Class ClusterSingletonManager

  • All Implemented Interfaces:
    Actor, ActorLogging, FSM<ClusterSingletonManager.State,​ClusterSingletonManager.Data>, Listeners

    public class ClusterSingletonManager
    extends java.lang.Object
    implements Actor, FSM<ClusterSingletonManager.State,​ClusterSingletonManager.Data>
    Manages singleton actor instance among all cluster nodes or a group of nodes tagged with a specific role. At most one singleton instance is running at any point in time.

    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.

    Not intended for subclassing by user code.

    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

    • Method Detail

      • props

        public static Props props​(Props singletonProps,
                                  java.lang.Object terminationMessage,
                                  ClusterSingletonManagerSettings settings)
        Scala API: Factory method for ClusterSingletonManager Props.
        Parameters:
        singletonProps - (undocumented)
        terminationMessage - (undocumented)
        settings - (undocumented)
        Returns:
        (undocumented)
      • sender

        public static final ActorRef sender()
      • aroundReceive

        protected static void aroundReceive​(scala.PartialFunction<java.lang.Object,​scala.runtime.BoxedUnit> receive,
                                            java.lang.Object msg)
      • aroundPreStart

        protected static void aroundPreStart()
      • aroundPostStop

        protected static void aroundPostStop()
      • aroundPreRestart

        protected static void aroundPreRestart​(java.lang.Throwable reason,
                                               scala.Option<java.lang.Object> message)
      • aroundPostRestart

        protected static void aroundPostRestart​(java.lang.Throwable reason)
      • preRestart

        public static void preRestart​(java.lang.Throwable reason,
                                      scala.Option<java.lang.Object> message)
                               throws java.lang.Exception
        Throws:
        java.lang.Exception
      • postRestart

        public static void postRestart​(java.lang.Throwable reason)
                                throws java.lang.Exception
        Throws:
        java.lang.Exception
      • unhandled

        public static void unhandled​(java.lang.Object message)
      • listenerManagement

        protected static scala.PartialFunction<java.lang.Object,​scala.runtime.BoxedUnit> listenerManagement()
      • gossip

        protected static void gossip​(java.lang.Object msg,
                                     ActorRef sender)
      • gossip$default$2

        protected static ActorRef gossip$default$2​(java.lang.Object msg)
      • akka$actor$ActorLogging$$_log

        public static LoggingAdapter akka$actor$ActorLogging$$_log()
      • akka$actor$ActorLogging$$_log_$eq

        public static void akka$actor$ActorLogging$$_log_$eq​(LoggingAdapter x$1)
      • when

        public static final void when​(S stateName,
                                      scala.concurrent.duration.FiniteDuration stateTimeout,
                                      scala.PartialFunction<FSM.Event<D>,​FSM.State<S,​D>> stateFunction)
      • when$default$2

        public static final scala.concurrent.duration.FiniteDuration when$default$2()
      • startWith

        public static final void startWith​(S stateName,
                                           D stateData,
                                           scala.Option<scala.concurrent.duration.FiniteDuration> timeout)
      • startWith$default$3

        public static final scala.Option<scala.concurrent.duration.FiniteDuration> startWith$default$3()
      • stay

        public static final FSM.State<S,​D> stay()
      • stop

        public static final FSM.State<S,​D> stop()
      • setTimer

        public static final void setTimer​(java.lang.String name,
                                          java.lang.Object msg,
                                          scala.concurrent.duration.FiniteDuration timeout,
                                          boolean repeat)
      • setTimer$default$4

        public static final boolean setTimer$default$4()
      • cancelTimer

        public static final void cancelTimer​(java.lang.String name)
      • isTimerActive

        public static final boolean isTimerActive​(java.lang.String name)
      • setStateTimeout

        public static final void setStateTimeout​(S state,
                                                 scala.Option<scala.concurrent.duration.FiniteDuration> timeout)
      • isStateTimerActive

        public static final boolean isStateTimerActive()
      • onTransition

        public static final void onTransition​(scala.PartialFunction<scala.Tuple2<S,​S>,​scala.runtime.BoxedUnit> transitionHandler)
      • total2pf

        public static final scala.PartialFunction<scala.Tuple2<S,​S>,​scala.runtime.BoxedUnit> total2pf​(scala.Function2<S,​S,​scala.runtime.BoxedUnit> transitionHandler)
      • onTermination

        public static final void onTermination​(scala.PartialFunction<FSM.StopEvent<S,​D>,​scala.runtime.BoxedUnit> terminationHandler)
      • whenUnhandled

        public static final void whenUnhandled​(scala.PartialFunction<FSM.Event<D>,​FSM.State<S,​D>> stateFunction)
      • initialize

        public static final void initialize()
      • stateName

        public static final S stateName()
      • stateData

        public static final D stateData()
      • nextStateData

        public static final D nextStateData()
      • debugEvent

        public static boolean debugEvent()
      • akka$actor$FSM$$currentState

        public static FSM.State<S,​D> akka$actor$FSM$$currentState()
      • akka$actor$FSM$$currentState_$eq

        public static void akka$actor$FSM$$currentState_$eq​(FSM.State<S,​D> x$1)
      • akka$actor$FSM$$timeoutFuture

        public static scala.Option<Cancellable> akka$actor$FSM$$timeoutFuture()
      • akka$actor$FSM$$timeoutFuture_$eq

        public static void akka$actor$FSM$$timeoutFuture_$eq​(scala.Option<Cancellable> x$1)
      • akka$actor$FSM$$nextState

        public static FSM.State<S,​D> akka$actor$FSM$$nextState()
      • akka$actor$FSM$$nextState_$eq

        public static void akka$actor$FSM$$nextState_$eq​(FSM.State<S,​D> x$1)
      • akka$actor$FSM$$generation

        public static long akka$actor$FSM$$generation()
      • akka$actor$FSM$$generation_$eq

        public static void akka$actor$FSM$$generation_$eq​(long x$1)
      • akka$actor$FSM$$timers

        public static scala.collection.mutable.Map<java.lang.String,​FSM.Timer> akka$actor$FSM$$timers()
      • akka$actor$FSM$$timerGen

        public static scala.collection.Iterator<java.lang.Object> akka$actor$FSM$$timerGen()
      • akka$actor$FSM$$stateFunctions

        public static scala.collection.mutable.Map<S,​scala.PartialFunction<FSM.Event<D>,​FSM.State<S,​D>>> akka$actor$FSM$$stateFunctions()
      • akka$actor$FSM$$stateTimeouts

        public static scala.collection.mutable.Map<S,​scala.Option<scala.concurrent.duration.FiniteDuration>> akka$actor$FSM$$stateTimeouts()
      • akka$actor$FSM$$handleEventDefault

        public static scala.PartialFunction<FSM.Event<D>,​FSM.State<S,​D>> akka$actor$FSM$$handleEventDefault()
      • akka$actor$FSM$$handleEvent

        public static scala.PartialFunction<FSM.Event<D>,​FSM.State<S,​D>> akka$actor$FSM$$handleEvent()
      • akka$actor$FSM$$handleEvent_$eq

        public static void akka$actor$FSM$$handleEvent_$eq​(scala.PartialFunction<FSM.Event<D>,​FSM.State<S,​D>> x$1)
      • akka$actor$FSM$$terminateEvent

        public static scala.PartialFunction<FSM.StopEvent<S,​D>,​scala.runtime.BoxedUnit> akka$actor$FSM$$terminateEvent()
      • akka$actor$FSM$$terminateEvent_$eq

        public static void akka$actor$FSM$$terminateEvent_$eq​(scala.PartialFunction<FSM.StopEvent<S,​D>,​scala.runtime.BoxedUnit> x$1)
      • akka$actor$FSM$$transitionEvent

        public static scala.collection.immutable.List<scala.PartialFunction<scala.Tuple2<S,​S>,​scala.runtime.BoxedUnit>> akka$actor$FSM$$transitionEvent()
      • akka$actor$FSM$$transitionEvent_$eq

        public static void akka$actor$FSM$$transitionEvent_$eq​(scala.collection.immutable.List<scala.PartialFunction<scala.Tuple2<S,​S>,​scala.runtime.BoxedUnit>> x$1)
      • receive

        public static scala.PartialFunction<java.lang.Object,​scala.runtime.BoxedUnit> receive()
      • processEvent

        public static void processEvent​(FSM.Event<D> event,
                                        java.lang.Object source)
      • applyState

        public static void applyState​(FSM.State<S,​D> nextState)
      • makeTransition

        public static void makeTransition​(FSM.State<S,​D> nextState)
      • logTermination

        protected static void logTermination​(FSM.Reason reason)
      • akka$actor$FSM$_setter_$$minus$greater_$eq

        protected abstract static void akka$actor$FSM$_setter_$$minus$greater_$eq​(FSM.$minus$greater$ x$1)
      • akka$actor$FSM$_setter_$akka$actor$FSM$$timers_$eq

        protected abstract static void akka$actor$FSM$_setter_$akka$actor$FSM$$timers_$eq​(scala.collection.mutable.Map<java.lang.String,​FSM.Timer> x$1)
      • akka$actor$FSM$_setter_$akka$actor$FSM$$timerGen_$eq

        protected abstract static void akka$actor$FSM$_setter_$akka$actor$FSM$$timerGen_$eq​(scala.collection.Iterator<java.lang.Object> x$1)
      • akka$actor$FSM$_setter_$akka$actor$FSM$$stateFunctions_$eq

        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)
      • akka$actor$FSM$_setter_$akka$actor$FSM$$stateTimeouts_$eq

        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)
      • akka$actor$FSM$_setter_$akka$actor$FSM$$handleEventDefault_$eq

        protected abstract static void akka$actor$FSM$_setter_$akka$actor$FSM$$handleEventDefault_$eq​(scala.PartialFunction<FSM.Event<D>,​FSM.State<S,​D>> x$1)
      • context

        public ActorContext context()
        Description copied from interface: Actor
        Scala API: Stores the context for this actor, including self, and sender. It is implicit to support operations such as 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 AbstractActor.ActorContext, which is the Java API of the actor context.

        Specified by:
        context in interface Actor
        Returns:
        (undocumented)
      • self

        public final ActorRef self()
        Description copied from interface: Actor
        The 'self' field holds the ActorRef for this actor.

        Can be used to send messages to itself:
         self ! message
         
        Specified by:
        self in interface Actor
        Returns:
        (undocumented)
      • akka$actor$Actor$_setter_$context_$eq

        protected void akka$actor$Actor$_setter_$context_$eq​(ActorContext x$1)
        Description copied from interface: Actor
        Scala API: Stores the context for this actor, including self, and sender. It is implicit to support operations such as 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 AbstractActor.ActorContext, which is the Java API of the actor context.

        Specified by:
        akka$actor$Actor$_setter_$context_$eq in interface Actor
        Parameters:
        x$1 - (undocumented)
      • akka$actor$Actor$_setter_$self_$eq

        protected final void akka$actor$Actor$_setter_$self_$eq​(ActorRef x$1)
        Description copied from interface: Actor
        The 'self' field holds the ActorRef for this actor.

        Can be used to send messages to itself:
         self ! message
         
        Specified by:
        akka$actor$Actor$_setter_$self_$eq in interface Actor
        Parameters:
        x$1 - (undocumented)
      • cluster

        public Cluster cluster()
      • selfUniqueAddressOption

        public scala.Some<UniqueAddress> selfUniqueAddressOption()
      • removalMargin

        public scala.concurrent.duration.FiniteDuration removalMargin()
      • maxHandOverRetries

        public int maxHandOverRetries()
      • maxTakeOverRetries

        public int maxTakeOverRetries()
      • oldestChangedBuffer

        public ActorRef oldestChangedBuffer()
      • oldestChangedBuffer_$eq

        public void oldestChangedBuffer_$eq​(ActorRef x$1)
      • oldestChangedReceived

        public boolean oldestChangedReceived()
      • oldestChangedReceived_$eq

        public void oldestChangedReceived_$eq​(boolean x$1)
      • selfExited

        public boolean selfExited()
      • selfExited_$eq

        public void selfExited_$eq​(boolean x$1)
      • removed

        public scala.collection.immutable.Map<UniqueAddress,​scala.concurrent.duration.Deadline> removed()
      • removed_$eq

        public void removed_$eq​(scala.collection.immutable.Map<UniqueAddress,​scala.concurrent.duration.Deadline> x$1)
      • cleanupOverdueNotMemberAnyMore

        public void cleanupOverdueNotMemberAnyMore()
      • memberExitingProgress

        public scala.concurrent.Promise<Done> memberExitingProgress()
      • logInfo

        public void logInfo​(java.lang.String message)
      • logInfo

        public void logInfo​(java.lang.String template,
                            java.lang.Object arg1)
      • logInfo

        public void logInfo​(java.lang.String template,
                            java.lang.Object arg1,
                            java.lang.Object arg2)
      • 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
      • getNextOldestChanged

        public void getNextOldestChanged()
      • scheduleDelayedMemberRemoved

        public void scheduleDelayedMemberRemoved​(Member m)
      • selfMemberExited

        public void selfMemberExited()