As you know we’ve released the V1.0 of Sync Services for ADO.NET as a standalone package. It is also bundled with Visual Studio 2008 with additional Sync Designer experience. Sync Services is one component in a comprehensive sync platform offering from Microsoft called Microsoft Sync Framework that we unleashed recently. The Sync Framework is publicly available as an early CTP release. With it, you will find a new version of Sync Services for ADO.NET that adds on top of V1 components a new provider called DbPeerSyncProvider. Well, let’s talk a little bit about this new guy.
Sync applications tend to evolve over time; let’s say you started by adding offline capabilities to your application, your customers loved it, but then they ask for more. They wanted to have the same experience on the device; well, no big deal, you tweaked your app to work on devices as well as desktop. Both flavors of your app take data offline and synchronize with some useful service you have on the cloud. Now, some savvy customers will come to you and say, “My data plan is expensive, can I synchronize my mobile device with the desktop instead of going to the web?” others might say, “we need to be able to synchronize with one another in an ad-hook fashion!” … So now you have a growing demand to support a different model than that of a central server database. You need to build peer to peer sync system. Your central database will become yet another peer(s) in an ever growing topology!
This scenario is not uncommon, but technology seems to lack big time when you move to loosely-coupled multi master sync scenarios. This is where DbPeerSyncProvider comes in to fill this gap.
You will feel at home when looking at the DbPeerSyncProvider interface. It follows the same programming model introduced with DbServerSyncProvider. Let’s see what commands we have on the provider and sync adapter:
The provider interface contains thee commands that you need to define. These commands are used by the provider to manage key information about this node including metadata summary for the contents on this node. This summary is formally known as ‘knowledge’ object in the sync framework. Using the knowledge object, one can tell very quickly if two nodes are in sync or not. The provider commands are:
The ‘scope’ refers to the set of tables that this provider synchronizes. A given node could have multiple scopes. This is similar to the table group concept in the client\server provider terminology.
Each adapter represents a table in the scope on the node. The sync adapter interface carries nine commands that can be further categorized as follows:
- Change Enumeration
Just one command is used to enumerate incremental changes from the database. This is different from the DbServerSyncProvider where we have three commands instead.
- Change Application
As you might expect, there are three commands for applying inserts, updates and deletes. In addition there is another command for getting a hold of a given row or its metadata. This command is mostly used during change application.
- Tombstone Cleanup
The peer provider needs to record in its summary the fact that tombstones have been deleted. That said, the provider will use this command in which you, the developer, defines the criteria for deleted rows to be cleanup (tombstones older than 10 days, for example), to find those tombstones and record the needed metadata for you then delete the rows. No worries, this command is just a simple select statement, the provider will do the heavy lifting for you.
- Metadata Management
In the p2p sync world, metadata is king! By this statement I am trying to underline the importance of the metadata management and the ability of the provider to tweak them as it sees fit. There are three metadata management commands that give the provider the control to insert, update and delete metadata for a given row.
This just a quick introduction to our new provider, there is a lot to talk about as we move forward with building sharing applications using this provider. Check out the documentation on the sync dev center, and give the bits a test drive!
More to come…
I am not actively blogging about Sync Technologies. Please see Sync Team Blog for more updated content.