Example #1
0
        public void Process(DeletionRequestReceived deletionRequest, EffectTracker effects)
        {
            int numberInstancesDeleted = 0;

            if (this.OrchestrationState != null &&
                (!deletionRequest.CreatedTime.HasValue || deletionRequest.CreatedTime.Value == this.OrchestrationState.CreatedTime))
            {
                this.OrchestrationState = null;
                numberInstancesDeleted++;

                // we also delete this instance's history, and pending operations on it
                effects.Add(TrackedObjectKey.History(this.InstanceId));
                effects.Add(TrackedObjectKey.Sessions);
            }

            if (!effects.IsReplaying)
            {
                this.Partition.Send(new DeletionResponseReceived()
                {
                    ClientId  = deletionRequest.ClientId,
                    RequestId = deletionRequest.RequestId,
                    NumberInstancesDeleted = numberInstancesDeleted,
                });
            }
        }
        TrackedObject GetOrAdd(TrackedObjectKey key)
        {
            var result = this.trackedObjects.GetOrAdd(key, TrackedObjectKey.Factory);

            result.Partition = this.partition;
            return(result);
        }
Example #3
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));
            }
        }
Example #4
0
        public override void DetermineEffects(EffectTracker effects)
        {
            // the last-added effects are processed first
            // so they can set the Purged list to contain only the instance ids that are actually purged

            effects.Add(TrackedObjectKey.Queries);
            effects.Add(TrackedObjectKey.Sessions);

            this.Purged = new List <string>();
            foreach (string instanceId in this.InstanceIds)
            {
                effects.Add(TrackedObjectKey.Instance(instanceId));
            }
        }
Example #5
0
        public void Deliver(TrackedObjectKey key, TrackedObject trackedObject, out bool isReady)
        {
            if (!this.Prefetch.HasValue)
            {
                this.prefetchLoaded = true;
                this.targetLoaded   = true;
                this.target         = trackedObject;
            }
            else if (key.Equals(this.Prefetch.Value))
            {
                this.prefetchLoaded = true;
            }
            else
            {
                this.targetLoaded = true;
                this.target       = trackedObject;
            }

            isReady = (this.prefetchLoaded && this.targetLoaded);
        }
        public static int Compare(ref TrackedObjectKey key1, ref TrackedObjectKey key2)
        {
            int result = key1.ObjectType.CompareTo(key2.ObjectType);

            return(result == 0 ? key1.InstanceId.CompareTo(key2.InstanceId) : result);
        }
 public static TrackedObject Factory(TrackedObjectKey key) => key.ObjectType switch
 {
 public ValueTask ApplyToStore(TrackedObjectKey key, EffectTracker tracker)
 {
     tracker.ProcessEffectOn(this.GetOrAdd(key));
     return(default);