public class ClusterSingletonManager extends java.lang.Object implements 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 |
FSM.$minus$greater$, FSM.CurrentState<S>, FSM.CurrentState$, FSM.Event<D>, FSM.Event$, FSM.Failure, FSM.Failure$, FSM.LogEntry<S,D>, FSM.LogEntry$, FSM.Normal$, FSM.NullFunction$, FSM.Reason, FSM.Shutdown$, FSM.SilentState<S,D>, FSM.State$, FSM.StateTimeout$, FSM.StopEvent<S,D>, FSM.StopEvent$, FSM.SubscribeTransitionCallBack, FSM.SubscribeTransitionCallBack$, FSM.TimeoutMarker, FSM.TimeoutMarker$, FSM.Timer, FSM.Timer$, FSM.TransformHelper, FSM.Transition<S>, FSM.Transition$, FSM.UnsubscribeTransitionCallBack, FSM.UnsubscribeTransitionCallBack$
Actor.emptyBehavior$, Actor.ignoringBehavior$
Constructor and Description |
---|
ClusterSingletonManager(Props singletonProps,
java.lang.Object terminationMessage,
ClusterSingletonManagerSettings settings) |
Modifier and Type | Method and Description |
---|---|
static FSM.$minus$greater$ |
$minus$greater() |
void |
addRemoved(UniqueAddress node) |
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 abstract static void |
akka$actor$FSM$_setter_$$minus$greater_$eq(FSM.$minus$greater$ x$1) |
protected abstract static void |
akka$actor$FSM$_setter_$akka$actor$FSM$$handleEventDefault_$eq(scala.PartialFunction<FSM.Event<D>,FSM.State<S,D>> x$1) |
protected abstract static void |
akka$actor$FSM$_setter_$akka$actor$FSM$$stateFunctions_$eq(scala.collection.mutable.Map<S,scala.PartialFunction<FSM.Event<D>,FSM.State<S,D>>> x$1) |
protected abstract static void |
akka$actor$FSM$_setter_$akka$actor$FSM$$stateTimeouts_$eq(scala.collection.mutable.Map<S,scala.Option<scala.concurrent.duration.FiniteDuration>> x$1) |
protected abstract static void |
akka$actor$FSM$_setter_$akka$actor$FSM$$timerGen_$eq(scala.collection.Iterator<java.lang.Object> x$1) |
protected abstract static void |
akka$actor$FSM$_setter_$akka$actor$FSM$$timers_$eq(scala.collection.mutable.Map<java.lang.String,FSM.Timer> x$1) |
protected abstract static void |
akka$actor$FSM$_setter_$Event_$eq(FSM.Event$ x$1) |
protected abstract static void |
akka$actor$FSM$_setter_$StateTimeout_$eq(FSM.StateTimeout$ x$1) |
protected abstract static void |
akka$actor$FSM$_setter_$StopEvent_$eq(FSM.StopEvent$ x$1) |
static void |
akka$actor$FSM$$currentState_$eq(FSM.State<S,D> x$1) |
static FSM.State<S,D> |
akka$actor$FSM$$currentState() |
static void |
akka$actor$FSM$$generation_$eq(long x$1) |
static long |
akka$actor$FSM$$generation() |
static void |
akka$actor$FSM$$handleEvent_$eq(scala.PartialFunction<FSM.Event<D>,FSM.State<S,D>> x$1) |
static scala.PartialFunction<FSM.Event<D>,FSM.State<S,D>> |
akka$actor$FSM$$handleEvent() |
static scala.PartialFunction<FSM.Event<D>,FSM.State<S,D>> |
akka$actor$FSM$$handleEventDefault() |
static void |
akka$actor$FSM$$nextState_$eq(FSM.State<S,D> x$1) |
static FSM.State<S,D> |
akka$actor$FSM$$nextState() |
static scala.collection.mutable.Map<S,scala.PartialFunction<FSM.Event<D>,FSM.State<S,D>>> |
akka$actor$FSM$$stateFunctions() |
static scala.collection.mutable.Map<S,scala.Option<scala.concurrent.duration.FiniteDuration>> |
akka$actor$FSM$$stateTimeouts() |
static void |
akka$actor$FSM$$terminateEvent_$eq(scala.PartialFunction<FSM.StopEvent<S,D>,scala.runtime.BoxedUnit> x$1) |
static scala.PartialFunction<FSM.StopEvent<S,D>,scala.runtime.BoxedUnit> |
akka$actor$FSM$$terminateEvent() |
static void |
akka$actor$FSM$$timeoutFuture_$eq(scala.Option<Cancellable> x$1) |
static scala.Option<Cancellable> |
akka$actor$FSM$$timeoutFuture() |
static scala.collection.Iterator<java.lang.Object> |
akka$actor$FSM$$timerGen() |
static scala.collection.mutable.Map<java.lang.String,FSM.Timer> |
akka$actor$FSM$$timers() |
static void |
akka$actor$FSM$$transitionEvent_$eq(scala.collection.immutable.List<scala.PartialFunction<scala.Tuple2<S,S>,scala.runtime.BoxedUnit>> x$1) |
static scala.collection.immutable.List<scala.PartialFunction<scala.Tuple2<S,S>,scala.runtime.BoxedUnit>> |
akka$actor$FSM$$transitionEvent() |
protected abstract static void |
akka$routing$Listeners$_setter_$listeners_$eq(java.util.Set<ActorRef> x$1) |
static void |
applyState(FSM.State<S,D> nextState) |
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) |
static void |
cancelTimer(java.lang.String name) |
void |
cleanupOverdueNotMemberAnyMore() |
Cluster |
cluster() |
ActorContext |
context()
Stores the context for this actor, including self, and sender.
|
static boolean |
debugEvent() |
FSM.Event$ |
Event() |
void |
getNextOldestChanged() |
protected static void |
gossip(java.lang.Object msg,
ActorRef sender) |
protected static ActorRef |
gossip$default$2(java.lang.Object msg) |
FSM.State<FSM.State,akka.cluster.singleton.ClusterSingletonManager.Data> |
gotoHandingOver(ActorRef singleton,
boolean singletonTerminated,
scala.Option<ActorRef> handOverTo) |
FSM.State<FSM.State,akka.cluster.singleton.ClusterSingletonManager.Data> |
gotoOldest() |
FSM.State<FSM.State,akka.cluster.singleton.ClusterSingletonManager.Data> |
gotoStopping(ActorRef singleton) |
FSM.State<FSM.State,akka.cluster.singleton.ClusterSingletonManager.Data> |
handOverDone(scala.Option<ActorRef> handOverTo) |
static void |
initialize() |
static boolean |
isStateTimerActive() |
static boolean |
isTimerActive(java.lang.String name) |
protected static scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> |
listenerManagement() |
protected java.util.Set<ActorRef> |
listeners() |
static LoggingAdapter |
log() |
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) |
protected static void |
logTermination(FSM.Reason reason) |
static void |
makeTransition(FSM.State<S,D> nextState) |
int |
maxHandOverRetries() |
int |
maxTakeOverRetries() |
static D |
nextStateData() |
ActorRef |
oldestChangedBuffer() |
boolean |
oldestChangedReceived() |
static void |
onTermination(scala.PartialFunction<FSM.StopEvent<S,D>,scala.runtime.BoxedUnit> terminationHandler) |
static void |
onTransition(scala.PartialFunction<scala.Tuple2<S,S>,scala.runtime.BoxedUnit> transitionHandler) |
ActorSelection |
peer(Address at) |
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 void |
processEvent(FSM.Event<D> event,
java.lang.Object source) |
static Props |
props(Props singletonProps,
java.lang.Object terminationMessage,
ClusterSingletonManagerSettings settings)
Scala API: Factory method for
ClusterSingletonManager Props . |
static scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> |
receive() |
scala.concurrent.duration.FiniteDuration |
removalMargin() |
scala.collection.immutable.Map<UniqueAddress,scala.concurrent.duration.Deadline> |
removed() |
void |
scheduleDelayedMemberRemoved(Member m) |
ActorRef |
self()
The 'self' field holds the ActorRef for this actor.
|
boolean |
selfExited() |
scala.Some<UniqueAddress> |
selfUniqueAddressOption() |
static ActorRef |
sender() |
static void |
setStateTimeout(S state,
scala.Option<scala.concurrent.duration.FiniteDuration> timeout) |
static void |
setTimer(java.lang.String name,
java.lang.Object msg,
scala.concurrent.duration.FiniteDuration timeout,
boolean repeat) |
static boolean |
setTimer$default$4() |
static void |
startWith(S stateName,
D stateData,
scala.Option<scala.concurrent.duration.FiniteDuration> timeout) |
static scala.Option<scala.concurrent.duration.FiniteDuration> |
startWith$default$3() |
static D |
stateData() |
static S |
stateName() |
FSM.StateTimeout$ |
StateTimeout()
This case object is received in case of a state timeout.
|
static FSM.State<S,D> |
stay() |
static FSM.State<S,D> |
stop() |
static FSM.State<S,D> |
stop(FSM.Reason reason) |
static FSM.State<S,D> |
stop(FSM.Reason reason,
D stateData) |
FSM.StopEvent$ |
StopEvent() |
static SupervisorStrategy |
supervisorStrategy() |
static scala.PartialFunction<scala.Tuple2<S,S>,scala.runtime.BoxedUnit> |
total2pf(scala.Function2<S,S,scala.runtime.BoxedUnit> transitionHandler) |
static FSM.TransformHelper |
transform(scala.PartialFunction<FSM.Event<D>,FSM.State<S,D>> func) |
static void |
unhandled(java.lang.Object message) |
static void |
when(S stateName,
scala.concurrent.duration.FiniteDuration stateTimeout,
scala.PartialFunction<FSM.Event<D>,FSM.State<S,D>> stateFunction) |
static scala.concurrent.duration.FiniteDuration |
when$default$2() |
static void |
whenUnhandled(scala.PartialFunction<FSM.Event<D>,FSM.State<S,D>> stateFunction) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
applyState, cancelTimer, debugEvent, handleTransition, initialize, isStateTimerActive, isTimerActive, logTermination, makeTransition, nextStateData, onTermination, onTransition, processEvent, processMsg, receive, register, setStateTimeout, setTimer, startWith, stateData, stateName, stay, stop, stop, stop, terminate, total2pf, transform, when, whenUnhandled
aroundPostRestart, aroundPostStop, aroundPreRestart, aroundPreStart, aroundReceive, postRestart, preRestart, sender, supervisorStrategy, unhandled
gossip, listenerManagement
log
public ClusterSingletonManager(Props singletonProps, java.lang.Object terminationMessage, ClusterSingletonManagerSettings settings)
public static Props props(Props singletonProps, java.lang.Object terminationMessage, ClusterSingletonManagerSettings settings)
ClusterSingletonManager
Props
.singletonProps
- (undocumented)terminationMessage
- (undocumented)settings
- (undocumented)public 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.Exception
public static void postRestart(java.lang.Throwable reason) throws java.lang.Exception
java.lang.Exception
public 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)
protected static scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> listenerManagement()
protected static void gossip(java.lang.Object msg, ActorRef sender)
protected static ActorRef gossip$default$2(java.lang.Object msg)
protected abstract static void akka$routing$Listeners$_setter_$listeners_$eq(java.util.Set<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 static FSM.$minus$greater$ $minus$greater()
public static final void when(S stateName, scala.concurrent.duration.FiniteDuration stateTimeout, scala.PartialFunction<FSM.Event<D>,FSM.State<S,D>> stateFunction)
public static final void startWith(S stateName, D stateData, scala.Option<scala.concurrent.duration.FiniteDuration> timeout)
public static final FSM.State<S,D> stay()
public static final FSM.State<S,D> stop()
public static final FSM.State<S,D> stop(FSM.Reason reason)
public static final FSM.State<S,D> stop(FSM.Reason reason, D stateData)
public static final FSM.TransformHelper transform(scala.PartialFunction<FSM.Event<D>,FSM.State<S,D>> func)
public static final void setTimer(java.lang.String name, java.lang.Object msg, scala.concurrent.duration.FiniteDuration timeout, boolean repeat)
public static final void cancelTimer(java.lang.String name)
public static final boolean isTimerActive(java.lang.String name)
public static final void setStateTimeout(S state, scala.Option<scala.concurrent.duration.FiniteDuration> timeout)
public static final boolean isStateTimerActive()
public static final void onTransition(scala.PartialFunction<scala.Tuple2<S,S>,scala.runtime.BoxedUnit> transitionHandler)
public static final scala.PartialFunction<scala.Tuple2<S,S>,scala.runtime.BoxedUnit> total2pf(scala.Function2<S,S,scala.runtime.BoxedUnit> transitionHandler)
public static final void onTermination(scala.PartialFunction<FSM.StopEvent<S,D>,scala.runtime.BoxedUnit> terminationHandler)
public static final void whenUnhandled(scala.PartialFunction<FSM.Event<D>,FSM.State<S,D>> stateFunction)
public static final void initialize()
public static final S stateName()
public static final D stateData()
public static final D nextStateData()
public static boolean debugEvent()
public static FSM.State<S,D> akka$actor$FSM$$currentState()
public static void akka$actor$FSM$$currentState_$eq(FSM.State<S,D> x$1)
public static scala.Option<Cancellable> akka$actor$FSM$$timeoutFuture()
public static void akka$actor$FSM$$timeoutFuture_$eq(scala.Option<Cancellable> x$1)
public static FSM.State<S,D> akka$actor$FSM$$nextState()
public static void akka$actor$FSM$$nextState_$eq(FSM.State<S,D> x$1)
public static long akka$actor$FSM$$generation()
public static void akka$actor$FSM$$generation_$eq(long x$1)
public static scala.collection.mutable.Map<java.lang.String,FSM.Timer> akka$actor$FSM$$timers()
public static scala.collection.Iterator<java.lang.Object> akka$actor$FSM$$timerGen()
public static scala.collection.mutable.Map<S,scala.PartialFunction<FSM.Event<D>,FSM.State<S,D>>> akka$actor$FSM$$stateFunctions()
public static scala.collection.mutable.Map<S,scala.Option<scala.concurrent.duration.FiniteDuration>> akka$actor$FSM$$stateTimeouts()
public static scala.PartialFunction<FSM.Event<D>,FSM.State<S,D>> akka$actor$FSM$$handleEventDefault()
public static scala.PartialFunction<FSM.Event<D>,FSM.State<S,D>> akka$actor$FSM$$handleEvent()
public static void akka$actor$FSM$$handleEvent_$eq(scala.PartialFunction<FSM.Event<D>,FSM.State<S,D>> x$1)
public static scala.PartialFunction<FSM.StopEvent<S,D>,scala.runtime.BoxedUnit> akka$actor$FSM$$terminateEvent()
public static void akka$actor$FSM$$terminateEvent_$eq(scala.PartialFunction<FSM.StopEvent<S,D>,scala.runtime.BoxedUnit> x$1)
public static scala.collection.immutable.List<scala.PartialFunction<scala.Tuple2<S,S>,scala.runtime.BoxedUnit>> akka$actor$FSM$$transitionEvent()
public static void akka$actor$FSM$$transitionEvent_$eq(scala.collection.immutable.List<scala.PartialFunction<scala.Tuple2<S,S>,scala.runtime.BoxedUnit>> x$1)
public static scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive()
public static void processEvent(FSM.Event<D> event, java.lang.Object source)
public static void applyState(FSM.State<S,D> nextState)
public static void makeTransition(FSM.State<S,D> nextState)
protected static void logTermination(FSM.Reason reason)
public static final scala.concurrent.duration.FiniteDuration when$default$2()
public static final scala.Option<scala.concurrent.duration.FiniteDuration> startWith$default$3()
public static final boolean setTimer$default$4()
protected abstract static void akka$actor$FSM$_setter_$Event_$eq(FSM.Event$ x$1)
protected abstract static void akka$actor$FSM$_setter_$StopEvent_$eq(FSM.StopEvent$ x$1)
protected abstract static void akka$actor$FSM$_setter_$$minus$greater_$eq(FSM.$minus$greater$ x$1)
protected abstract static void akka$actor$FSM$_setter_$StateTimeout_$eq(FSM.StateTimeout$ x$1)
protected abstract static void akka$actor$FSM$_setter_$akka$actor$FSM$$timers_$eq(scala.collection.mutable.Map<java.lang.String,FSM.Timer> x$1)
protected abstract static void akka$actor$FSM$_setter_$akka$actor$FSM$$timerGen_$eq(scala.collection.Iterator<java.lang.Object> x$1)
protected abstract static void akka$actor$FSM$_setter_$akka$actor$FSM$$stateFunctions_$eq(scala.collection.mutable.Map<S,scala.PartialFunction<FSM.Event<D>,FSM.State<S,D>>> x$1)
protected abstract static void akka$actor$FSM$_setter_$akka$actor$FSM$$stateTimeouts_$eq(scala.collection.mutable.Map<S,scala.Option<scala.concurrent.duration.FiniteDuration>> x$1)
protected abstract static void akka$actor$FSM$_setter_$akka$actor$FSM$$handleEventDefault_$eq(scala.PartialFunction<FSM.Event<D>,FSM.State<S,D>> x$1)
public FSM.Event$ Event()
public FSM.StopEvent$ StopEvent()
public FSM.StateTimeout$ StateTimeout()
FSM
StateTimeout
in interface FSM<akka.cluster.singleton.ClusterSingletonManager.State,akka.cluster.singleton.ClusterSingletonManager.Data>
protected java.util.Set<ActorRef> listeners()
public ActorContext context()
Actor
forward
.
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()
Actor
self ! message
public Cluster cluster()
public scala.Some<UniqueAddress> selfUniqueAddressOption()
public scala.concurrent.duration.FiniteDuration removalMargin()
public int maxHandOverRetries()
public int maxTakeOverRetries()
public ActorRef oldestChangedBuffer()
public boolean oldestChangedReceived()
public boolean selfExited()
public scala.collection.immutable.Map<UniqueAddress,scala.concurrent.duration.Deadline> removed()
public void addRemoved(UniqueAddress node)
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()
Actor
public void postStop()
Actor
public ActorSelection peer(Address at)
public void getNextOldestChanged()
public void scheduleDelayedMemberRemoved(Member m)
public FSM.State<FSM.State,akka.cluster.singleton.ClusterSingletonManager.Data> gotoOldest()
public FSM.State<FSM.State,akka.cluster.singleton.ClusterSingletonManager.Data> gotoHandingOver(ActorRef singleton, boolean singletonTerminated, scala.Option<ActorRef> handOverTo)
public FSM.State<FSM.State,akka.cluster.singleton.ClusterSingletonManager.Data> handOverDone(scala.Option<ActorRef> handOverTo)