Class CoordinatedShutdown
- java.lang.Object
-
- akka.actor.CoordinatedShutdown
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CoordinatedShutdown.ClusterDowningReason$
Scala API: The shutdown was initiated by Cluster downing.static class
CoordinatedShutdown.ClusterJoinUnsuccessfulReason$
Scala API: The shutdown was initiated by a failure to join a seed node.static class
CoordinatedShutdown.ClusterLeavingReason$
Scala API: The shutdown was initiated by Cluster leaving.static class
CoordinatedShutdown.IncompatibleConfigurationDetectedReason$
Scala API: The shutdown was initiated by a configuration clash within the existing cluster and the joining nodestatic class
CoordinatedShutdown.JvmExitReason$
Scala API: The shutdown was initiated by a JVM shutdown hook, e.g.static class
CoordinatedShutdown.Phase
INTERNAL APIstatic class
CoordinatedShutdown.Phase$
static interface
CoordinatedShutdown.Reason
Reason for the shutdown, which can be used by tasks in case they need to do different things depending on what caused the shutdown.static class
CoordinatedShutdown.UnknownReason$
-
Constructor Summary
Constructors Constructor Description CoordinatedShutdown(ExtendedActorSystem system, scala.collection.immutable.Map<java.lang.String,CoordinatedShutdown.Phase> phases)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description 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.<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.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.<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.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.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.static T
apply(ActorSystem system)
static T
apply(ClassicActorSystemProvider system)
static CoordinatedShutdown.Reason
clusterDowningReason()
static CoordinatedShutdown.Reason
clusterJoinUnsuccessfulReason()
static CoordinatedShutdown.Reason
clusterLeavingReason()
static com.typesafe.config.Config
confWithOverrides(com.typesafe.config.Config conf, scala.Option<CoordinatedShutdown.Reason> reason)
static CoordinatedShutdown
createExtension(ExtendedActorSystem system)
static boolean
equals(java.lang.Object other)
static CoordinatedShutdown
get(ActorSystem system)
static CoordinatedShutdown
get(ClassicActorSystemProvider system)
java.util.Optional<CoordinatedShutdown.Reason>
getShutdownReason()
TheReason
for the shutdown as passed to therun
method.static int
hashCode()
static CoordinatedShutdown.Reason
incompatibleConfigurationDetectedReason()
static CoordinatedShutdown.Reason
jvmExitReason()
java.util.concurrent.CountDownLatch
jvmHooksLatch()
INTERNAL APILoggingAdapter
log()
static CoordinatedShutdown$
lookup()
scala.collection.immutable.List<java.lang.String>
orderedPhases()
INTERNAL APIstatic java.lang.String
PhaseActorSystemTerminate()
Last phase.static java.lang.String
PhaseBeforeActorSystemTerminate()
Phase for custom application tasks that are to be run after cluster shutdown and before ActorSystem termination.static java.lang.String
PhaseBeforeClusterShutdown()
Phase for custom application tasks that are to be run after service shutdown and before cluster shutdown.static java.lang.String
PhaseBeforeServiceUnbind()
static java.lang.String
PhaseClusterExiting()
Shutdown cluster singletonsstatic java.lang.String
PhaseClusterExitingDone()
Wait until exiting has been completedstatic java.lang.String
PhaseClusterLeave()
Emit the leave command for the node that is shutting down.static java.lang.String
PhaseClusterShardingShutdownRegion()
Graceful shutdown of the Cluster Sharding regions.static java.lang.String
PhaseClusterShutdown()
Shutdown the cluster extensionstatic java.lang.String
PhaseServiceRequestsDone()
Wait for requests that are in progress to be completed.static java.lang.String
PhaseServiceStop()
Final shutdown of service endpoints.static java.lang.String
PhaseServiceUnbind()
Stop accepting new incoming requests in for example HTTP.static scala.collection.immutable.Map<java.lang.String,CoordinatedShutdown.Phase>
phasesFromConfig(com.typesafe.config.Config conf)
scala.concurrent.Future<Done>
run()
Deprecated.Use the method with `reason` parameter instead.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>
run(java.util.Optional<java.lang.String> fromPhase)
Deprecated.Use the method with `reason` parameter instead.scala.concurrent.Future<Done>
run(scala.Option<java.lang.String> fromPhase)
Deprecated.Use the method with `reason` parameter instead.java.util.concurrent.CompletionStage<Done>
runAll()
Deprecated.Use the method with `reason` parameter instead.java.util.concurrent.CompletionStage<Done>
runAll(CoordinatedShutdown.Reason reason)
Java API: Run tasks of all phases.scala.Option<CoordinatedShutdown.Reason>
shutdownReason()
TheReason
for the shutdown as passed to therun
method.scala.concurrent.duration.FiniteDuration
timeout(java.lang.String phase)
The configured timeout for a givenphase
.static scala.collection.immutable.List<java.lang.String>
topologicalSort(scala.collection.immutable.Map<java.lang.String,CoordinatedShutdown.Phase> phases)
INTERNAL API: https://en.wikipedia.org/wiki/Topological_sortingscala.concurrent.duration.FiniteDuration
totalTimeout()
Sum of timeouts of all phases that have some task.static CoordinatedShutdown.Reason
unknownReason()
-
-
-
Constructor Detail
-
CoordinatedShutdown
public CoordinatedShutdown(ExtendedActorSystem system, scala.collection.immutable.Map<java.lang.String,CoordinatedShutdown.Phase> phases)
-
-
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.- Returns:
- (undocumented)
-
PhaseServiceRequestsDone
public static java.lang.String PhaseServiceRequestsDone()
Wait for requests that are in progress to be completed.- Returns:
- (undocumented)
-
PhaseServiceStop
public static java.lang.String PhaseServiceStop()
Final shutdown of service endpoints.- Returns:
- (undocumented)
-
PhaseBeforeClusterShutdown
public static java.lang.String PhaseBeforeClusterShutdown()
Phase for custom application tasks that are to be run after service shutdown and before cluster shutdown.- Returns:
- (undocumented)
-
PhaseClusterShardingShutdownRegion
public static java.lang.String PhaseClusterShardingShutdownRegion()
Graceful shutdown of the Cluster Sharding regions.- Returns:
- (undocumented)
-
PhaseClusterLeave
public static java.lang.String PhaseClusterLeave()
Emit the leave command for the node that is shutting down.- Returns:
- (undocumented)
-
PhaseClusterExiting
public static java.lang.String PhaseClusterExiting()
Shutdown cluster singletons- Returns:
- (undocumented)
-
PhaseClusterExitingDone
public static java.lang.String PhaseClusterExitingDone()
Wait until exiting has been completed- Returns:
- (undocumented)
-
PhaseClusterShutdown
public static java.lang.String PhaseClusterShutdown()
Shutdown the cluster extension- Returns:
- (undocumented)
-
PhaseBeforeActorSystemTerminate
public static java.lang.String PhaseBeforeActorSystemTerminate()
Phase for custom application tasks that are to be run after cluster shutdown and before ActorSystem termination.- Returns:
- (undocumented)
-
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.- Returns:
- (undocumented)
-
unknownReason
public static CoordinatedShutdown.Reason unknownReason()
-
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)
-
confWithOverrides
public static com.typesafe.config.Config confWithOverrides(com.typesafe.config.Config conf, scala.Option<CoordinatedShutdown.Reason> reason)
-
phasesFromConfig
public static scala.collection.immutable.Map<java.lang.String,CoordinatedShutdown.Phase> phasesFromConfig(com.typesafe.config.Config conf)
-
topologicalSort
public static scala.collection.immutable.List<java.lang.String> topologicalSort(scala.collection.immutable.Map<java.lang.String,CoordinatedShutdown.Phase> phases)
INTERNAL API: https://en.wikipedia.org/wiki/Topological_sorting- Parameters:
phases
- (undocumented)- Returns:
- (undocumented)
-
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)
-
log
public LoggingAdapter log()
-
orderedPhases
public scala.collection.immutable.List<java.lang.String> orderedPhases()
INTERNAL API
-
jvmHooksLatch
public java.util.concurrent.CountDownLatch jvmHooksLatch()
INTERNAL API- Returns:
- (undocumented)
-
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.
- Parameters:
phase
- (undocumented)taskName
- (undocumented)task
- (undocumented)
-
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.
- Parameters:
phase
- (undocumented)taskName
- (undocumented)task
- (undocumented)
-
shutdownReason
public scala.Option<CoordinatedShutdown.Reason> shutdownReason()
TheReason
for the shutdown as passed to therun
method.None
if the shutdown has not been started.- Returns:
- (undocumented)
-
getShutdownReason
public java.util.Optional<CoordinatedShutdown.Reason> getShutdownReason()
TheReason
for the shutdown as passed to therun
method.Optional.empty
if the shutdown has not been started.- Returns:
- (undocumented)
-
run
public scala.concurrent.Future<Done> run(CoordinatedShutdown.Reason reason)
Scala API: Run tasks of all phases. The returnedFuture
is 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.
- Parameters:
reason
- (undocumented)- Returns:
- (undocumented)
-
run
public scala.concurrent.Future<Done> run()
Deprecated.Use the method with `reason` parameter instead. Since 2.5.8.
-
runAll
public java.util.concurrent.CompletionStage<Done> runAll(CoordinatedShutdown.Reason reason)
Java API: Run tasks of all phases. The returnedCompletionStage
is 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.
- Parameters:
reason
- (undocumented)- Returns:
- (undocumented)
-
runAll
public java.util.concurrent.CompletionStage<Done> runAll()
Deprecated.Use the method with `reason` parameter instead. Since 2.5.8.
-
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 returnedFuture
is 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.
- Parameters:
reason
- (undocumented)fromPhase
- (undocumented)- Returns:
- (undocumented)
-
run
public scala.concurrent.Future<Done> run(scala.Option<java.lang.String> fromPhase)
Deprecated.Use the method with `reason` parameter instead. Since 2.5.8.
-
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 returnedCompletionStage
is 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.
- Parameters:
reason
- (undocumented)fromPhase
- (undocumented)- Returns:
- (undocumented)
-
run
public java.util.concurrent.CompletionStage<Done> run(java.util.Optional<java.lang.String> fromPhase)
Deprecated.Use the method with `reason` parameter instead. Since 2.5.8.
-
timeout
public scala.concurrent.duration.FiniteDuration timeout(java.lang.String phase)
The configured timeout for a givenphase
. For example useful as timeout when actorask
requests is used as a task.- Parameters:
phase
- (undocumented)- Returns:
- (undocumented)
-
totalTimeout
public scala.concurrent.duration.FiniteDuration totalTimeout()
Sum of timeouts of all phases that have some task.- Returns:
- (undocumented)
-
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.- Parameters:
hook
- (undocumented)
-
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
Cancellable
makes 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.
- Parameters:
hook
- (undocumented)- Returns:
- (undocumented)
-
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.- Parameters:
hook
- (undocumented)
-
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
Cancellable
makes 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.
- Parameters:
hook
- (undocumented)- Returns:
- (undocumented)
-
-