public class ClusterSingletonManager
extends java.lang.Object
implements akka.actor.Actor, akka.actor.FSM<akka.cluster.singleton.ClusterSingletonManager.State,akka.cluster.singleton.ClusterSingletonManager.Data>
The ClusterSingletonManager is supposed to be started on all nodes,
or all nodes with specified role, in the cluster with actorOf
.
The actual singleton is started on the oldest node by creating a child
actor from the supplied singletonProps
.
The singleton actor is always running on the oldest member with specified role.
The oldest member is determined by Member.isOlderThan(akka.cluster.Member)
.
This can change when removing members. A graceful hand over can normally
be performed when current oldest node is leaving the cluster. Be aware that
there is a short time period when there is no active singleton during the
hand-over process.
The cluster failure detector will notice when oldest node becomes unreachable due to things like JVM crash, hard shut down, or network failure. When the crashed node has been removed (via down) from the cluster then a new oldest node will take over and a new singleton actor is created. For these failure scenarios there will not be a graceful hand-over, but more than one active singletons is prevented by all reasonable means. Some corner cases are eventually resolved by configurable timeouts.
You access the singleton actor with ClusterSingletonProxy
.
Alternatively the singleton actor may broadcast its existence when it is started.
Use factory method props(akka.actor.Props, java.lang.Object, akka.cluster.singleton.ClusterSingletonManagerSettings)
to create the
Props
for the actor.
param: singletonProps Props
of the singleton actor instance.
param: terminationMessage When handing over to a new oldest node
this terminationMessage
is sent to the singleton actor to tell
it to finish its work, close resources, and stop.
The hand-over to the new oldest node is completed when the
singleton actor is terminated.
Note that PoisonPill
is a perfectly fine
terminationMessage
if you only need to stop the actor.
param: settings see ClusterSingletonManagerSettings
Modifier and Type | Class and Description |
---|---|
static interface |
ClusterSingletonManager.Data
INTERNAL API
public due to the
with FSM type parameters |
static class |
ClusterSingletonManager.Internal$
INTERNAL API
|
static interface |
ClusterSingletonManager.State
INTERNAL API
public due to the
with FSM type parameters |
akka.actor.FSM.$minus$greater$, akka.actor.FSM.CurrentState<S>, akka.actor.FSM.CurrentState$, akka.actor.FSM.Event<D>, akka.actor.FSM.Event$, akka.actor.FSM.Failure, akka.actor.FSM.Failure$, akka.actor.FSM.LogEntry<S,D>, akka.actor.FSM.LogEntry$, akka.actor.FSM.Normal$, akka.actor.FSM.NullFunction$, akka.actor.FSM.Reason, akka.actor.FSM.Shutdown$, akka.actor.FSM.SilentState<S,D>, akka.actor.FSM.State$, akka.actor.FSM.StateTimeout$, akka.actor.FSM.StopEvent<S,D>, akka.actor.FSM.StopEvent$, akka.actor.FSM.SubscribeTransitionCallBack, akka.actor.FSM.SubscribeTransitionCallBack$, akka.actor.FSM.TimeoutMarker, akka.actor.FSM.TimeoutMarker$, akka.actor.FSM.Timer, akka.actor.FSM.Timer$, akka.actor.FSM.TransformHelper, akka.actor.FSM.Transition<S>, akka.actor.FSM.Transition$, akka.actor.FSM.UnsubscribeTransitionCallBack, akka.actor.FSM.UnsubscribeTransitionCallBack$
Constructor and Description |
---|
ClusterSingletonManager(akka.actor.Props singletonProps,
java.lang.Object terminationMessage,
akka.cluster.singleton.ClusterSingletonManagerSettings settings) |
Modifier and Type | Method and Description |
---|---|
void |
addRemoved(akka.actor.Address address) |
void |
cleanupOverdueNotMemberAnyMore() |
akka.cluster.Cluster |
cluster() |
void |
getNextOldestChanged() |
akka.actor.FSM.State<akka.actor.FSM.State,akka.cluster.singleton.ClusterSingletonManager.Data> |
gotoHandingOver(akka.actor.ActorRef singleton,
boolean singletonTerminated,
scala.Option<akka.actor.ActorRef> handOverTo) |
akka.actor.FSM.State<akka.actor.FSM.State,akka.cluster.singleton.ClusterSingletonManager.Data> |
gotoOldest() |
akka.actor.FSM.State<akka.actor.FSM.State,akka.cluster.singleton.ClusterSingletonManager.Data> |
handOverDone(scala.Option<akka.actor.ActorRef> handOverTo) |
void |
logInfo(java.lang.String message) |
void |
logInfo(java.lang.String template,
java.lang.Object arg1) |
void |
logInfo(java.lang.String template,
java.lang.Object arg1,
java.lang.Object arg2) |
int |
maxHandOverRetries() |
int |
maxTakeOverRetries() |
akka.actor.ActorRef |
oldestChangedBuffer() |
boolean |
oldestChangedReceived() |
akka.actor.ActorSelection |
peer(akka.actor.Address at) |
void |
postStop() |
void |
preStart() |
static akka.actor.Props |
props(akka.actor.Props singletonProps,
java.lang.Object terminationMessage,
akka.cluster.singleton.ClusterSingletonManagerSettings settings)
Scala API: Factory method for
ClusterSingletonManager Props . |
scala.concurrent.duration.FiniteDuration |
removalMargin() |
scala.collection.immutable.Map<akka.actor.Address,scala.concurrent.duration.Deadline> |
removed() |
void |
scheduleDelayedMemberRemoved(akka.cluster.Member m) |
scala.Some<akka.actor.Address> |
selfAddressOption() |
boolean |
selfExited() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
$minus$greater, akka$actor$FSM$_setter_$$minus$greater_$eq, akka$actor$FSM$_setter_$akka$actor$FSM$$handleEventDefault_$eq, akka$actor$FSM$_setter_$akka$actor$FSM$$stateFunctions_$eq, akka$actor$FSM$_setter_$akka$actor$FSM$$stateTimeouts_$eq, akka$actor$FSM$_setter_$akka$actor$FSM$$timerGen_$eq, akka$actor$FSM$_setter_$akka$actor$FSM$$timers_$eq, akka$actor$FSM$_setter_$Event_$eq, akka$actor$FSM$_setter_$StateTimeout_$eq, akka$actor$FSM$_setter_$StopEvent_$eq, akka$actor$FSM$$currentState_$eq, akka$actor$FSM$$currentState, akka$actor$FSM$$generation_$eq, akka$actor$FSM$$generation, akka$actor$FSM$$handleEvent_$eq, akka$actor$FSM$$handleEvent, akka$actor$FSM$$handleEventDefault, akka$actor$FSM$$nextState_$eq, akka$actor$FSM$$nextState, akka$actor$FSM$$stateFunctions, akka$actor$FSM$$stateTimeouts, akka$actor$FSM$$terminateEvent_$eq, akka$actor$FSM$$terminateEvent, akka$actor$FSM$$timeoutFuture_$eq, akka$actor$FSM$$timeoutFuture, akka$actor$FSM$$timerGen, akka$actor$FSM$$timers, akka$actor$FSM$$transitionEvent_$eq, akka$actor$FSM$$transitionEvent, applyState, cancelTimer, debugEvent, Event, goto, initialize, isStateTimerActive, isTimerActive, logTermination, makeTransition, nextStateData, onTermination, onTransition, processEvent, receive, setStateTimeout, setTimer, setTimer$default$4, startWith, startWith$default$3, stateData, stateName, StateTimeout, stay, stop, stop, stop, StopEvent, total2pf, transform, when, when$default$2, whenUnhandled
akka$actor$Actor$_setter_$context_$eq, akka$actor$Actor$_setter_$self_$eq, aroundPostRestart, aroundPostStop, aroundPreRestart, aroundPreStart, aroundReceive, context, postRestart, preRestart, self, sender, supervisorStrategy, unhandled
public ClusterSingletonManager(akka.actor.Props singletonProps, java.lang.Object terminationMessage, akka.cluster.singleton.ClusterSingletonManagerSettings settings)
public static akka.actor.Props props(akka.actor.Props singletonProps, java.lang.Object terminationMessage, akka.cluster.singleton.ClusterSingletonManagerSettings settings)
ClusterSingletonManager
Props
.singletonProps
- (undocumented)terminationMessage
- (undocumented)settings
- (undocumented)public akka.cluster.Cluster cluster()
public scala.Some<akka.actor.Address> selfAddressOption()
public scala.concurrent.duration.FiniteDuration removalMargin()
public int maxHandOverRetries()
public int maxTakeOverRetries()
public akka.actor.ActorRef oldestChangedBuffer()
public boolean oldestChangedReceived()
public boolean selfExited()
public scala.collection.immutable.Map<akka.actor.Address,scala.concurrent.duration.Deadline> removed()
public void addRemoved(akka.actor.Address address)
public void cleanupOverdueNotMemberAnyMore()
public void logInfo(java.lang.String message)
public void logInfo(java.lang.String template, java.lang.Object arg1)
public void logInfo(java.lang.String template, java.lang.Object arg1, java.lang.Object arg2)
public void preStart()
preStart
in interface akka.actor.Actor
public void postStop()
postStop
in interface akka.actor.Actor
postStop
in interface akka.actor.FSM<akka.cluster.singleton.ClusterSingletonManager.State,akka.cluster.singleton.ClusterSingletonManager.Data>
public akka.actor.ActorSelection peer(akka.actor.Address at)
public void getNextOldestChanged()
public void scheduleDelayedMemberRemoved(akka.cluster.Member m)
public akka.actor.FSM.State<akka.actor.FSM.State,akka.cluster.singleton.ClusterSingletonManager.Data> gotoOldest()
public akka.actor.FSM.State<akka.actor.FSM.State,akka.cluster.singleton.ClusterSingletonManager.Data> gotoHandingOver(akka.actor.ActorRef singleton, boolean singletonTerminated, scala.Option<akka.actor.ActorRef> handOverTo)
public akka.actor.FSM.State<akka.actor.FSM.State,akka.cluster.singleton.ClusterSingletonManager.Data> handOverDone(scala.Option<akka.actor.ActorRef> handOverTo)