Sync Framework Metadata Storage Service Components

The metadata storage service provides support for storing and handling synchronization metadata.

The metadata storage service is a set of interfaces that can be used by storage service writers to implement a custom set of classes to store metadata in any kind of data store. The metadata storage service also provides an implementation of the interface that uses a lightweight database to store synchronization metadata in a single database file in a file system.

Initializing Metadata

The main interface for all metadata stores is ISyncMetadataStore. This interface contains methods to initialize and get replica metadata in the metadata store, and to start and stop transactions on the database. Interfaces that inherit from this interface, such as ISqlSyncMetadataStore, can provide methods to create and open metadata stores.

ISyncMetadataStore::InitializeReplicaMetadata initializes replica metadata in the metadata store. The CUSTOM_FIELD_DEFINITION parameter to this method enables a set of custom fields to be created. These fields can be used to store additional metadata for items in the metadata store. The CUSTOM_FIELDS_INDEX parameter enables sets of fields to be defined as indexes. These indexes can be used to efficiently locate items in the metadata store.

Encapsulating Metadata for Replicas

The IReplicaMetadata interface encapsulates all the metadata for a particular replica. Replica metadata can be accessed by using methods such as IReplicaMetadata::GetKnowledge and IReplicaMetadata::GetReplicaId.

Several methods in this interface help implement synchronization provider methods, such as the following:

  • IReplicaMetadata::GetChangeBatch. This method can perform most of the work for the IKnowledgeSyncProvider::GetChangeBatch method.

  • IReplicaMetadata::GetItemBatchVersions. This method can be called from the IKnowledgeSyncProvider::ProcessChangeBatch method to find local versions of change batch items. These local versions are needed by the change applier.

IReplicaMetadata also contains the delete detection service. A provider can use methods such as IReplicaMetadata::GetUnreportedItems to detect which items have been deleted from the item store and should be marked as deleted in the metadata store.

Encapsulating Metadata for Items

Item metadata can be found in the metadata store by using IReplicaMetadata methods to search by item ID or indexed fields, such as IReplicaMetadata::FindItemMetadataByGlobalId or IReplicaMetadata::FindItemMetadataByIndexedFields. The IItemMetadata Interface class encapsulates all the metadata for a particular item. This metadata can be accessed by using methods such as IItemMetadata::GetChangeVersion, IItemMetadata::GetCreationVersion, IItemMetadata::GetGlobalId, and IItemMetadata::GetIsDeleted. This class also contains several methods that can be used to access any custom fields that were defined when the replica metadata was initialized.

The metadata storage service uses a set of custom errors to report problems. For more information, see Metadata Storage Error Codes.