public DbSyncProvider(IDbConnection Connection, string Name) { log.Debug("ctor"); this._Db = new SyncDatabase(Connection); this._Name = Name; Configuration.ConflictResolutionPolicy = ConflictResolutionPolicy.SourceWins; // установка значений форматов идентификаторов idFormats = new SyncIdFormatGroup(); // для идентификаторов изменений используется BIGINT (2^64) IdFormats.ChangeUnitIdFormat.Length = 64; // filter-id какие то, пока не знаю что это IdFormats.FilterIdFormat.Length = 64; // идентификатор элементов IdFormats.ItemIdFormat.Length = 256; IdFormats.ItemIdFormat.IsVariableLength = true; IdFormats.ReplicaIdFormat.Length = 300; IdFormats.ReplicaIdFormat.IsVariableLength = true; // создание таблицы, которая будет использована для сбора информации о синхронизации tableSyncLog = new DataTable(); log.Debug("ctor finished"); }
public MetadataStore(SyncIdFormatGroup idFormats) { var replicaMetadataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "MegaDesktop"); _replicaMetadataFile = Path.Combine(replicaMetadataFolder, "nodes.metadata"); _idFormats = idFormats; }
public TestProvider( Guid replicaId, string metadataFilePath ) { _metadataFilePath = metadataFilePath; _replicaId = new SyncId(replicaId); //// Set ReplicaIdFormat to use a GUID as an ID, and ItemIdFormat to use a GUID plus //// an 8-byte prefix. //_idFormats = new SyncIdFormatGroup(); //_idFormats.ItemIdFormat.IsVariableLength = false; //_idFormats.ItemIdFormat.Length = 24; //_idFormats.ReplicaIdFormat.IsVariableLength = false; //_idFormats.ReplicaIdFormat.Length = 16; this._idFormats = new SyncIdFormatGroup(); this._idFormats.ChangeUnitIdFormat.IsVariableLength = false; this._idFormats.ChangeUnitIdFormat.Length = (ushort)4; this._idFormats.ItemIdFormat.IsVariableLength = false; this._idFormats.ItemIdFormat.Length = (ushort)24; this._idFormats.ReplicaIdFormat.IsVariableLength = false; this._idFormats.ReplicaIdFormat.Length = (ushort)16; CreateMetadataStore(metadataFilePath); _metadataSchema = CreateMetadataSchema(); }
public CachedChangeDataRetriever( IChangeDataRetriever changeDataRetriever, ChangeBatchBase sourceChanges) { _idFormats = changeDataRetriever.IdFormats; _cachedData = new Dictionary<SyncId, SyncTransferData>(); // Look at each change in the source batch foreach (ItemChange itemChange in sourceChanges) { if (itemChange.ChangeKind != ChangeKind.Deleted) { // This is not delete, so there is some data associated // with this change. // Create a UserLoadChangeContext to retriever this data. UserLoadChangeContext loadChangeContext = new UserLoadChangeContext( _idFormats, itemChange); // Retrieve the data (we know that our provider uses data of type ItemData. SyncTransferData itemData = changeDataRetriever.LoadChangeData(loadChangeContext) as SyncTransferData; // Cache it _cachedData.Add(itemChange.ItemId, itemData); } } }
//private void RecordCollisionConflict(SaveChangeContext context, MegaStoreConstraintException e) //{ // var existingItem = e.Node == null ? null : // _metadataStore.FindItemMetadataByNodeId(e.Node.Node.Id); // if (existingItem != null) // { // // ConstraintConflictReason.Collision does not fire the collision resolver!!!11 // context.RecordConstraintConflictForItem(existingItem.GlobalId, ConstraintConflictReason.Other); // } // else // { // context.RecordRecoverableErrorForItem(new RecoverableErrorData(e)); // } //} //private void RecordConcurrencyConflict(SaveChangeContext context, MegaStoreConcurrencyException e) //{ // var existingItem = e.Node == null ? null : // _metadataStore.FindItemMetadataByNodeId(e.Node.Node.Id); // // try to handle in a regular way // if (existingItem != null) // { // context.RecordConstraintConflictForItem(existingItem.GlobalId, ConstraintConflictReason.Other); // } // // we are doomed! // else // { // context.RecordRecoverableErrorForItem(new RecoverableErrorData(e)); // } //} #endregion #region default implementation of interfaces public ChangeApplier(MetadataStore metadataStore, SyncIdFormatGroup idFormats, NodeStore nodeStore) { _metadataStore = metadataStore; _idFormats = idFormats; _nodeStore = nodeStore; AssumeSameFiles = true; }
public CachedChangeDataRetriever( IChangeDataRetriever changeDataRetriever, ChangeBatchBase sourceChanges) { this.idFormats = changeDataRetriever.IdFormats; this.cachedData = new Dictionary <SyncId, Sync101.ItemData>(); // Look at each change in the source batch foreach (ItemChange itemChange in sourceChanges) { if (itemChange.ChangeKind != ChangeKind.Deleted) { // This is not delete, so there is some data associated // with this change. // Create a UserLoadChangeContext to retriever this data. UserLoadChangeContext loadChangeContext = new UserLoadChangeContext( idFormats, itemChange); // Retrieve the data (we know that our provider uses data of type ItemData. ItemData itemData = changeDataRetriever.LoadChangeData( loadChangeContext) as ItemData; // Cache it cachedData.Add(itemChange.ItemId, itemData); } } }
public CachedChangeDataRetriever(IChangeDataRetriever changeDataRetriever, ChangeBatchBase sourceChanges) { idFormats = changeDataRetriever.IdFormats; cachedData = new Dictionary <SyncId, ISyncDataObject>(); var changeItems = sourceChanges.Where(o => o.ChangeKind != ChangeKind.Deleted).Select(o => new UserLoadChangeContext(idFormats, o)); cachedData = (changeDataRetriever as PosDbSyncProvider).LoadChangeDatas(changeItems); }
public SyncDetails(string folderPath, bool load) { if (load) { this.idFormats = GetIdFormat(); this.folderPath = folderPath; Load(); } }
public override ReplicaMetadata InitializeReplicaMetadata(SyncIdFormatGroup idFormats, SyncId replicaId, IEnumerable <FieldSchema> customItemFieldSchemas, IEnumerable <IndexSchema> customIndexedFieldSchemas) { if (_replicaMetaData == null) { throw new NullReferenceException("not initialized"); } return(GetReplicaMetadata(idFormats, replicaId)); }
public RemoteProviderProxy(int companyId, string storeId, string endpointConfigurationName, string syncDataServiceName) { this.syncDataServiceName = syncDataServiceName; this.endpointConfigurationName = endpointConfigurationName; _companyId = companyId; _storeId = storeId; // Create a client this.client = new PosServerDbSyncServiceClient( endpointConfigurationName); this.client.CreateProviderForSyncSession(companyId, storeId, syncDataServiceName); this.idFormats = this.client.GetIdFormats(); }
/// <summary> /// Создает новое хранилище метаданных реплики /// </summary> /// <param name="replicaId">The replica id.</param> /// <param name="idFormats">The id formats.</param> /// <returns></returns> public static ReplicaMetadataAdaptor CreateInstance(SyncId replicaId, SyncIdFormatGroup idFormats) { SynchronizationReplicaRow row = new SynchronizationReplicaRow(); row.TickCount = 1; ReplicaMetadataAdaptor retVal = new ReplicaMetadataAdaptor(row); retVal._replicaRow.PrimaryKeyId = replicaId.GetGuidId(); retVal.ReplicaKeyMap = new ReplicaKeyMap(idFormats, replicaId); retVal.CurrentKnowledge = new SyncKnowledge(idFormats, retVal.ReplicaKeyMap, (ulong)retVal.TickCount); retVal.ForgottenKnowledge = new ForgottenKnowledge(idFormats, retVal.CurrentKnowledge); return(retVal); }
public SyncProvider(SessionBase session) { m_session = session; m_idFormatGroup = new SyncIdFormatGroup(); m_idFormatGroup.ChangeUnitIdFormat.IsVariableLength = false; m_idFormatGroup.ChangeUnitIdFormat.Length = sizeof(UInt64); m_idFormatGroup.ItemIdFormat.IsVariableLength = false; m_idFormatGroup.ItemIdFormat.Length = sizeof(UInt64); m_idFormatGroup.ReplicaIdFormat.IsVariableLength = false; m_idFormatGroup.ReplicaIdFormat.Length = sizeof(UInt64); }
// Construct a data store by providing a name for the endpoint (replica) and // a file to which we'll persist the sync metadata (file) public MySyncProvider(string name, MySimpleDataStore store) { _name = name; _store = store; _replicaMetadataFile = Environment.CurrentDirectory + "\\" + _name.ToString() + ".Metadata"; _replicaIdFile = Environment.CurrentDirectory + "\\" + _name.ToString() + ".Replicaid"; // Set ItemIdFormat and ReplicaIdFormat for using Guid ids. _idFormats = new SyncIdFormatGroup(); _idFormats.ItemIdFormat.IsVariableLength = false; _idFormats.ItemIdFormat.Length = 16; _idFormats.ReplicaIdFormat.IsVariableLength = false; _idFormats.ReplicaIdFormat.Length = 16; }
// Construct a data store by providing a name for the endpoint (replica) and // a file to which we'll persist the sync metadata (file) public MySyncProvider(string folderPath, string name) { _name = name; _folderPath = folderPath; _replicaMetadataFile = _folderPath.ToString() + "\\" + _name.ToString() + ".Metadata"; _replicaIdFile = _folderPath.ToString() + "\\" + _name.ToString() + ".Replicaid"; // Set ItemIdFormat and ReplicaIdFormat for using Guid ids. _idFormats = new SyncIdFormatGroup(); _idFormats.ItemIdFormat.IsVariableLength = false; _idFormats.ItemIdFormat.Length = 16; _idFormats.ReplicaIdFormat.IsVariableLength = false; _idFormats.ReplicaIdFormat.Length = 16; }
public RemoteProviderProxy( string folderPath, string storeName, string endpointConfigurationName) { this.folderPath = folderPath; this.storeName = storeName; this.endpointConfigurationName = endpointConfigurationName; // Create a client this.client = new Sync101WebServiceClient( endpointConfigurationName); this.client.CreateProviderForSyncSession(folderPath, this.storeName); this.idFormats = this.client.GetIdFormats(); }
public static SyncIdFormatGroup GetIdFormats() { SyncIdFormatGroup idFormats = new SyncIdFormatGroup(); // 1 byte change unit id idFormats.ChangeUnitIdFormat.IsVariableLength = false; idFormats.ChangeUnitIdFormat.Length = 1; // Set format of replica id for using Guid ids idFormats.ReplicaIdFormat.IsVariableLength = false; idFormats.ReplicaIdFormat.Length = 16; // Set format of item id for using Sync id idFormats.ItemIdFormat.IsVariableLength = false; idFormats.ItemIdFormat.Length = 24; return(idFormats); }
// Construct a data store by providing a name for the endpoint (replica) and // a file to which we'll persist the sync metadata (file) internal AzureBlobSyncProvider(string accountName, string containerName, string accountKey, string metadataDirectory) { _name = containerName; _replicaMetadataFile = Path.Combine(metadataDirectory, _name + ".Metadata"); _replicaIdFile = Path.Combine(metadataDirectory, _name + ".Replicaid"); DataStore = new AzureBlobStore(accountName, containerName, accountKey); // Set ItemIdFormat and ReplicaIdFormat for using Guid ids. _idFormats = new SyncIdFormatGroup(); _idFormats.ChangeUnitIdFormat.IsVariableLength = false; _idFormats.ChangeUnitIdFormat.Length = 4; _idFormats.ItemIdFormat.IsVariableLength = false; _idFormats.ItemIdFormat.Length = 24; _idFormats.ReplicaIdFormat.IsVariableLength = false; _idFormats.ReplicaIdFormat.Length = 16; }
public SyncIdFormatGroup GetIdFormats() { if (_idFormats == null) { _idFormats = new SyncIdFormatGroup(); // 4 byte change unit id _idFormats.ChangeUnitIdFormat.IsVariableLength = false; _idFormats.ChangeUnitIdFormat.Length = 4; // Set format of replica id for using Guid ids _idFormats.ReplicaIdFormat.IsVariableLength = false; _idFormats.ReplicaIdFormat.Length = 16; // Set format of item id for using global id _idFormats.ItemIdFormat.IsVariableLength = false; _idFormats.ItemIdFormat.Length = 24; } return(_idFormats); }
public MegaProvider(Mega api, string syncFolderName) { this.api = new MegaStore(api, syncFolderName); this.api.ProgressChanged += (s, e) => OnProgressChanged(); _replicaMetadataFile = MetadataDirectory + _name + ".Metadata"; _replicaIdFile = MetadataDirectory + _name + ".Replicaid"; _idFormats = new SyncIdFormatGroup(); _idFormats.ChangeUnitIdFormat.IsVariableLength = false; _idFormats.ChangeUnitIdFormat.Length = 4; _idFormats.ItemIdFormat.IsVariableLength = false; _idFormats.ItemIdFormat.Length = 24; _idFormats.ReplicaIdFormat.IsVariableLength = false; _idFormats.ReplicaIdFormat.Length = 16; this.ItemConstraint += new EventHandler <SimpleSyncItemConstraintEventArgs>(OnItemConstraint); this.ItemConflicting += new EventHandler <SimpleSyncItemConflictingEventArgs>(OnItemConflicting); }
public MegaKnowledgeProvider(NodeStore store) { _nodeStore = store; _idFormats = new SyncIdFormatGroup(); _idFormats.ChangeUnitIdFormat.IsVariableLength = false; _idFormats.ChangeUnitIdFormat.Length = 4; _idFormats.ItemIdFormat.IsVariableLength = false; _idFormats.ItemIdFormat.Length = 24; _idFormats.ReplicaIdFormat.IsVariableLength = false; _idFormats.ReplicaIdFormat.Length = 16; _metadataStore = new MetadataStore(_idFormats); _changeApplier = new ChangeApplier(_metadataStore, _idFormats, _nodeStore); _changeApplier.AppliedChange += OnAppliedChange; _changeApplier.DemandedResync += (s,e) => NeedResync = true; //Configuration.CollisionConflictResolutionPolicy = }
public MegaKnowledgeProvider(NodeStore store) { _nodeStore = store; _idFormats = new SyncIdFormatGroup(); _idFormats.ChangeUnitIdFormat.IsVariableLength = false; _idFormats.ChangeUnitIdFormat.Length = 4; _idFormats.ItemIdFormat.IsVariableLength = false; _idFormats.ItemIdFormat.Length = 24; _idFormats.ReplicaIdFormat.IsVariableLength = false; _idFormats.ReplicaIdFormat.Length = 16; _metadataStore = new MetadataStore(_idFormats); _changeApplier = new ChangeApplier(_metadataStore, _idFormats, _nodeStore); _changeApplier.AppliedChange += OnAppliedChange; _changeApplier.DemandedResync += (s, e) => NeedResync = true; //Configuration.CollisionConflictResolutionPolicy = }
// Construct a data store by providing a name for the endpoint (replica) and // a file to which we'll persist the sync metadata (file) internal AzureBlobSyncProvider( string name, AzureBlobStore store ) { _name = name; _store = store; _replicaMetadataFile = MetadataDirectory + _name + ".Metadata"; _replicaIdFile = MetadataDirectory + _name + ".Replicaid"; // Set ItemIdFormat and ReplicaIdFormat for using Guid ids. _idFormats = new SyncIdFormatGroup(); _idFormats.ChangeUnitIdFormat.IsVariableLength = false; _idFormats.ChangeUnitIdFormat.Length = 4; _idFormats.ItemIdFormat.IsVariableLength = false; _idFormats.ItemIdFormat.Length = 24; _idFormats.ReplicaIdFormat.IsVariableLength = false; _idFormats.ReplicaIdFormat.Length = 16; }
public PosDbSyncProvider(int companyId, string storeId, ISyncDataService syncContext) { ReadRedisLog = false; CompanyId = companyId; StoreId = storeId; _syncContext = syncContext; // _store = store; var syncTempDirectory = "SyncTemp"; var syncDirectory = string.Format(@"{0}{1}\Company{2}strore{3}", AppDomain.CurrentDomain.BaseDirectory, syncTempDirectory, companyId, storeId); if (!Directory.Exists(syncDirectory)) { Directory.CreateDirectory(syncDirectory); } _replicaMetadataFile = string.Format(@"{0}\{1}.Metadata", syncDirectory, syncContext.Name); _replicaIdFile = string.Format(@"{0}\{1}.Replicaid", syncDirectory, syncContext.Name); DestinationCallbacks.ProgressChanged += DestinationCallbacks_ProgressChanged; _idFormats = new SyncIdFormatGroup(); _idFormats.ItemIdFormat.IsVariableLength = false; _idFormats.ItemIdFormat.Length = 16; _idFormats.ReplicaIdFormat.IsVariableLength = false; _idFormats.ReplicaIdFormat.Length = 16; }
public override void RemoveReplicaMetadata(SyncIdFormatGroup idFormats, SyncId replicaId) { throw new NotImplementedException(); }
public override ReplicaMetadata GetReplicaMetadata(SyncIdFormatGroup idFormats, SyncId replicaId) { SyncReplicaMetadata retVal = new SyncReplicaMetadata(idFormats, replicaId, _replicaMetaData); return(retVal); }
public SyncReplicaMetadata(SyncIdFormatGroup idFormats, SyncId replicaId, ReplicaMetadataAdaptor replica) : base(idFormats, replicaId) { Replica = replica; }
public override ReplicaMetadata GetReplicaMetadata(SyncIdFormatGroup idFormats, SyncId replicaId) { SyncReplicaMetadata retVal = new SyncReplicaMetadata(idFormats, replicaId, _replicaMetaData); return retVal; }
public override ReplicaMetadata InitializeReplicaMetadata(SyncIdFormatGroup idFormats, SyncId replicaId, IEnumerable<FieldSchema> customItemFieldSchemas, IEnumerable<IndexSchema> customIndexedFieldSchemas) { if (_replicaMetaData == null) { throw new NullReferenceException("not initialized"); } return GetReplicaMetadata(idFormats, replicaId); }
public MegaProvider(Mega api, string syncFolderName) { this.api = new MegaStore(api, syncFolderName); this.api.ProgressChanged += (s, e) => OnProgressChanged(); _replicaMetadataFile = MetadataDirectory + _name + ".Metadata"; _replicaIdFile = MetadataDirectory + _name + ".Replicaid"; _idFormats = new SyncIdFormatGroup(); _idFormats.ChangeUnitIdFormat.IsVariableLength = false; _idFormats.ChangeUnitIdFormat.Length = 4; _idFormats.ItemIdFormat.IsVariableLength = false; _idFormats.ItemIdFormat.Length = 24; _idFormats.ReplicaIdFormat.IsVariableLength = false; _idFormats.ReplicaIdFormat.Length = 16; this.ItemConstraint += new EventHandler<SimpleSyncItemConstraintEventArgs>(OnItemConstraint); this.ItemConflicting += new EventHandler<SimpleSyncItemConflictingEventArgs>(OnItemConflicting); }
public static SyncIdFormatGroup GetIdFormat() { SyncIdFormatGroup idFormats = new SyncIdFormatGroup(); idFormats.ChangeUnitIdFormat.IsVariableLength = false; idFormats.ChangeUnitIdFormat.Length = 1; idFormats.ReplicaIdFormat.IsVariableLength = false; idFormats.ReplicaIdFormat.Length = 16; idFormats.ItemIdFormat.IsVariableLength = false; idFormats.ItemIdFormat.Length = 24; return idFormats; }