Monday, 27 April 2009

Live Mesh Part 2

In my previous entry about Live Mesh I mentioned that you could use it to transfer data to and from the cloud in addition to straightforward file-sync operations.

To develop Mesh enabled applications you need to sign up to the Mesh developer site, but this is straightforward. You do need to remove the Live Mesh client to install the Live Framework Client and connect to https://developer.mesh-ctp.com rather than http://www.mesh.com, but presumably this will be rectified for final release You can download the SDK from here.

In the Live Framework SDK there are samples to demonstrate Mesh functionality. The Live Folders sample creates, edits and deletes files from the Mesh. These files and folders appear exactly the same as the synchronized folders created with Live Mesh. I would expect that long term you could synchronize with these folders, but at the moment the Live Framework Client is sandboxed and does not support the synchronization or remote control features of Live Mesh.

The following code creates a Live Mesh folder and you can see that the resource type is LIVE_MESH_FOLDER:

public static string CreateRootFolder(Mesh mesh, string title)

{

// Check if a folder with the same name exists.

foreach (MeshObject oneObject in mesh.MeshObjects.Entries)

{

if (oneObject.Resource.Title.Equals(title))

{

return "Folder already Exists!!!";

}

}

// Create folder object

MeshObject meshObject = new MeshObject(title);

// It is a mesh folder

meshObject.Resource.Type = MeshConstants.LIVE_MESH_FOLDER;

// Add folder to collection of mesh objects

mesh.MeshObjects.Add(ref meshObject);

// Create feed for files (required)

DataFeed fileDataFeed = new DataFeed(MeshConstants.LIVE_MESH_FILES);

// Set type and handler type (required)

fileDataFeed.Resource.Type = MeshConstants.LIVE_MESH_FILES;

fileDataFeed.Resource.HandlerType = MeshConstants.FILE_HANDLER_TYPE;

// Add new data feeds to collection

meshObject.DataFeeds.Add(ref fileDataFeed);

//this.LoadMeshObjects();

return "Root folder " + title + " created successfully";

}


There is also a Project Manager sample in the SDK. This is a simple application to create projects and milestones. It creates non-standard objects in Mesh. As you can see in the project code below, you can create your own class of object and are not constrained by standard folders and files:


///
/// UUID of the parent MeshObject
///
[DataMember]
public string MOID { get; set; }
///
/// Title of the milestone (during save/update, this matches MeshObject.Resource.Title,
/// but is stored here when the custom object is databound instead of the resource)
///
[DataMember]
public string Title { get; set; }
///
/// Date when project will be started
///
[DataMember]
public DateTime KickOffDate { get; set; }
///
/// Estimated Date for Completion
///
[DataMember]
public DateTime CompletionDate { get; set; }
///
/// Date when project was shipped
///
[DataMember]
public DateTime ShippedDate { get; set; }
///
/// Description of Project
///
[DataMember]
public string Description { get; set; }


When you deploy a Mesh application it appears both on the users Live Mesh website and also as a shortcut on their desktop. In this way, a user can just run the app without any knowledge of Live Mesh. Furthermore, because the data is synchronized between the local machine and the cloud, they can run the application when they are disconnected and it will automatically synchronize when connected although there is no conflict resolution built in.

This does come with some caveats. This is currently CTP and is not fully functional. As previously mentioned the developer environment does not currently integrate with the Live Mesh client. Also every time I tried to run an application from the desktop it said it was waiting for me to sign in with no opportunity for me to do so and regardless of whether I was signed in or not. There is also a risk that this is a solution waiting for a problem. It looks interesting, it’s quick and straightforward to Mesh enable applications, but there needs to be a compelling requirement for this to go beyond the trying out samples stage and into developing real applications.


In the code samples above, these are just snippets of the complete solution, but you can see that Live Mesh has both straightforward user file and folder synchronization, as well as an API to enable you to create a cloud-based solution.
As a final note, I looked into this as a way to synchronize favorites in IE8. You can now do this by signing up to SkyDrive and reinstalling the Live Toolbar.

Monday, 20 April 2009

Table and Index Partitioning in SQL Server 2008 Enterprise Edition

Introduction

SQL Server 2008 Enterprise enables you to horizontally partition individual tables and indexes so that data storage is spread over multiple drives. Horizontal partitioning is the process of dividing the data in a table or index by rows, so that some of the rows are contained in one location, some in a second location, some in a third, and so on. For example, with SQL Server 2008 Enterprise, you can partition large tables by date, so that each partition stores rows that correspond to a specific time period.
Partitioning has multiple benefits:
• Firstly, it enables you to make efficient use of the available disk capacity by controlling the placement of data from a single table or index across multiple disks. Partitions are mapped to filegroups, which in turn contain the files that hold the actual data.
• Secondly, partitioning enables flexible management of larger tables, for example by enabling you to backup a just subset of the rows in a table. Because partitions are mapped to filegroups, you can use SQL Server backup to backup just the filegroups that contain changed data.
• Thirdly, partitioning can make the loading new data a much faster procedure using the SWITCH option, which we’ll discuss shortly.
• Finally, and perhaps most significantly, partitioning can improve query response times for users.

Partition switching

Faster data loading can be achieved when you use the SWITCH clause of the ALTER TABLE statement. This enables you to swap a populated table or partition with an empty table or partition, provided that the they both have the same design structure, including the number, order, naming, and nullability of columns. For example, you could load new data by switching a populated table into a partitioned table and switching a named partition – say, partition 1 - out of that table. All that actually happens with this operation is that the metadata of the table and partition, including the table name and the partition name, are switched. No data actually needs to be moved, and as a result the process is very quick. You can also use the ALTER PARTITION FUNCTION statement with the MERGE and SPLIT clauses to merge two partitions together and to split an existing partition.

Performance improvements

Partitioning improves query response times on partitioned tables when users issues queries that filter rows by date, as is very often the case in large databases such as data warehouses. This is because SQL Server only needs to search through the partition or partitions that contain the relevant rows, which is more efficient. You can also limit lock escalation to the partition rather than the table, reducing the risk of blocking and deadlocking.
SQL Server 2008 offers a considerable improvement in performance over SQL Server 2005 for queries against partitioned tables that run on multiprocessor systems. In SQL Server 2005, if a user issued a query against a partitioned table and the query touched only one of the partitions in that table, all available threads could be allocated to that query, resulting in fast response times. If, however, the query touched more than one partition, then only one thread could be allocated per partition in the query, resulting in comparatively slower response times, particularly in cases where the majority of the data resided in just one of the partitions. This behaviour was by design and was actually intended to provide improved performance in the special case of a query touching only one partition, but from the users’ point of view, it sometimes meant that execution times seemed unpredictable. SQL Server 2008 addresses this issue with improved partitioned table parallelism. Queries that touch a single partition behave in the same way as they do in SQL Server 2005, and all available threads are allocated to the query. Queries that touch multiple partitions now have all available threads allocated to them, with the threads being distributed in a round-robin fashion. For example, on a server that has four cores, a query that touches one partition will have all four threads allocated to it. A query that touches two partitions will have all four allocated again, with two available per partition. In SQL Server 2005, this second query would only have had one thread available per partition. This new behaviour can result in drastic improvements in performance, with some queries running ten to fifteen times faster.

Summary

Table and index partitioning is a powerful feature that offers many benefits to administrators who manage large databases. SQL Server 2008’s enhanced partitioning delivers impressive performance on multi-core servers, enabling you to get more out of your existing hardware.

Monday, 6 April 2009

Live Mesh

I came across a new Windows Live component the other day called Live Mesh
when searching for a way to synchronize my favorites. In IE7 you could synchronize favorites with Live Favorites. It worked pretty well, although by no means perfectly. This functionality was removed from IE8, which annoyed me somewhat. I work from home most of the time, but occasionally go into the office and take a laptop. Virtually all documents I use are checked into SharePoint, so I don’t lose any data when I switch machines, however there are always useful bits and pieces that I pick up on the Web and I usually just add these to favorites. This is where the upgrade to IE8 is giving me problems. Not insurmountable, obviously, but I want everything to work smoothly. A blogger called Laurent Duveau has used Live Mesh to do just this. Looking further into Live Mesh made me realise its other capabilities. It interested me through a connection with the Azure Services Platform, of which it is a part, and through its data synchronization and remote control functionality.
Live Mesh allows you to synchronize folders with the cloud. You set up a device and then simply right click a folder to begin synchronizing data. This sounds a bit like functionality already provided by Live Sync and SkyDrive, however Live Sync requires both computers to be connected at the same time and SkyDrive is just online storage with no more advanced functionality.


So what more does Live Mesh offer? Well, for a start, the whole process is automatic and painless. You add a folder and the folder is synched. You can add another device and keep the data synched across multiple devices. These devices will include Windows Mobile and Apple Macs in the future. The data is both held locally, so that it can be accessed offline, and in the cloud, so that it can be accessed anywhere. This solved my favorites problem, but also made me curious as to the capabilities of Live Mesh.

Other features include remote desktop. Now not only do I have all my data synchronized, I can also connect to my desktop PC from anywhere. So far, these are all features available with the use of a few tools, but there is another trick up the Live Mesh sleeve. There is a Live Framework with various APIs including .NET, Silverlight and JavaScript to use Live Mesh services. This not only allows you to share folders as you normally would with Live Mesh, but also allows any data to be stored and synchronized between devices. I’ll leave the Live Framework for another day, but it appears to offer interesting possibilities.
Of course, this is a beta, but when the minor errors are ironed out this could be a valuable data synchronization tool.

Tuesday, 24 March 2009

Silverlight 3 Released

Silverlight 3 Beta was announced at the MIX 09 event in Las Vegas. The new version pushes the envelope in providing richer online applications through its various new features, controls, and methods of development. Some of the great Silverlight 3 features include the Out-Of-Browser experience, Search Engine Optimization, and improved graphic support. In this article, I will show you some of the cool features from Silverlight 3.

Developer Version

The current version of Silverlight 3 Beta is intended for developer use only. This means that you will need the Developer runtime to view Silverlight 3 applications. There is no “Go Live” support and not intended for public viewing. The end user runtime will be available later this year. Developers will need to ensure that they define the install experience in an appropriate manner to inform the end user that the application is in the beta stage. Tim Heuer wrote a great blog article about the Silverlight 3 Install Experience.

Let’s Get Started

Before you start developing in Silverlight 3, you will need to be aware that this is a Beta version and must treated as such. Silverlight 2 applications can be viewed, but not developed, with the new runtime. If you plan on developing Silverlight 3 applications, it is recommended to install Silverlight 3 on its own machine or virtual machine. Once you have installed Silverlight 3, you won’t be able to deploy Silverlight 2 applications on the same machine.

The following tools are the bare minimum needed to develop Silverlight 3 applications:

For more information on getting started with Silverlight, check out the Microsoft Silverlight 3 Site. The site includes the necessary tools, tutorials, and information to rapidly get you started.

Silverlight Toolkit

During MIX 09, the Silverlight Toolkit March 2009 was released with additional controls. One of the major change in the new Toolkit is the move from Microsoft.Windows.Controls to System.Windows.Controls namespace. The Toolkit includes two new themes: BubbleCreme & TwilightBlue. Some of the great new controls in the Toolkit include the Accordion and DomainUpDown. The Accordion control stores a list of collapsed and expanded AccordionItem controls. This concept is similar to a grouped collection of Expander controls, which allows you to organize data or XAML elements in a clean manner. The DomainUpDown control allows the user to cycle through a list of values using the TextBox and Spinner controls.

To learn more about the new features, check out the Silverlight Toolkit Breaking Changes.

New Controls

Silverlight 3 is shipped with new controls, along with a mature set of controls from Silverlight Toolkit. Some of the mature controls from Silverlight Toolkit include DockPanel, WrapPanel, Label, TreeView, Expander, and DataGrid. If you have used any of these controls in older applications, they will still work with Silverlight 3. Silverlight 3 also utilizes new controls for data, search engine optimization, and overall development.

Two new Data controls, DataForm and DataPager, can be used to render data in Silverlight applications. The DataForm control displays data for a single entity and allows for traditional data manipulation, including edit and update. The DataPager control allows the navigation through a data set.

Silverlight 3 introduces the navigation framework (System.Windows.Control.Navigation), which is composed of the Page and Frame controls. The Frame control hosts a single Page control utilizes the Navigation APIs to allow the user to navigate between the pages. The Page control resembles the commonly used UserControl control to hold the contents of the respected page. This feature allows you to create applications that resemble a web page using a single xap file. The primary benefit of the framework is the ability to communicate with the browser in regards to the Address Bar and Browser History. The currently loaded XAML file is stored in the Address Bar, which allows for deep linking in Silverlight applications and providing SEO. The framework also maintains the history of navigated pages, which can be access using the browser’s back and forward functionality.

The ChildWindow control makes its way to Silverlight 3. Child Windows, also known as modal windows, are used to draw attention to important information or to halt the application flow for user input. The child window blocks the workflow until the window is closed. The window stores the result in DialogResult to inform the application of its status upon closing. Unlike the traditional modal window, Silverlight renders the child window with an animation sequence and renders an overlay background to ensure the user focuses on the window.

Graphic Enhancements

Silverlight 3 sports significant graphical enhancements including 3D perspective transforms, pixel shaders, GPU acceleration, and animation easing. The new version also has a Bitmap API for manipulating bitmap pixels.

Perspective Transforms in Silverlight 3 is the next step towards developing 3D Silverlight applications. In previous versions of Silverlight, transforms were processed in the X and Y axis using the UIElement’s RenderTransform property. Silverlight 3 uses the PlaneProjection class to render 3D-like effects by applying content to a 3D plane. All elements, that derive from UIElement, have the Projection property that allows the element to simulate translation and rotation transformations in a 3D space. This feature allows for 3D-like user interfaces, flipping animations, and transition effects.

Silverlight 3 has two built-in effects, Blur and DropShadow, and supports the development of custom effects. Pixel Shaders are a compiled set of software instructions that calculate the color of the pixels and executed on the GPU. The instructions are written in HLSL (High Level Shader Language). All elements, that derive from UIElement, have the Effect property that allows the element to render with the connected pixel shader. This feature allows for more rich and beautiful user interfaces and transition effects.

GPU hardware acceleration reduces the CPU processing workload by performing the tasks directly on GPU hardware. This allows for full screen HD renderings of video to run on your computer without taking up a large load of CPU. GPU rendering can also be used to cache XAML and image elements.

The animation system has been upgraded with Easing functions to provide more natural and advanced animation. Developers can create their own custom easing functions by modifying the built-in function or deriving from the EasingFunctionBase. Silverlight 3 comes with several built-in easing functions, including the following:

  • BackEase
  • BounceEase
  • CircleEase
  • CubicEase
  • ElasticEase
  • ExponentialEase
  • PowerEase
  • QuadraticEase
  • QuarticEase
  • QuinticEase
  • SineEase

The Bitmap API allows rendering XAML elements and data to bitmaps using the WriteableBitmap class. This can be used to modify images, capture a frame from a MediaElement control, and render the current state of a control.

Media Support

Silverlight 3 adds support for additional standard media types, including H.264 and AAC, and supports third party codecs to decode outside the runtime and render in the Silverlight application. This allows for a wide variety of video and audio files to be played in Silverlight. Using GPU hardware acceleration, applications can now deliver full-screen HD content.

Themes and Styles

Silverlight 3 improves the themes and styles system to allow designers and developers to customize the look and feel of their applications. Unlike previous versions of Silverlight, Silverlight 3 supports changing styles during runtime. Styles can be stored externally in resource dictionary to allow for organized and shareable code. This allows developers to easily share and merge their styles among different projects. Styles now support an inherited system to reduce necessary code for redundant styles.

Out of Browser Experience

Silverlight applications can run outside of the browser with simple modifications by the developer. The end user can choose whether to install the application on the user’ Start menu and Desktop. One major benefit is that the end user can run the application at home, at work, and on the go without the need of a web browser and online access. Installed applications can be automatically updated to ensure that the end user has the latest version. The new Network APIs allows the application to know whether the application is connected or not.

Element to Element Binding

Element to element data binding allows you to bind element properties to each other. In previous versions of Silverlight, this would require more work on the code side because the element would fire its changed method and have that update the necessary elements. Silverlight 3 simplifies this process by performing the task directly in XAML.

Conclusion

Silverlight 3 has a lot of fantastic features to create the next generation of interactive applications. This article has only scratched the surface on the Silverlight 3 features. For more information on Silverlight 3, check out http://silverlight.net/getstarted/silverlight3/default.aspx. Additional information on Silverlight 3 can be found on the many MIX 09, which can be viewed at http://sessions.visitmix.com/MIX09/.

Sunday, 22 March 2009

Mix 09 Day 1


Welcome to the second post in Mix 09 set, Here is what happened on the first official day of the event.

Keynote

After breakfast, we headed into the main hall at the Venetian for the day one keynote. While we were waiting for the session to start, we were entertained by DJ Riz (who is a famous DJ in Seattle so I am told) while some impressive visuals were being shown on the big screens. One of these was a really cool idea – a game of Tetris with each of the falling blocks being a recent tweet that was tagged with #mix09. I tried to take some photos of people who I recognised, so check out the flickr feed – it has to be seen to be believed.

At 9am, out came the legendary Bill Buxton who delivered a very energised talk on industrial design and how companies are now not just selling software, but also the user experience that goes along with them.

Scott Guthrie was then introduced (using a very funny video available here) and delivered the more specific information on the new versions of the upcoming products.

Expression Web 3 is getting an exiting new feature called SuperPreview. This allows you to compare your sites in other browser rendering engines using them as an overlay. This gets cooler still as there is even a cloud service that will download preview data for browsers that you don't have installed locally. You can even use this service to see what your site will look like in IE 6,7, 8 etc.

If you’re an ASP developer, you may already know that MVC V1.0 was shipped recently. This was talked about briefly before a talk on ASP.NET 4 and VS 2010. Here, a feature termed  “Velocity” (distributed caching) will be included in the platform and it will also get the dynamic routing engine built originally for MVC.

The Web Platform installer is getting an update to keep you up to date with all the latest stuff going on in the web world. This installer will also keep you updated with bits that ship separately from a main product as well as all the latest beta versions that happen to be available. Support for the Web Application Gallery has also been added to enable you to keep updated with other applications such as Wordpress.

The Azure Services Platform is also getting PHP support and the ability to run full trust applications. SQL Data Services is also exposing a Relational data model and .NET Services is supporting additional web standards. 

Some additional (really cool) Silverlight controls are coming up for the Virtual Earth service and the WorldWide Telescope. No dates were given but the demos looked awesome.

Kevin McEntee, VP of Web Engineering for Netflix talked about his experiences of using Silverlight to deliver movie content in the browser using adaptive streaming. This enables a users stream to change dynamically to give them a better user experience.

Silverlight 3.0

Silverlight 3 is introducing some cool new graphical features to the core platform. These include GPU acceleration and hardware compositing (on both PC and Mac), perspective 3D support, bitmap and pixel APIs, HLSL-based pixel shader effects and some DeepZoom improvements including the ability to use a hardware-accelerated, larger collection of images

Deep linking is also coming for ease of navigation and search engine optimisation. This enables you to directly link to and bookmark a place within an application.

David Anthony from Bondi Digital Publishing and Scott Stanfield from Vertigo introduced a new Silverlight 3 masterpiece. This is in the form of a magazine viewer that enables you to search through and read the thousands of Rolling Stone back issues. This is due to go live in the summer but a preview edition with some back issues of Playboy is online now.

Tom Mara, Executive Director of KEXP came on stage to show the stations Silverlight application and how it interacts with users. More importantly, this demonstration shows the new “Out Of Browser” feature that allows you to install a Silverlight app locally. This is all done from the right-click context menu without the need to Add/Remove the application like a standard piece of software. Installing works a lot like ClickOnce if you are familiar with that. 

Tools

Expression Blend 3 was then announced which adds a plethora of really cool and useful features to the product.

SketchFlow is the largest of these and this make it possible for designers to concentrate on the flow of the application. This uses a mind map type control to create rough states and link them together. The interface can then be drawn out using silverlight controls with a special “sketch” template added to them to draw attention away from the way it looks and concentrate more on how it works. Support for importing image assets from Adobe Photoshop and Adobe Illustrator, behaviours, dummy data, source code control, and IntelliSense all make an appearance in this version.

The Sessions

The sessions i attended on Day 1 were “What's new in Silverlight 3", “Microsoft Silverlight Media” and “Mesh Enabled Web Applications”. Needless to say they were all very informative and the sessions are all online now here 

The Party at TAO

The TAO night club is Las Vegas was a very nice place – Microsoft always know how to throw a good party and this one was no exception. I was even lucky enough to meet and have a conversation with Bill Buxton about Design, Expression and the UK of all things