예제 #1
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="message">TBD</param>
        /// <returns>TBD</returns>
        protected override bool ReceiveRecover(object message)
        {
            SnapshotOffer offer;

            if (message is EntityStarted)
            {
                var started = (EntityStarted)message;
                State = new ShardState(State.Entries.Add(started.EntityId));
            }
            else if (message is EntityStopped)
            {
                var stopped = (EntityStopped)message;
                State = new ShardState(State.Entries.Remove(stopped.EntityId));
            }
            else if ((offer = message as SnapshotOffer) != null && offer.Snapshot is ShardState)
            {
                State = (ShardState)offer.Snapshot;
            }
            else if (message is RecoveryCompleted)
            {
                RestartRememberedEntities();
                base.Initialized();
                Log.Debug("PersistentShard recovery completed shard [{0}] with [{1}] entities", ShardId, State.Entries.Count);
            }
            else
            {
                return(false);
            }
            return(true);
        }
예제 #2
0
        protected override bool ReceiveRecover(object message)
        {
            SnapshotOffer offer;

            if (message is EntityStarted)
            {
                var started = (EntityStarted)message;
                State = new ShardState(State.Entries.Add(started.EntityId));
            }
            else if (message is EntityStopped)
            {
                var stopped = (EntityStopped)message;
                State = new ShardState(State.Entries.Remove(stopped.EntityId));
            }
            else if ((offer = message as SnapshotOffer) != null && offer.Snapshot is ShardState)
            {
                State = (ShardState)offer.Snapshot;
            }
            else if (message is RecoveryCompleted)
            {
                foreach (var entry in State.Entries)
                {
                    GetEntity(entry);
                }

                base.Initialized();
                Log.Debug("Shard recovery completed [{0}]", ShardId);
            }
            else
            {
                return(false);
            }
            return(true);
        }
예제 #3
0
파일: Shard.cs 프로젝트: icewwn/akka.net
 private void HandleStartEntityAck(ShardRegion.StartEntityAck ack)
 {
     if (ack.ShardId != ShardId && State.Entries.Contains(ack.EntityId))
     {
         Log.Debug("Entity [{0}] previously owned by shard [{1}] started in shard [{2}]", ack.EntityId, ShardId, ack.ShardId);
         ProcessChange(new EntityStopped(ack.EntityId), _ =>
         {
             State          = new ShardState(State.Entries.Remove(ack.EntityId));
             MessageBuffers = MessageBuffers.Remove(ack.EntityId);
         });
     }
 }
예제 #4
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="evt">TBD</param>
        protected void PassivateCompleted(EntityStopped evt)
        {
            var id = evt.EntityId;

            Log.Debug("Entity stopped [{0}]", id);

            var entity = RefById[id];

            IdByRef = IdByRef.Remove(entity);
            RefById = RefById.Remove(id);

            State          = new ShardState(State.Entries.Remove(id));
            MessageBuffers = MessageBuffers.Remove(id);
        }
예제 #5
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="id">TBD</param>
        /// <returns>TBD</returns>
        protected IActorRef GetEntity(string id)
        {
            var name  = Uri.EscapeDataString(id);
            var child = Context.Child(name);

            if (Equals(child, ActorRefs.Nobody))
            {
                Log.Debug("Starting entity [{0}] in shard [{1}]", id, ShardId);

                child   = Context.Watch(Context.ActorOf(EntityProps, name));
                IdByRef = IdByRef.SetItem(child, id);
                RefById = RefById.SetItem(id, child);
                State   = new ShardState(State.Entries.Add(id));
            }

            return(child);
        }
예제 #6
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="message">TBD</param>
        /// <returns>TBD</returns>
        public bool ReceiveRecover(object message)
        {
            switch (message)
            {
            case EntityStarted started:
                State = new ShardState(State.Entries.Add(started.EntityId));
                return(true);

            case EntityStopped stopped:
                State = new ShardState(State.Entries.Remove(stopped.EntityId));
                return(true);

            case SnapshotOffer offer when offer.Snapshot is ShardState:
                State = (ShardState)offer.Snapshot;
                return(true);

            case RecoveryCompleted _:
                RestartRememberedEntities();
                base.Initialized();
                Log.Debug("PersistentShard recovery completed shard [{0}] with [{1}] entities", ShardId, State.Entries.Count);
                return(true);
            }
            return(false);
        }
예제 #7
0
파일: Shard.cs 프로젝트: icewwn/akka.net
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="evt">TBD</param>
 protected void PassivateCompleted(EntityStopped evt)
 {
     Log.Debug("Entity stopped after passivation [{0}]", evt.EntityId);
     State          = new ShardState(State.Entries.Remove(evt.EntityId));
     MessageBuffers = MessageBuffers.Remove(evt.EntityId);
 }