コード例 #1
0
ファイル: Shard.cs プロジェクト: icewwn/akka.net
        private void HandOff(IActorRef replyTo)
        {
            if (HandOffStopper != null)
            {
                Log.Warning("HandOff shard [{0}] received during existing handOff", ShardId);
            }
            else
            {
                Log.Debug("HandOff shard [{0}]", ShardId);

                if (State.Entries.Count != 0)
                {
                    HandOffStopper = _context.Watch(_context.ActorOf(
                                                        ShardRegion.HandOffStopper.Props(ShardId, replyTo, IdByRef.Keys, HandOffStopMessage)));

                    //During hand off we only care about watching for termination of the hand off stopper
                    _context.Become(message =>
                    {
                        var terminated = message as Terminated;
                        if (terminated != null)
                        {
                            HandleTerminated(terminated.ActorRef);
                            return(true);
                        }
                        return(false);
                    });
                }
                else
                {
                    replyTo.Tell(new PersistentShardCoordinator.ShardStopped(ShardId));
                    _context.Stop(_context.Self);
                }
            }
        }