Class CoordinatedShutdown
- java.lang.Object
-
- akka.actor.CoordinatedShutdown
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCoordinatedShutdown.ActorSystemTerminateReason$static classCoordinatedShutdown.ClusterDowningReason$static classCoordinatedShutdown.ClusterJoinUnsuccessfulReason$static classCoordinatedShutdown.ClusterLeavingReason$static classCoordinatedShutdown.IncompatibleConfigurationDetectedReason$static classCoordinatedShutdown.JvmExitReason$static classCoordinatedShutdown.Phase$static interfaceCoordinatedShutdown.PhaseDefinitionstatic interfaceCoordinatedShutdown.ReasonReason for the shutdown, which can be used by tasks in case they need to do different things depending on what caused the shutdown.static classCoordinatedShutdown.UnknownReason$
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static CoordinatedShutdown.ReasonactorSystemTerminateReason()voidaddActorTerminationTask(java.lang.String phase, java.lang.String taskName, ActorRef actor, java.util.Optional<java.lang.Object> stopMsg)Java API: Add an actor termination task to a phase.voidaddActorTerminationTask(java.lang.String phase, java.lang.String taskName, ActorRef actor, scala.Option<java.lang.Object> stopMsg)Scala API: Add an actor termination task to a phase.CancellableaddCancellableJvmShutdownHook(java.lang.Runnable hook)Java API: Add a JVM shutdown hook that will be run when the JVM process begins its shutdown sequence.<T> CancellableaddCancellableJvmShutdownHook(scala.Function0<T> hook)Scala API: Add a JVM shutdown hook that will be run when the JVM process begins its shutdown sequence.CancellableaddCancellableTask(java.lang.String phase, java.lang.String taskName, java.util.function.Supplier<java.util.concurrent.CompletionStage<Done>> task)Java API: Add a task to a phase, returning an object which will cancel it on demand and remove it from the task pool (so long as the same task has not been added elsewhere).CancellableaddCancellableTask(java.lang.String phase, java.lang.String taskName, scala.Function0<scala.concurrent.Future<Done>> task)Scala API: Add a task to a phase, returning an object which will cancel it on demand and remove it from the task pool (so long as the same task has not been added elsewhere).voidaddJvmShutdownHook(java.lang.Runnable hook)Java API: Add a JVM shutdown hook that will be run when the JVM process begins its shutdown sequence.<T> voidaddJvmShutdownHook(scala.Function0<T> hook)Scala API: Add a JVM shutdown hook that will be run when the JVM process begins its shutdown sequence.voidaddTask(java.lang.String phase, java.lang.String taskName, java.util.function.Supplier<java.util.concurrent.CompletionStage<Done>> task)Java API: Add a task to a phase.voidaddTask(java.lang.String phase, java.lang.String taskName, scala.Function0<scala.concurrent.Future<Done>> task)Scala API: Add a task to a phase.static Tapply(ActorSystem system)static Tapply(ClassicActorSystemProvider system)static CoordinatedShutdown.ReasonclusterDowningReason()static CoordinatedShutdown.ReasonclusterJoinUnsuccessfulReason()static CoordinatedShutdown.ReasonclusterLeavingReason()static CoordinatedShutdowncreateExtension(ExtendedActorSystem system)static booleanequals(java.lang.Object other)static CoordinatedShutdownget(ActorSystem system)static CoordinatedShutdownget(ClassicActorSystemProvider system)java.util.Optional<CoordinatedShutdown.Reason>getShutdownReason()TheReasonfor the shutdown as passed to therunmethod.static inthashCode()static CoordinatedShutdown.ReasonincompatibleConfigurationDetectedReason()static CoordinatedShutdown.ReasonjvmExitReason()static CoordinatedShutdown$lookup()static java.lang.StringPhaseActorSystemTerminate()Last phase.static java.lang.StringPhaseBeforeActorSystemTerminate()Phase for custom application tasks that are to be run after cluster shutdown and before ActorSystem termination.static java.lang.StringPhaseBeforeClusterShutdown()Phase for custom application tasks that are to be run after service shutdown and before cluster shutdown.static java.lang.StringPhaseBeforeServiceUnbind()static java.lang.StringPhaseClusterExiting()Shutdown cluster singletonsstatic java.lang.StringPhaseClusterExitingDone()Wait until exiting has been completedstatic java.lang.StringPhaseClusterLeave()Emit the leave command for the node that is shutting down.static java.lang.StringPhaseClusterShardingShutdownRegion()Graceful shutdown of the Cluster Sharding regions.static java.lang.StringPhaseClusterShutdown()Shutdown the cluster extensionstatic java.lang.StringPhaseServiceRequestsDone()Wait for requests that are in progress to be completed.static java.lang.StringPhaseServiceStop()Final shutdown of service endpoints.static java.lang.StringPhaseServiceUnbind()Stop accepting new incoming requests in for example HTTP.scala.concurrent.Future<Done>run(CoordinatedShutdown.Reason reason)Scala API: Run tasks of all phases.java.util.concurrent.CompletionStage<Done>run(CoordinatedShutdown.Reason reason, java.util.Optional<java.lang.String> fromPhase)Java API: Run tasks of all phases including and after the given phase.scala.concurrent.Future<Done>run(CoordinatedShutdown.Reason reason, scala.Option<java.lang.String> fromPhase)Scala API: Run tasks of all phases including and after the given phase.java.util.concurrent.CompletionStage<Done>runAll(CoordinatedShutdown.Reason reason)Java API: Run tasks of all phases.scala.Option<CoordinatedShutdown.Reason>shutdownReason()TheReasonfor the shutdown as passed to therunmethod.scala.concurrent.duration.FiniteDurationtimeout(java.lang.String phase)The configured timeout for a givenphase.scala.concurrent.duration.FiniteDurationtotalTimeout()Sum of timeouts of all phases that have some task.static CoordinatedShutdown.ReasonunknownReason()
-
-
-
Method Detail
-
PhaseBeforeServiceUnbind
public static java.lang.String PhaseBeforeServiceUnbind()
-
PhaseServiceUnbind
public static java.lang.String PhaseServiceUnbind()
Stop accepting new incoming requests in for example HTTP.
-
PhaseServiceRequestsDone
public static java.lang.String PhaseServiceRequestsDone()
Wait for requests that are in progress to be completed.
-
PhaseServiceStop
public static java.lang.String PhaseServiceStop()
Final shutdown of service endpoints.
-
PhaseBeforeClusterShutdown
public static java.lang.String PhaseBeforeClusterShutdown()
Phase for custom application tasks that are to be run after service shutdown and before cluster shutdown.
-
PhaseClusterShardingShutdownRegion
public static java.lang.String PhaseClusterShardingShutdownRegion()
Graceful shutdown of the Cluster Sharding regions.
-
PhaseClusterLeave
public static java.lang.String PhaseClusterLeave()
Emit the leave command for the node that is shutting down.
-
PhaseClusterExiting
public static java.lang.String PhaseClusterExiting()
Shutdown cluster singletons
-
PhaseClusterExitingDone
public static java.lang.String PhaseClusterExitingDone()
Wait until exiting has been completed
-
PhaseClusterShutdown
public static java.lang.String PhaseClusterShutdown()
Shutdown the cluster extension
-
PhaseBeforeActorSystemTerminate
public static java.lang.String PhaseBeforeActorSystemTerminate()
Phase for custom application tasks that are to be run after cluster shutdown and before ActorSystem termination.
-
PhaseActorSystemTerminate
public static java.lang.String PhaseActorSystemTerminate()
Last phase. See terminate-actor-system and exit-jvm above. Don't add phases that depends on this phase because the dispatcher and scheduler of the ActorSystem have been shutdown.
-
unknownReason
public static CoordinatedShutdown.Reason unknownReason()
-
actorSystemTerminateReason
public static CoordinatedShutdown.Reason actorSystemTerminateReason()
-
jvmExitReason
public static CoordinatedShutdown.Reason jvmExitReason()
-
clusterDowningReason
public static CoordinatedShutdown.Reason clusterDowningReason()
-
clusterJoinUnsuccessfulReason
public static CoordinatedShutdown.Reason clusterJoinUnsuccessfulReason()
-
incompatibleConfigurationDetectedReason
public static CoordinatedShutdown.Reason incompatibleConfigurationDetectedReason()
-
clusterLeavingReason
public static CoordinatedShutdown.Reason clusterLeavingReason()
-
get
public static CoordinatedShutdown get(ActorSystem system)
-
get
public static CoordinatedShutdown get(ClassicActorSystemProvider system)
-
lookup
public static CoordinatedShutdown$ lookup()
-
createExtension
public static CoordinatedShutdown createExtension(ExtendedActorSystem system)
-
apply
public static T apply(ActorSystem system)
-
apply
public static T apply(ClassicActorSystemProvider system)
-
hashCode
public static final int hashCode()
-
equals
public static final boolean equals(java.lang.Object other)
-
addCancellableTask
public Cancellable addCancellableTask(java.lang.String phase, java.lang.String taskName, scala.Function0<scala.concurrent.Future<Done>> task)
Scala API: Add a task to a phase, returning an object which will cancel it on demand and remove it from the task pool (so long as the same task has not been added elsewhere). Tasks in a phase are run concurrently, with no ordering assumed.Adding a task to a phase does not remove any other tasks from the phase.
If the same task is added multiple times, each addition will be run unless cancelled.
Tasks should typically be registered as early as possible -- once coordinated shutdown begins, tasks may be added without ever being run. A task may add tasks to a later stage with confidence that they will be run.
-
addCancellableTask
public Cancellable addCancellableTask(java.lang.String phase, java.lang.String taskName, java.util.function.Supplier<java.util.concurrent.CompletionStage<Done>> task)
Java API: Add a task to a phase, returning an object which will cancel it on demand and remove it from the task pool (so long as the same task has not been added elsewhere). Tasks in a phase are run concurrently, with no ordering assumed.Adding a task to a phase does not remove any other tasks from the phase.
If the same task is added multiple times, each addition will be run unless cancelled.
Tasks should typically be registered as early as possible -- once coordinated shutdown begins, tasks may be added without ever being run. A task may add tasks to a later stage with confidence that they will be run.
-
addTask
public void addTask(java.lang.String phase, java.lang.String taskName, scala.Function0<scala.concurrent.Future<Done>> task)Scala API: Add a task to a phase. It doesn't remove previously added tasks. Tasks added to the same phase are executed in parallel without any ordering assumptions. Next phase will not start until all tasks of previous phase have been completed.Tasks should typically be registered as early as possible after system startup. When running the coordinated shutdown tasks that have been registered will be performed but tasks that are added too late will not be run. It is possible to add a task to a later phase by a task in an earlier phase and it will be performed.
-
addTask
public void addTask(java.lang.String phase, java.lang.String taskName, java.util.function.Supplier<java.util.concurrent.CompletionStage<Done>> task)Java API: Add a task to a phase. It doesn't remove previously added tasks. Tasks added to the same phase are executed in parallel without any ordering assumptions. Next phase will not start until all tasks of previous phase have been completed.Tasks should typically be registered as early as possible after system startup. When running the coordinated shutdown tasks that have been registered will be performed but tasks that are added too late will not be run. It is possible to add a task to a later phase by a task in an earlier phase and it will be performed.
-
addActorTerminationTask
public void addActorTerminationTask(java.lang.String phase, java.lang.String taskName, ActorRef actor, scala.Option<java.lang.Object> stopMsg)Scala API: Add an actor termination task to a phase. It doesn't remove previously added tasks. Tasks added to the same phase are executed in parallel without any ordering assumptions. Next phase will not start until all tasks of previous phase have been completed.When executed, this task will first send the given stop message, if defined, to the actor, then it will watch the actor, and complete when the actor terminates.
Tasks should typically be registered as early as possible after system startup. When running the coordinated shutdown tasks that have been registered will be performed but tasks that are added too late will not be run. It is possible to add a task to a later phase by a task in an earlier phase and it will be performed.
-
addActorTerminationTask
public void addActorTerminationTask(java.lang.String phase, java.lang.String taskName, ActorRef actor, java.util.Optional<java.lang.Object> stopMsg)Java API: Add an actor termination task to a phase. It doesn't remove previously added tasks. Tasks added to the same phase are executed in parallel without any ordering assumptions. Next phase will not start until all tasks of previous phase have been completed.When executed, this task will first send the given stop message, if defined, to the actor, then it will watch the actor, and complete when the actor terminates.
Tasks should typically be registered as early as possible after system startup. When running the coordinated shutdown tasks that have been registered will be performed but tasks that are added too late will not be run. It is possible to add a task to a later phase by a task in an earlier phase and it will be performed.
-
shutdownReason
public scala.Option<CoordinatedShutdown.Reason> shutdownReason()
TheReasonfor the shutdown as passed to therunmethod.Noneif the shutdown has not been started.
-
getShutdownReason
public java.util.Optional<CoordinatedShutdown.Reason> getShutdownReason()
TheReasonfor the shutdown as passed to therunmethod.Optional.emptyif the shutdown has not been started.
-
run
public scala.concurrent.Future<Done> run(CoordinatedShutdown.Reason reason)
Scala API: Run tasks of all phases. The returnedFutureis completed when all tasks have been completed, or there is a failure when recovery is disabled.It's safe to call this method multiple times. It will only run the shutdown sequence once.
-
runAll
public java.util.concurrent.CompletionStage<Done> runAll(CoordinatedShutdown.Reason reason)
Java API: Run tasks of all phases. The returnedCompletionStageis completed when all tasks have been completed, or there is a failure when recovery is disabled.It's safe to call this method multiple times. It will only run the shutdown sequence once.
-
run
public scala.concurrent.Future<Done> run(CoordinatedShutdown.Reason reason, scala.Option<java.lang.String> fromPhase)
Scala API: Run tasks of all phases including and after the given phase. The returnedFutureis completed when all such tasks have been completed, or there is a failure when recovery is disabled.It's safe to call this method multiple times. It will only run shutdown sequence once.
-
run
public java.util.concurrent.CompletionStage<Done> run(CoordinatedShutdown.Reason reason, java.util.Optional<java.lang.String> fromPhase)
Java API: Run tasks of all phases including and after the given phase. The returnedCompletionStageis completed when all such tasks have been completed, or there is a failure when recovery is disabled.It's safe to call this method multiple times. It will only run the shutdown sequence once.
-
timeout
public scala.concurrent.duration.FiniteDuration timeout(java.lang.String phase)
The configured timeout for a givenphase. For example useful as timeout when actoraskrequests is used as a task.
-
totalTimeout
public scala.concurrent.duration.FiniteDuration totalTimeout()
Sum of timeouts of all phases that have some task.
-
addJvmShutdownHook
public <T> void addJvmShutdownHook(scala.Function0<T> hook)
Scala API: Add a JVM shutdown hook that will be run when the JVM process begins its shutdown sequence. Added hooks may run in any order concurrently, but they are running before Akka internal shutdown hooks, e.g. those shutting down Artery.
-
addCancellableJvmShutdownHook
public <T> Cancellable addCancellableJvmShutdownHook(scala.Function0<T> hook)
Scala API: Add a JVM shutdown hook that will be run when the JVM process begins its shutdown sequence. Added hooks may run in any order concurrently, but they are running before Akka internal shutdown hooks, e.g. those shutting down Artery.The returned
Cancellablemakes it possible to de-register the hook. For example on actor system shutdown to avoid leaking references to the actor system in tests.For shutdown hooks that does not have any requirements on running before the Akka shutdown hooks the standard library JVM shutdown hooks APIs are better suited.
-
addJvmShutdownHook
public void addJvmShutdownHook(java.lang.Runnable hook)
Java API: Add a JVM shutdown hook that will be run when the JVM process begins its shutdown sequence. Added hooks may run in any order concurrently, but they are running before Akka internal shutdown hooks, e.g. those shutting down Artery.
-
addCancellableJvmShutdownHook
public Cancellable addCancellableJvmShutdownHook(java.lang.Runnable hook)
Java API: Add a JVM shutdown hook that will be run when the JVM process begins its shutdown sequence. Added hooks may run in an order concurrently, but they are running before Akka internal shutdown hooks, e.g. those shutting down Artery.The returned
Cancellablemakes it possible to de-register the hook. For example on actor system shutdown to avoid leaking references to the actor system in tests.For shutdown hooks that does not have any requirements on running before the Akka shutdown hooks the standard library JVM shutdown hooks APIs are better suited.
-
-