Ejemplo n.º 1
0
        /// <summary>
        /// Возвращает пакет изменений, содержащий метаданные элементов, которые отсутствовали в указанном наборе знаний от поставщика назначения
        /// </summary>
        /// <param name="batchSize">Size of the batch.</param>
        /// <param name="destinationKnowledge">The destination knowledge.</param>
        /// <returns></returns>
        public override ChangeBatch GetChangeBatch(uint batchSize, SyncKnowledge destinationKnowledge)
        {
            ChangeBatch retVal    = null;
            ulong       tickCount = GetNextTickCount();


            List <ItemChange> changes = DetectChanges(destinationKnowledge, batchSize);

            retVal = new ChangeBatch(IdFormats, destinationKnowledge, Replica.ForgottenKnowledge);

            // Add the changes to the ChangeBatch with our made with knowledge
            // (Made width knowledge is the knowledge the other side will "learn" if they apply these
            // changes successfully)
            retVal.BeginUnorderedGroup();
            retVal.AddChanges(changes);
            // If last change batch, mark accordingly
            // (We always enumerate full batches, so if our batch is less than the batch size we
            // must be at the last batch. The second condition is spurious.)
            bool isLastBatch = false;

            if ((changes.Count < batchSize) || (changes.Count == 0))
            {
                retVal.SetLastBatch();
                isLastBatch = true;
            }

            retVal.EndUnorderedGroup(Replica.CurrentKnowledge, isLastBatch);

            return(retVal);
        }
Ejemplo n.º 2
0
        public ChangeBatch GetChangeBatch(uint batchSize, SyncKnowledge destinationKnowledge, out ForgottenKnowledge forgottenKnowledge, out object changeDataRetriever)
        {
            // Increment the tick count
            GetNextTickCount();

            // Get local changes
            List <ItemChange> changes = DetectChanges(destinationKnowledge, batchSize);

            // Update the knowledge with an updated local tick count
            SyncKnowledge.SetLocalTickCount(tickCount);

            // Construct the ChangeBatch and return it
            ChangeBatch changeBatch = new ChangeBatch(IdFormats, destinationKnowledge, ForgottenKnowledge);

            changeBatch.BeginUnorderedGroup();
            changeBatch.AddChanges(changes);
            if (changes.Count < batchSize || changes.Count == 0)
            {
                changeBatch.SetLastBatch();
            }
            changeBatch.EndUnorderedGroup(SyncKnowledge, changeBatch.IsLastBatch);

            // Return the forgotten knowledge
            forgottenKnowledge = ForgottenKnowledge;

            changeDataRetriever = this;

            return(changeBatch);
        }
Ejemplo n.º 3
0
        public ChangeBatch GetChanges(ChangeBatch sourceChanges)
        {
            GetNextTickCount();
            myKnowledge.SetLocalTickCount(tickCount);

            List<ItemChange> changes = new List<ItemChange>();

            foreach (ItemChange ic in sourceChanges)
            {
                ItemMetadata item;
                ItemChange change;

                if (metadataStore.TryGetItem(ic.ItemId, out item))
                {
                    System.Diagnostics.Debug.WriteLine("Remote item has   local counterpart::" + item.Uri);
                    change = new ItemChange(IdFormats, ReplicaId, item.ItemId,
                        (item.IsTombstone ? ChangeKind.Deleted : ChangeKind.Update),
                        item.CreationVersion, item.ChangeVersion);

                }
                else
                {
                    if (item == null)
                        System.Diagnostics.Debug.WriteLine("Remote item has no local counterpart: item.uri is null");
                    else
                        System.Diagnostics.Debug.WriteLine("Remote item has no local counterpart:" + item.Uri);

                    change = new ItemChange(IdFormats, replicaId, ic.ItemId, ChangeKind.UnknownItem,
                        SyncVersion.UnknownVersion, SyncVersion.UnknownVersion);

                }
                changes.Add(change);
            }

            ChangeBatch changeBatchBuilder = new ChangeBatch(IdFormats, myKnowledge , myForgottenKnowledge);

            changeBatchBuilder.BeginUnorderedGroup();

            changeBatchBuilder.AddChanges(changes);

            changeBatchBuilder.EndUnorderedGroup(myKnowledge, true);

            return changeBatchBuilder;
        }
Ejemplo n.º 4
0
        public ChangeBatch GetChangeBatch(string path, uint batchSize, SyncKnowledge destinationKnowledge, out object changeDataRetriever)
        {
            folderPath = path;
            GetNextTickCount();

            List<ItemChange> changes = DetectChanges(destinationKnowledge, batchSize);

            myKnowledge.SetLocalTickCount(tickCount);

            ChangeBatch changeBatchBuilder = new ChangeBatch(IdFormats,destinationKnowledge,  myForgottenKnowledge);

            changeBatchBuilder.BeginUnorderedGroup();

            changeBatchBuilder.AddChanges(changes);

            changeBatchBuilder.EndUnorderedGroup(myKnowledge, true);

            if ((changes.Count < batchSize) || (changes.Count == 0))
            {
                changeBatchBuilder.SetLastBatch();
            }

            changeDataRetriever = this;

            return changeBatchBuilder;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Возвращает пакет изменений, содержащий метаданные элементов, которые отсутствовали в указанном наборе знаний от поставщика назначения
        /// </summary>
        /// <param name="batchSize">Size of the batch.</param>
        /// <param name="destinationKnowledge">The destination knowledge.</param>
        /// <returns></returns>
        public override ChangeBatch GetChangeBatch(uint batchSize, SyncKnowledge destinationKnowledge)
        {
            ChangeBatch retVal = null;
            ulong tickCount = GetNextTickCount();

            List<ItemChange> changes = DetectChanges(destinationKnowledge, batchSize);

            retVal = new ChangeBatch(IdFormats, destinationKnowledge, Replica.ForgottenKnowledge);

            // Add the changes to the ChangeBatch with our made with knowledge
            // (Made width knowledge is the knowledge the other side will "learn" if they apply these
            // changes successfully)
            retVal.BeginUnorderedGroup();
            retVal.AddChanges(changes);
            // If last change batch, mark accordingly
            // (We always enumerate full batches, so if our batch is less than the batch size we
            // must be at the last batch. The second condition is spurious.)
            bool isLastBatch = false;
            if ((changes.Count < batchSize) || (changes.Count == 0))
            {
                retVal.SetLastBatch();
                isLastBatch = true;
            }

            retVal.EndUnorderedGroup(Replica.CurrentKnowledge, isLastBatch);

            return retVal;
        }