Пример #1
0
        void ReportInvalidBatch(DataBatch batch)
        {
            Console.WriteLine("Invalid batch {0} reported",
                              batch.Index);

            throw new NotImplementedException();
        }
Пример #2
0
        async Task StartBatchSynchronizationBuffer()
        {
            while (true)
            {
                DataBatch batch = await BatchSynchronizationBuffer
                                  .ReceiveAsync()
                                  .ConfigureAwait(false);

                if (batch.Index != BatchIndex)
                {
                    QueueDownloadBatch.Add(batch.Index, batch);
                    continue;
                }

                do
                {
                    TryInsertBatch(batch);

                    if (batch.IsCancellationBatch)
                    {
                        SignalSynchronizationCompleted.SetResult(null);
                        return;
                    }

                    BatchIndex += 1;

                    if (QueueDownloadBatch.TryGetValue(
                            BatchIndex,
                            out batch))
                    {
                        QueueDownloadBatch.Remove(BatchIndex);
                    }
                    else
                    {
                        break;
                    }
                } while (true);
            }
        }
Пример #3
0
        protected bool TryInsertBatch(DataBatch batch)
        {
            if (batch.IsCancellationBatch)
            {
                ArchiveContainers();
                return(true);
            }

            foreach (DataContainer container in
                     batch.DataContainers)
            {
                container.Index = ArchiveIndexStore;

                if (!TryInsertContainer(container))
                {
                    return(false);
                }

                Containers.Add(container);
                CountItems += container.CountItems;

                if (CountItems >= SizeBatchArchive)
                {
                    ArchiveContainers();

                    Containers = new List <DataContainer>();
                    CountItems = 0;

                    ArchiveImage(ArchiveIndexStore);

                    ArchiveIndexStore += 1;
                }
            }

            return(true);
        }