Ejemplo n.º 1
0
        public void Process(PurgeBatchIssued purgeBatchIssued, EffectTracker effects)
        {
            var purgeRequest = (PurgeRequestReceived)this.PendingQueries[purgeBatchIssued.QueryEventId];

            purgeRequest.NumberInstancesPurged += purgeBatchIssued.Purged.Count;

            if (!effects.IsReplaying)
            {
                // lets the query that is currently in progress know that this batch is done
                purgeBatchIssued.WhenProcessed.TrySetResult(null);
            }
        }
Ejemplo n.º 2
0
        public void Process(PurgeBatchIssued purgeBatchIssued, EffectTracker effects)
        {
            OrchestrationState state = this.OrchestrationState;

            if (this.OrchestrationState != null &&
                purgeBatchIssued.InstanceQuery.Matches(this.OrchestrationState))
            {
                this.OrchestrationState = null;
                purgeBatchIssued.Purged.Add(this.InstanceId);
                effects.Add(TrackedObjectKey.History(this.InstanceId));
            }
        }
Ejemplo n.º 3
0
        public async override Task OnQueryCompleteAsync(IAsyncEnumerable <OrchestrationState> instances, Partition partition)
        {
            int batchCount = 0;

            PurgeBatchIssued makeNewBatchObject()
            => new PurgeBatchIssued()
            {
                PartitionId   = partition.PartitionId,
                QueryEventId  = this.EventIdString,
                BatchNumber   = batchCount++,
                InstanceIds   = new List <string>(),
                WhenProcessed = new TaskCompletionSource <object>(TaskCreationOptions.RunContinuationsAsynchronously),
                InstanceQuery = this.InstanceQuery,
            };

            PurgeBatchIssued batch = makeNewBatchObject();

            async Task ExecuteBatch()
            {
                await partition.State.Prefetch(batch.KeysToPrefetch);

                partition.SubmitInternalEvent(batch);
                await batch.WhenProcessed.Task;
            }

            await foreach (var orchestrationState in instances)
            {
                batch.InstanceIds.Add(orchestrationState.OrchestrationInstance.InstanceId);

                if (batch.InstanceIds.Count == MaxBatchSize)
                {
                    await ExecuteBatch();

                    batch = makeNewBatchObject();
                }
            }

            if (batch.InstanceIds.Count > 0)
            {
                await ExecuteBatch();
            }

            partition.Send(new PurgeResponseReceived()
            {
                ClientId              = this.ClientId,
                RequestId             = this.RequestId,
                NumberInstancesPurged = this.NumberInstancesPurged,
            });
        }
 public void Process(PurgeBatchIssued purgeBatchIssued, EffectTracker effects)
 {
     this.DeleteHistory();
 }