akka.contrib.pattern
Class ClusterReceptionist

java.lang.Object
  extended by akka.contrib.pattern.ClusterReceptionist
All Implemented Interfaces:
Actor, ActorLogging

public class ClusterReceptionist
extends java.lang.Object
implements Actor, ActorLogging

ClusterClient connects to this actor to retrieve. The ClusterReceptionist is supposed to be started on all nodes, or all nodes with specified role, in the cluster. The receptionist can be started with the ClusterReceptionistExtension or as an ordinary actor (use the factory method props(akka.actor.ActorRef, scala.Option, int, scala.concurrent.duration.FiniteDuration)).

The receptionist forwards messages from the client to the associated DistributedPubSubMediator, i.e. the client can send messages to any actor in the cluster that is registered in the DistributedPubSubMediator. Messages from the client are wrapped in DistributedPubSubMediator.Send, DistributedPubSubMediator.SendToAll or DistributedPubSubMediator.Publish with the semantics described in DistributedPubSubMediator.

Response messages from the destination actor are tunneled via the receptionist to avoid inbound connections from other cluster nodes to the client, i.e. the sender, as seen by the destination actor, is not the client itself. The sender of the response messages, as seen by the client, is preserved as the original sender, so the client can choose to send subsequent messages directly to the actor in the cluster.


Nested Class Summary
static class ClusterReceptionist.Internal$
          INTERNAL API
 
Nested classes/interfaces inherited from interface akka.actor.Actor
Actor.emptyBehavior$
 
Constructor Summary
ClusterReceptionist(ActorRef pubSubMediator, scala.Option<java.lang.String> role, int numberOfContacts, scala.concurrent.duration.FiniteDuration responseTunnelReceiveTimeout)
           
 
Method Summary
 Cluster cluster()
           
 ConsistentHash<Address> consistentHash()
           
 boolean matchingRole(Member m)
           
 scala.collection.immutable.SortedSet<Address> nodes()
           
 void postStop()
          User overridable callback.
 void preStart()
          User overridable callback.
static Props props(ActorRef pubSubMediator, scala.Option<java.lang.String> role, int numberOfContacts, scala.concurrent.duration.FiniteDuration responseTunnelReceiveTimeout)
          Scala API: Factory method for ClusterReceptionist Props.
static Props props(ActorRef pubSubMediator, java.lang.String role)
          Java API: Factory method for ClusterReceptionist Props with default values.
static Props props(ActorRef pubSubMediator, java.lang.String role, int numberOfContacts, scala.concurrent.duration.FiniteDuration responseTunnelReceiveTimeout)
          Java API: Factory method for ClusterReceptionist Props.
 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.
 ActorRef responseTunnel(ActorRef client)
           
 int virtualNodesFactor()
           
 
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, self, sender, supervisorStrategy, unhandled
 
Methods inherited from interface akka.actor.ActorLogging
_log, log
 

Constructor Detail

ClusterReceptionist

public ClusterReceptionist(ActorRef pubSubMediator,
                           scala.Option<java.lang.String> role,
                           int numberOfContacts,
                           scala.concurrent.duration.FiniteDuration responseTunnelReceiveTimeout)
Method Detail

props

public static Props props(ActorRef pubSubMediator,
                          scala.Option<java.lang.String> role,
                          int numberOfContacts,
                          scala.concurrent.duration.FiniteDuration responseTunnelReceiveTimeout)
Scala API: Factory method for ClusterReceptionist Props.

Parameters:
pubSubMediator - (undocumented)
role - (undocumented)
numberOfContacts - (undocumented)
responseTunnelReceiveTimeout - (undocumented)
Returns:
(undocumented)

props

public static Props props(ActorRef pubSubMediator,
                          java.lang.String role,
                          int numberOfContacts,
                          scala.concurrent.duration.FiniteDuration responseTunnelReceiveTimeout)
Java API: Factory method for ClusterReceptionist Props.

Parameters:
pubSubMediator - (undocumented)
role - (undocumented)
numberOfContacts - (undocumented)
responseTunnelReceiveTimeout - (undocumented)
Returns:
(undocumented)

props

public static Props props(ActorRef pubSubMediator,
                          java.lang.String role)
Java API: Factory method for ClusterReceptionist Props with default values.

Parameters:
pubSubMediator - (undocumented)
role - (undocumented)
Returns:
(undocumented)

cluster

public Cluster cluster()

nodes

public scala.collection.immutable.SortedSet<Address> nodes()

virtualNodesFactor

public int virtualNodesFactor()

consistentHash

public ConsistentHash<Address> consistentHash()

preStart

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

Is called when an Actor is started. Actors are automatically started asynchronously when created. Empty default implementation.

Specified by:
preStart in interface Actor

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

matchingRole

public boolean matchingRole(Member m)

responseTunnel

public ActorRef responseTunnel(ActorRef client)

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)