Class ClusterSingletonManager
- All Implemented Interfaces:
Actor,ActorLogging,FSM<ClusterSingletonManager.State,,ClusterSingletonManager.Data> Listeners
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 pekko.cluster.Member#isOlderThan.
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(org.apache.pekko.actor.Props, java.lang.Object, org.apache.pekko.cluster.singleton.ClusterSingletonManagerSettings) to create the
pekko.actor.Props for the actor.
Not intended for subclassing by user code.
param: singletonProps pekko.actor.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 pekko.actor.PoisonPill is a perfectly fine
terminationMessage if you only need to stop the actor.
param: settings see ClusterSingletonManagerSettings
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceINTERNAL API public due to thewith FSMtype parametersstatic classINTERNAL APIstatic interfaceINTERNAL API public due to thewith FSMtype parametersNested classes/interfaces inherited from interface org.apache.pekko.actor.Actor
Actor.emptyBehavior$, Actor.ignoringBehavior$Nested classes/interfaces inherited from interface org.apache.pekko.actor.FSM
FSM.$minus$greater$, FSM.CurrentState<S>, FSM.CurrentState$, FSM.Event<D>, FSM.Event$, FSM.Failure, FSM.Failure$, FSM.FixedDelayMode$, FSM.FixedRateMode$, FSM.LogEntry<S,D>, FSM.LogEntry$, FSM.Normal$, FSM.NullFunction$, FSM.Reason, FSM.Shutdown$, FSM.SilentState<S, D>, FSM.SingleMode$, FSM.State$, FSM.StateTimeout$, FSM.StopEvent<S, D>, FSM.StopEvent$, FSM.SubscribeTransitionCallBack, FSM.SubscribeTransitionCallBack$, FSM.Timer, FSM.Timer$, FSM.TimerMode, FSM.TransformHelper, FSM.Transition<S>, FSM.Transition$, FSM.UnsubscribeTransitionCallBack, FSM.UnsubscribeTransitionCallBack$ -
Constructor Summary
ConstructorsConstructorDescriptionClusterSingletonManager(Props singletonProps, Object terminationMessage, ClusterSingletonManagerSettings settings) -
Method Summary
Modifier and TypeMethodDescriptionThis extractor is just convenience for matching a (S, S) pair, including a reminder what the new state is.voidaddRemoved(UniqueAddress node) voidcluster()context()Scala API: Stores the context for this actor, including self, and sender.Event()voidgotoHandingOver(scala.Option<ActorRef> singleton, scala.Option<ActorRef> handOverTo) gotoStopping(ActorRef singleton) handleOldestChanged(scala.Option<ActorRef> singleton, scala.Option<UniqueAddress> oldestOption) handOverDone(scala.Option<ActorRef> handOverTo) scala.Option<Lease>lease()scala.concurrent.duration.FiniteDurationlog()voidvoidvoidvoidvoidvoidvoidintintscala.concurrent.Promise<Done>voidbooleanvoidoldestChangedReceived_$eq(boolean x$1) protected voidScala API: Stores the context for this actor, including self, and sender.protected final voidThe 'self' field holds the ActorRef for this actor.protected voidprotected voidThis case object is received in case of a state timeout.protected voidprotected voidvoidpostStop()User overridable callback.booleanvoidpreparingForFullShutdown_$eq(boolean x$1) voidpreStart()User overridable callback.static Propsprops(Props singletonProps, Object terminationMessage, ClusterSingletonManagerSettings settings) Scala API: Factory method forClusterSingletonManagerpekko.actor.Props.scala.concurrent.duration.FiniteDurationscala.collection.immutable.Map<UniqueAddress,scala.concurrent.duration.Deadline> removed()voidremoved_$eq(scala.collection.immutable.Map<UniqueAddress, scala.concurrent.duration.Deadline> x$1) voidfinal ActorRefself()The 'self' field holds the ActorRef for this actor.booleanvoidselfExited_$eq(boolean x$1) voidscala.Some<UniqueAddress>This case object is received in case of a state timeout.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.pekko.actor.Actor
aroundPostRestart, aroundPostStop, aroundPreRestart, aroundPreStart, aroundReceive, postRestart, preRestart, sender, supervisorStrategy, unhandledMethods inherited from interface org.apache.pekko.actor.ActorLogging
_log_$eqMethods inherited from interface org.apache.pekko.actor.FSM
applyState, cancelTimer, currentState_$eq, debugEvent, generation_$eq, handleEvent_$eq, handleTransition, initialize, isStateTimerActive, isTimerActive, logTermination, makeTransition, nextState_$eq, nextStateData, onTermination, onTransition, processEvent, processMsg, receive, register, setStateTimeout, startSingleTimer, startTimer, startTimerAtFixedRate, startTimerWithFixedDelay, startWith, startWith$default$3, stateData, stateName, stay, stop, stop, stop, super$postStop, terminate, terminateEvent_$eq, timeoutFuture_$eq, total2pf, transform, transitionEvent_$eq, when, when$default$2, whenUnhandledMethods inherited from interface org.apache.pekko.routing.Listeners
gossip, gossip$default$2, listenerManagement
-
Constructor Details
-
ClusterSingletonManager
public ClusterSingletonManager(Props singletonProps, Object terminationMessage, ClusterSingletonManagerSettings settings)
-
-
Method Details
-
props
public static Props props(Props singletonProps, Object terminationMessage, ClusterSingletonManagerSettings settings) Scala API: Factory method forClusterSingletonManagerpekko.actor.Props. -
Event
- Specified by:
Eventin interfaceFSM<ClusterSingletonManager.State,ClusterSingletonManager.Data>
-
StopEvent
- Specified by:
StopEventin interfaceFSM<ClusterSingletonManager.State,ClusterSingletonManager.Data>
-
$minus$greater
Description copied from interface:FSMThis extractor is just convenience for matching a (S, S) pair, including a reminder what the new state is.- Specified by:
$minus$greaterin interfaceFSM<ClusterSingletonManager.State,ClusterSingletonManager.Data>
-
StateTimeout
Description copied from interface:FSMThis case object is received in case of a state timeout.- Specified by:
StateTimeoutin interfaceFSM<ClusterSingletonManager.State,ClusterSingletonManager.Data>
-
org$apache$pekko$actor$FSM$_setter_$Event_$eq
- Specified by:
org$apache$pekko$actor$FSM$_setter_$Event_$eqin interfaceFSM<ClusterSingletonManager.State,ClusterSingletonManager.Data>
-
org$apache$pekko$actor$FSM$_setter_$StopEvent_$eq
- Specified by:
org$apache$pekko$actor$FSM$_setter_$StopEvent_$eqin interfaceFSM<ClusterSingletonManager.State,ClusterSingletonManager.Data>
-
org$apache$pekko$actor$FSM$_setter_$StateTimeout_$eq
Description copied from interface:FSMThis case object is received in case of a state timeout.- Specified by:
org$apache$pekko$actor$FSM$_setter_$StateTimeout_$eqin interfaceFSM<ClusterSingletonManager.State,ClusterSingletonManager.Data>
-
listeners
-
org$apache$pekko$routing$Listeners$_setter_$listeners_$eq
- Specified by:
org$apache$pekko$routing$Listeners$_setter_$listeners_$eqin interfaceListeners
-
context
Description copied from interface:ActorScala API: Stores the context for this actor, including self, and sender. It is implicit to support operations such asforward.WARNING: Only valid within the Actor itself, so do not close over it and publish it to other threads!
pekko.actor.ActorContextis the Scala API.getContextreturns apekko.actor.AbstractActor.ActorContext, which is the Java API of the actor context. -
self
Description copied from interface:ActorThe 'self' field holds the ActorRef for this actor. Can be used to send messages to itself:self ! message
-
org$apache$pekko$actor$Actor$_setter_$context_$eq
Description copied from interface:ActorScala API: Stores the context for this actor, including self, and sender. It is implicit to support operations such asforward.WARNING: Only valid within the Actor itself, so do not close over it and publish it to other threads!
pekko.actor.ActorContextis the Scala API.getContextreturns apekko.actor.AbstractActor.ActorContext, which is the Java API of the actor context.- Specified by:
org$apache$pekko$actor$Actor$_setter_$context_$eqin interfaceActor
-
org$apache$pekko$actor$Actor$_setter_$self_$eq
Description copied from interface:ActorThe 'self' field holds the ActorRef for this actor. Can be used to send messages to itself:self ! message
- Specified by:
org$apache$pekko$actor$Actor$_setter_$self_$eqin interfaceActor
-
cluster
-
selfUniqueAddressOption
-
log
- Specified by:
login interfaceActorLogging
-
lease
-
leaseRetryInterval
public scala.concurrent.duration.FiniteDuration leaseRetryInterval() -
removalMargin
public scala.concurrent.duration.FiniteDuration removalMargin() -
maxHandOverRetries
public int maxHandOverRetries() -
maxTakeOverRetries
public int maxTakeOverRetries() -
oldestChangedBuffer
-
oldestChangedBuffer_$eq
-
oldestChangedReceived
public boolean oldestChangedReceived() -
oldestChangedReceived_$eq
public void oldestChangedReceived_$eq(boolean x$1) -
preparingForFullShutdown
public boolean preparingForFullShutdown() -
preparingForFullShutdown_$eq
public void preparingForFullShutdown_$eq(boolean x$1) -
selfExited
public boolean selfExited() -
selfExited_$eq
public void selfExited_$eq(boolean x$1) -
removed
-
removed_$eq
public void removed_$eq(scala.collection.immutable.Map<UniqueAddress, scala.concurrent.duration.Deadline> x$1) -
addRemoved
-
cleanupOverdueNotMemberAnyMore
public void cleanupOverdueNotMemberAnyMore() -
coordShutdown
-
memberExitingProgress
-
logInfo
-
logInfo
-
logInfo
-
logInfo
-
logInfo
-
logInfo
-
logInfo
-
preStart
public void preStart()Description copied from interface:ActorUser overridable callback. Is called when an Actor is started. Actors are automatically started asynchronously when created. Empty default implementation. -
postStop
public void postStop()Description copied from interface:ActorUser overridable callback. Is called asynchronously after 'actor.stop()' is invoked. Empty default implementation.- Specified by:
postStopin interfaceActor- Specified by:
postStopin interfaceFSM<ClusterSingletonManager.State,ClusterSingletonManager.Data>
-
peer
-
getNextOldestChanged
public void getNextOldestChanged() -
handleMemberEvent
public FSM.State<ClusterSingletonManager.State,ClusterSingletonManager.Data> handleMemberEvent(ClusterEvent.MemberEvent event) -
scheduleDelayedMemberRemoved
-
tryAcquireLease
-
tryGotoOldest
-
gotoOldest
-
handleOldestChanged
public FSM.State<ClusterSingletonManager.State,ClusterSingletonManager.Data> handleOldestChanged(scala.Option<ActorRef> singleton, scala.Option<UniqueAddress> oldestOption) -
gotoHandingOver
public FSM.State<ClusterSingletonManager.State,ClusterSingletonManager.Data> gotoHandingOver(scala.Option<ActorRef> singleton, scala.Option<ActorRef> handOverTo) -
handOverDone
public FSM.State<ClusterSingletonManager.State,ClusterSingletonManager.Data> handOverDone(scala.Option<ActorRef> handOverTo) -
gotoStopping
public FSM.State<ClusterSingletonManager.State,ClusterSingletonManager.Data> gotoStopping(ActorRef singleton) -
selfMemberExited
public void selfMemberExited()
-