Пример #1
0
 /// <summary>
 /// When a cluster node is added this class takes over the
 /// responsibility for watchees on that node already handled
 /// by base RemoteWatcher.
 /// </summary>
 private void TakeOverResponsibility(Address address)
 {
     if (WatchingNodes.Contains(address))
     {
         Log.Debug("Cluster is taking over responsibility of node: {0}", address);
         UnwatchNode(address);
     }
 }
Пример #2
0
 protected override void OnReceive(object message)
 {
     if (message is HeartbeatTick)
     {
         SendHeartbeat();
     }
     else if (message is Heartbeat)
     {
         ReceiveHeartbeat();
     }
     else if (message is HeartbeatRsp)
     {
         ReceiveHeartbeatRsp(((HeartbeatRsp)message).AddressUid);
     }
     else if (message is ReapUnreachableTick)
     {
         ReapUnreachable();
     }
     else if (message is ExpectedFirstHeartbeat)
     {
         TriggerFirstHeartbeat(((ExpectedFirstHeartbeat)message).From);
     }
     else if (message is WatchRemote)
     {
         var watchRemote = (WatchRemote)message;
         AddWatching(watchRemote.Watchee, watchRemote.Watcher);
     }
     else if (message is UnwatchRemote)
     {
         var unwatchRemote = (UnwatchRemote)message;
         RemoveWatch(unwatchRemote.Watchee, unwatchRemote.Watcher);
     }
     else if (message is Terminated)
     {
         var t = (Terminated)message;
         ProcessTerminated(t.ActorRef.AsInstanceOf <IInternalActorRef>(), t.ExistenceConfirmed, t.AddressTerminated);
     }
     // test purpose
     else if (message is Stats)
     {
         var watchSet = ImmutableHashSet.Create(Watching.SelectMany(pair =>
         {
             var list = new List <Tuple <IActorRef, IActorRef> >(pair.Value.Count);
             var wee  = pair.Key;
             list.AddRange(pair.Value.Select(wer => Tuple.Create <IActorRef, IActorRef>(wee, wer)));
             return(list);
         }).ToArray());
         Sender.Tell(new Stats(watchSet.Count(), WatchingNodes.Count, watchSet,
                               ImmutableHashSet.Create(WatchingNodes.ToArray())));
     }
     else
     {
         Unhandled(message);
     }
 }