akka.remote
Class RemoteWatcher

java.lang.Object
  extended by akka.remote.RemoteWatcher
All Implemented Interfaces:
Actor, ActorLogging, RequiresMessageQueue<UnboundedMessageQueueSemantics>
Direct Known Subclasses:
ClusterRemoteWatcher

public class RemoteWatcher
extends java.lang.Object
implements Actor, ActorLogging, RequiresMessageQueue<UnboundedMessageQueueSemantics>

INTERNAL API

Remote nodes with actors that are watched are monitored by this actor to be able to detect network failures and JVM crashes. RemoteActorRefProvider intercepts Watch and Unwatch system messages and sends corresponding RemoteWatcher.WatchRemote and RemoteWatcher.UnwatchRemote to this actor.

For a new node to be watched this actor periodically sends RemoteWatcher.Heartbeat to the peer actor on the other node, which replies with RemoteWatcher.HeartbeatRsp message back. The failure detector on the watching side monitors these heartbeat messages. If arrival of hearbeat messages stops it will be detected and this actor will publish AddressTerminated to the AddressTerminatedTopic.

When all actors on a node have been unwatched it will stop sending heartbeat messages.

For bi-directional watch between two nodes the same thing will be established in both directions, but independent of each other.


Nested Class Summary
static class RemoteWatcher.ExpectedFirstHeartbeat
           
static class RemoteWatcher.ExpectedFirstHeartbeat$
           
static class RemoteWatcher.Heartbeat$
           
static class RemoteWatcher.HeartbeatRsp
           
static class RemoteWatcher.HeartbeatRsp$
           
static class RemoteWatcher.HeartbeatTick$
           
static class RemoteWatcher.ReapUnreachableTick$
           
static class RemoteWatcher.Rewatch
           
static class RemoteWatcher.RewatchRemote
           
static class RemoteWatcher.RewatchRemote$
           
static class RemoteWatcher.Stats
           
static class RemoteWatcher.Stats$
           
static class RemoteWatcher.UnwatchRemote
           
static class RemoteWatcher.UnwatchRemote$
           
static class RemoteWatcher.WatchRemote
           
static class RemoteWatcher.WatchRemote$
           
 
Nested classes/interfaces inherited from interface akka.actor.Actor
Actor.emptyBehavior$
 
Constructor Summary
RemoteWatcher(FailureDetectorRegistry<Address> failureDetector, scala.concurrent.duration.FiniteDuration heartbeatInterval, scala.concurrent.duration.FiniteDuration unreachableReaperInterval, scala.concurrent.duration.FiniteDuration heartbeatExpectedResponseAfter)
           
 
Method Summary
 scala.collection.immutable.Map<Address,java.lang.Object> addressUids()
           
 void addWatching(ActorRef watchee, ActorRef watcher)
           
 void checkLastUnwatchOfNode(Address watcheeAddress)
           
 Cancellable failureDetectorReaperTask()
           
 Cancellable heartbeatTask()
           
 void logActorForDeprecationWarning(ActorRef watchee)
           
 void postStop()
          User overridable callback.
static Props props(FailureDetectorRegistry<Address> failureDetector, scala.concurrent.duration.FiniteDuration heartbeatInterval, scala.concurrent.duration.FiniteDuration unreachableReaperInterval, scala.concurrent.duration.FiniteDuration heartbeatExpectedResponseAfter)
          Factory method for RemoteWatcher Props.
 void publishAddressTerminated(Address address)
           
 void quarantine(Address address, scala.Option<java.lang.Object> uid)
           
 void reapUnreachable()
           
 scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive()
          This defines the initial actor behavior, it must return a partial function with the actor logic.
 void receiveHeartbeat()
           
 void receiveHeartbeatRsp(int uid)
           
 RemoteActorRefProvider remoteProvider()
           
 void reWatch(Address address)
          To ensure that we receive heartbeat messages from the right actor system incarnation we send Watch again for the first HeartbeatRsp (containing the system UID) and if HeartbeatRsp contains a new system UID.
 void rewatchRemote(ActorRef watchee, ActorRef watcher)
           
 Scheduler scheduler()
           
 RemoteWatcher.HeartbeatRsp selfHeartbeatRspMsg()
           
 void sendHeartbeat()
           
 void terminated(ActorRef watchee, boolean existenceConfirmed, boolean addressTerminated)
           
 void triggerFirstHeartbeat(Address address)
           
 scala.collection.immutable.Set<Address> unreachable()
           
 void unwatchRemote(ActorRef watchee, ActorRef watcher)
           
 scala.collection.immutable.Set<scala.Tuple2<ActorRef,ActorRef>> watching()
           
 scala.collection.immutable.Set<Address> watchingNodes()
           
 void watchRemote(ActorRef watchee, ActorRef watcher)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface akka.actor.Actor
aroundPostRestart, aroundPostStop, aroundPreRestart, aroundPreStart, aroundReceive, context, postRestart, preRestart, preStart, self, sender, supervisorStrategy, unhandled
 
Methods inherited from interface akka.actor.ActorLogging
_log, log
 

Constructor Detail

RemoteWatcher

public RemoteWatcher(FailureDetectorRegistry<Address> failureDetector,
                     scala.concurrent.duration.FiniteDuration heartbeatInterval,
                     scala.concurrent.duration.FiniteDuration unreachableReaperInterval,
                     scala.concurrent.duration.FiniteDuration heartbeatExpectedResponseAfter)
Method Detail

props

public static Props props(FailureDetectorRegistry<Address> failureDetector,
                          scala.concurrent.duration.FiniteDuration heartbeatInterval,
                          scala.concurrent.duration.FiniteDuration unreachableReaperInterval,
                          scala.concurrent.duration.FiniteDuration heartbeatExpectedResponseAfter)
Factory method for RemoteWatcher Props.

Parameters:
failureDetector - (undocumented)
heartbeatInterval - (undocumented)
unreachableReaperInterval - (undocumented)
heartbeatExpectedResponseAfter - (undocumented)
Returns:
(undocumented)

scheduler

public Scheduler scheduler()

remoteProvider

public RemoteActorRefProvider remoteProvider()

selfHeartbeatRspMsg

public RemoteWatcher.HeartbeatRsp selfHeartbeatRspMsg()

watching

public scala.collection.immutable.Set<scala.Tuple2<ActorRef,ActorRef>> watching()

watchingNodes

public scala.collection.immutable.Set<Address> watchingNodes()

unreachable

public scala.collection.immutable.Set<Address> unreachable()

addressUids

public scala.collection.immutable.Map<Address,java.lang.Object> addressUids()

heartbeatTask

public Cancellable heartbeatTask()

failureDetectorReaperTask

public Cancellable failureDetectorReaperTask()

postStop

public void postStop()
Description copied from interface: Actor
User overridable callback.

Is called asynchronously after 'actor.stop()' is invoked. Empty default implementation.

Specified by:
postStop in interface Actor

receive

public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive()
Description copied from interface: Actor
This defines the initial actor behavior, it must return a partial function with the actor logic.

Specified by:
receive in interface Actor
Returns:
(undocumented)

receiveHeartbeat

public void receiveHeartbeat()

receiveHeartbeatRsp

public void receiveHeartbeatRsp(int uid)

reapUnreachable

public void reapUnreachable()

publishAddressTerminated

public void publishAddressTerminated(Address address)

quarantine

public void quarantine(Address address,
                       scala.Option<java.lang.Object> uid)

rewatchRemote

public void rewatchRemote(ActorRef watchee,
                          ActorRef watcher)

watchRemote

public void watchRemote(ActorRef watchee,
                        ActorRef watcher)

addWatching

public void addWatching(ActorRef watchee,
                        ActorRef watcher)

unwatchRemote

public void unwatchRemote(ActorRef watchee,
                          ActorRef watcher)

logActorForDeprecationWarning

public void logActorForDeprecationWarning(ActorRef watchee)

terminated

public void terminated(ActorRef watchee,
                       boolean existenceConfirmed,
                       boolean addressTerminated)

checkLastUnwatchOfNode

public void checkLastUnwatchOfNode(Address watcheeAddress)

sendHeartbeat

public void sendHeartbeat()

triggerFirstHeartbeat

public void triggerFirstHeartbeat(Address address)

reWatch

public void reWatch(Address address)
To ensure that we receive heartbeat messages from the right actor system incarnation we send Watch again for the first HeartbeatRsp (containing the system UID) and if HeartbeatRsp contains a new system UID. Terminated will be triggered if the watchee (including correct Actor UID) does not exist.

Parameters:
address - (undocumented)