Example #1
0
        private void GatherState(bool live, long messageSequence, IHydratable hydratable)
        {
            if (live)
            {
                this.AddMessages(hydratable);
            }
            else if (hydratable.PendingMessages.Count > 0)
            {
                Log.WarnFormat("Hydratable at '{0}' has {1} pending messages during replay, but shouldn't.", hydratable.Key, hydratable.PendingMessages.Count);
                hydratable.PendingMessages.TryClear();
            }

            if (hydratable.IsPublicSnapshot && (live || hydratable.IsComplete))
            {
                this.TakePublicSnapshot(hydratable, messageSequence);
            }

            if (!hydratable.IsComplete)
            {
                return;
            }

            this.repository.Delete(hydratable);

            if (live)
            {
                this.AddMessages(this.watcher.Abort(hydratable));
            }
        }
Example #2
0
        public void Delete(IHydratable hydratable)
        {
            if (!this.live)
            {
                this.accessed.Remove(hydratable);
            }

            this.graveyard.Bury(hydratable.Key);
            this.catalog.Remove(hydratable.Key);
        }
Example #3
0
        private void AddMessages(IHydratable hydratable)
        {
            var key      = hydratable.Key;
            var messages = hydratable.PendingMessages;

            foreach (var message in messages)
            {
                this.gathered.Add(this.watcher.Filter(key, message));
            }

            messages.TryClear();
        }
Example #4
0
        private void Touch(IHydratable hydratable, long sequence)
        {
            if (this.live || !hydratable.IsPublicSnapshot)
            {
                return;
            }

            // the incoming sequence hasn't yet affected the results, but any callers
            // to that access collection will be invoking it *after* the message has
            // taken effect
            this.accessed[hydratable] = sequence;
        }
Example #5
0
        private void TakePublicSnapshot(IHydratable hydratable, long messageSequence)
        {
            var memento = hydratable.Memento;
            var cloner  = memento as ICloneable;

            memento = (cloner == null ? memento : cloner.Clone()) ?? memento;

            var next    = this.ring.Next();
            var claimed = this.ring[next];

            claimed.AsPublicSnapshot(hydratable.Key, memento, hydratable.MementoType, messageSequence);
            this.ring.Publish(next);
        }
Example #6
0
        private static object CreateObject(Type objType, IDataReader dr)
        {
            object objectValue = RuntimeHelpers.GetObjectValue(Activator.CreateInstance(objType));

            if (objectValue is IHydratable)
            {
                IHydratable hydratable = objectValue as IHydratable;
                if (hydratable != null)
                {
                    hydratable.Fill(dr);
                }
            }
            else
            {
                CBO.HydrateObject(RuntimeHelpers.GetObjectValue(objectValue), dr);
            }
            return(objectValue);
        }
Example #7
0
        private static T CreateObject <T>(IDataReader dr)
        {
            T instance = Activator.CreateInstance <T>();

            if ((object)instance is IHydratable)
            {
                IHydratable hydratable = (object)instance as IHydratable;
                if (hydratable != null)
                {
                    hydratable.Fill(dr);
                }
            }
            else
            {
                CBO.HydrateObject((object)instance, dr);
            }
            return(instance);
        }
Example #8
0
 public IHydratable Abort(IHydratable hydratable)
 {
     this.aggregate.AbortTimeouts(hydratable.Key);
     return(this);
 }
 public IHydratable Abort(IHydratable hydratable)
 {
     return(null);
 }