コード例 #1
0
 void DeleteHistory()
 {
     this.History     = null;
     this.Episode     = 0;
     this.ExecutionId = null;
     this.CachedOrchestrationWorkItem = null;
 }
コード例 #2
0
        public void EnqueueOrchestrationWorkItem(OrchestrationWorkItem item)
        {
            this.WorkItemTraceHelper.TraceWorkItemQueued(
                this.PartitionId,
                WorkItemTraceHelper.WorkItemType.Orchestration,
                item.MessageBatch.WorkItemId,
                item.InstanceId,
                item.Type.ToString(),
                WorkItemTraceHelper.FormatMessageIdList(item.MessageBatch.TracedMessages));

            this.OrchestrationWorkItemQueue.Add(item);
        }
コード例 #3
0
        public void Process(BatchProcessed evt, EffectTracker effects)
        {
            // can add events to the history, or replace it with a new history

            // update the stored history
            if (this.History == null || evt.State.OrchestrationInstance.ExecutionId != this.ExecutionId)
            {
                this.History     = new List <HistoryEvent>();
                this.Episode     = 0;
                this.ExecutionId = evt.State.OrchestrationInstance.ExecutionId;
            }

            this.Partition.Assert(!string.IsNullOrEmpty(this.InstanceId) || string.IsNullOrEmpty(this.ExecutionId));

            // add all the new events to the history, and update episode number
            if (evt.NewEvents != null)
            {
                for (int i = 0; i < evt.NewEvents.Count; i++)
                {
                    var historyEvent = evt.NewEvents[i];
                    if (historyEvent.EventType == EventType.OrchestratorStarted)
                    {
                        this.Episode++;
                    }
                    this.History.Add(evt.NewEvents[i]);
                }
            }

            if (!effects.IsReplaying)
            {
                this.Partition.EventTraceHelper.TraceInstanceUpdate(
                    evt.WorkItemId,
                    evt.State.OrchestrationInstance.InstanceId,
                    evt.State.OrchestrationInstance.ExecutionId,
                    this.History.Count,
                    evt.NewEvents, this.Episode);

                // if present, we keep the work item so we can reuse the execution cursor
                this.CachedOrchestrationWorkItem = evt.WorkItemForReuse;

                if (this.CachedOrchestrationWorkItem != null &&
                    this.CachedOrchestrationWorkItem.OrchestrationRuntimeState?.OrchestrationInstance?.ExecutionId != evt.State.OrchestrationInstance.ExecutionId)
                {
                    effects.Partition.EventTraceHelper.TraceEventProcessingWarning($"Dropping bad workitem cache instance={this.InstanceId} expected_executionid={evt.State.OrchestrationInstance.ExecutionId} actual_executionid={this.CachedOrchestrationWorkItem.OrchestrationRuntimeState?.OrchestrationInstance?.ExecutionId}");
                    this.CachedOrchestrationWorkItem = null;
                }
            }
        }