Class StartupProcess<CONTEXT>
java.lang.Object
io.camunda.zeebe.scheduler.startup.StartupProcess<CONTEXT>
- Type Parameters:
CONTEXT- the startup/shutdown context
Executes a number of steps in a startup/shutdown process.
On startup, steps are executed in the given order. If any step completes exceptionally, then the subsequent steps are not executed and the startup future completes exceptionally. However, no shutdown is triggered by this class. This can be done by the caller.
On shutdown, steps are executed in reverse order. If any shutdown step completes exceptionally, subsequent steps will be executed and the exceptions of all steps are collected as suppressed exceptions
Error handling
- Exceptions that occur during startup/shutdown are propagated via the
ActorFuture. They are also wrapped. - If the exceptions is related to a certain step, it is wrapped in a
StartupProcessStepException, which is then added as suppressed exception to aStartupProcessException, which is returned by the future - If the exception is not related to a step (e.g. startup is aborted due to concurrent
shutdown), this is propagated as a plain
StartupProcessException - IllegalStateExceptions are not propagated via the future but thrown directly to the caller
Callers of this class must obey the following contract:
- Shutdown must not be called before startup
- Startup must be called at most once
- Shutdown may be called more than once. The first call will trigger the shutdown and any subsequent calls do nothing
- Shutdown may be called before the future of startup has completed. In that case, it will complete the current running startup step, cancel all subsequent startup step, complete the startup future with an exception and start the shutdown from the step that last completed
-
Constructor Summary
ConstructorsConstructorDescriptionStartupProcess(List<StartupStep<CONTEXT>> steps) Constructs the startup processStartupProcess(org.slf4j.Logger logger, List<? extends StartupStep<CONTEXT>> steps) Constructs the startup process -
Method Summary
Modifier and TypeMethodDescriptionshutdown(ConcurrencyControl concurrencyControl, CONTEXT context) Executes the shutdown logicstartup(ConcurrencyControl concurrencyControl, CONTEXT context) Executes the startup logic
-
Constructor Details
-
StartupProcess
Constructs the startup process- Parameters:
steps- the steps to execute; must not benull
-
StartupProcess
Constructs the startup process- Parameters:
logger- the logger to use for messages related to the startup process; must not benullsteps- the steps to execute; must not benull
-
-
Method Details
-
startup
Executes the startup logic- Parameters:
concurrencyControl- the startup context at the start of this stepcontext- the startup context at the start of this step- Returns:
- future with startup context at the end of this step
-
shutdown
Executes the shutdown logic- Parameters:
context- the shutdown context at the start of this step- Returns:
- future with the shutdown context at the end of this step.
-