public final class ClusterSingletonProxy extends java.lang.Object implements Actor, ActorLogging
ClusterSingletonProxy works together with the ClusterSingletonManager to provide a
distributed proxy to the singleton actor.
The proxy can be started on every node where the singleton needs to be reached and used as if it were the singleton itself. It will then act as a router to the currently running singleton instance. If the singleton is not currently available, e.g., during hand off or startup, the proxy will buffer the messages sent to the singleton and then deliver them when the singleton is finally available. The size of the buffer is configurable and it can be disabled by using a buffer size of 0. When the buffer is full old messages will be dropped when new messages are sent via the proxy.
The proxy works by keeping track of the oldest cluster member. When a new oldest member is identified, e.g. because
the older one left the cluster, or at startup, the proxy will try to identify the singleton on the oldest member by
periodically sending an Identify message until the singleton responds with its
ActorIdentity.
Note that this is a best effort implementation: messages can always be lost due to the distributed nature of the actors involved.
Actor.emptyBehavior$, Actor.ignoringBehavior$| Constructor and Description |
|---|
ClusterSingletonProxy(java.lang.String singletonManagerPath,
ClusterSingletonProxySettings settings) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(Member m)
Adds new member if it has the right role.
|
scala.math.Ordering<Member> |
ageOrdering() |
protected abstract static void |
akka$actor$Actor$_setter_$context_$eq(ActorContext x$1) |
protected abstract static void |
akka$actor$Actor$_setter_$self_$eq(ActorRef x$1) |
static void |
akka$actor$ActorLogging$$_log_$eq(LoggingAdapter x$1) |
static LoggingAdapter |
akka$actor$ActorLogging$$_log() |
protected static void |
aroundPostRestart(java.lang.Throwable reason) |
protected static void |
aroundPostStop() |
protected static void |
aroundPreRestart(java.lang.Throwable reason,
scala.Option<java.lang.Object> message) |
protected static void |
aroundPreStart() |
protected static void |
aroundReceive(scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive,
java.lang.Object msg) |
MessageBuffer |
buffer() |
void |
buffer(java.lang.Object msg) |
void |
cancelTimer() |
Cluster |
cluster() |
ActorContext |
context()
Stores the context for this actor, including self, and sender.
|
java.lang.String |
createIdentifyId(int i) |
void |
handleInitial(ClusterEvent.CurrentClusterState state) |
int |
identifyCounter() |
java.lang.String |
identifyId() |
void |
identifySingleton()
Discard old singleton ActorRef and send a periodic message to self to identify the singleton.
|
scala.Option<Cancellable> |
identifyTimer() |
static LoggingAdapter |
log() |
boolean |
matchingRole(Member member) |
scala.collection.immutable.SortedSet<Member> |
membersByAge() |
static void |
postRestart(java.lang.Throwable reason) |
void |
postStop()
User overridable callback.
|
static void |
preRestart(java.lang.Throwable reason,
scala.Option<java.lang.Object> message) |
void |
preStart()
User overridable callback.
|
static Props |
props(java.lang.String singletonManagerPath,
ClusterSingletonProxySettings settings)
Scala API: Factory method for
ClusterSingletonProxy 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.
|
void |
remove(Member m)
Removes a member.
|
ActorRef |
self()
The 'self' field holds the ActorRef for this actor.
|
void |
sendBuffered() |
static ActorRef |
sender() |
scala.Option<ActorRef> |
singleton() |
java.lang.String[] |
singletonPath() |
static SupervisorStrategy |
supervisorStrategy() |
void |
trackChange(scala.Function0<scala.runtime.BoxedUnit> block) |
static void |
unhandled(java.lang.Object message) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaroundPostRestart, aroundPostStop, aroundPreRestart, aroundPreStart, aroundReceive, postRestart, preRestart, sender, supervisorStrategy, unhandledlogpublic ClusterSingletonProxy(java.lang.String singletonManagerPath,
ClusterSingletonProxySettings settings)
public static Props props(java.lang.String singletonManagerPath, ClusterSingletonProxySettings settings)
ClusterSingletonProxy Props.
singletonManagerPath - The logical path of the singleton manager, e.g. /user/singletonManager,
which ends with the name you defined in actorOf when creating the ClusterSingletonManager.settings - see ClusterSingletonProxySettingspublic static final ActorRef sender()
protected static void aroundReceive(scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive,
java.lang.Object msg)
protected static void aroundPreStart()
protected static void aroundPostStop()
protected static void aroundPreRestart(java.lang.Throwable reason,
scala.Option<java.lang.Object> message)
protected static void aroundPostRestart(java.lang.Throwable reason)
public static SupervisorStrategy supervisorStrategy()
public static void preRestart(java.lang.Throwable reason,
scala.Option<java.lang.Object> message)
throws java.lang.Exception
java.lang.Exceptionpublic static void postRestart(java.lang.Throwable reason)
throws java.lang.Exception
java.lang.Exceptionpublic static void unhandled(java.lang.Object message)
protected abstract static void akka$actor$Actor$_setter_$context_$eq(ActorContext x$1)
protected abstract static void akka$actor$Actor$_setter_$self_$eq(ActorRef x$1)
public static LoggingAdapter akka$actor$ActorLogging$$_log()
public static void akka$actor$ActorLogging$$_log_$eq(LoggingAdapter x$1)
public static LoggingAdapter log()
public ActorContext context()
Actorforward.
WARNING: Only valid within the Actor itself, so do not close over it and publish it to other threads!
ActorContext is the Scala API. getContext returns a
UntypedActorContext, which is the Java API of the actor
context.
public final ActorRef self()
Actorself ! message
public java.lang.String[] singletonPath()
public int identifyCounter()
public java.lang.String identifyId()
public java.lang.String createIdentifyId(int i)
public scala.Option<Cancellable> identifyTimer()
public Cluster cluster()
public scala.Option<ActorRef> singleton()
public scala.math.Ordering<Member> ageOrdering()
public scala.collection.immutable.SortedSet<Member> membersByAge()
public MessageBuffer buffer()
public void preStart()
Actorpublic void postStop()
Actorpublic void cancelTimer()
public boolean matchingRole(Member member)
public void handleInitial(ClusterEvent.CurrentClusterState state)
public void identifySingleton()
public void trackChange(scala.Function0<scala.runtime.BoxedUnit> block)
public void add(Member m)
m - New cluster member.public void remove(Member m)
m - Cluster member to remove.public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive()
Actorpublic void buffer(java.lang.Object msg)
public void sendBuffered()