Class ExecutorShutdownController
java.lang.Object
ch.raffael.meldioc.library.base.lifecycle.ExecutorShutdownController
- All Implemented Interfaces:
ShutdownController,ShutdownController.Actuator
public class ExecutorShutdownController
extends Object
implements ShutdownController, ShutdownController.Actuator
A shutdown controller that allows to parallelize the shutdown.
The prepare and perform callbacks are called in parallel, but not overlapping (i.e. peform callbacks will only be called after all prepare callbacks are finished.
The finalize callback will be called serially the thread initiating the shutdown (finalizing the shutdown usually includes to destroying the work thread pool).
-
Nested Class Summary
Nested classes/interfaces inherited from interface ch.raffael.meldioc.library.base.lifecycle.ShutdownController
ShutdownController.Actuator, ShutdownController.IllegalShutdownStateException, ShutdownController.State, ShutdownController.Wrapper -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionactuator()void<T> TgetPreventingShutdown(Supplier<T> supplier) Run an action that prevents a shutdown being performed while running.protected voidvoidonFinalize(io.vavr.CheckedRunnable callback) voidonPerform(io.vavr.CheckedRunnable callback) voidonPrepare(io.vavr.CheckedRunnable callback) protected voidonShutdownComplete(io.vavr.collection.Seq<Throwable> exceptions) io.vavr.collection.Seq<Throwable>state()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ch.raffael.meldioc.library.base.lifecycle.ShutdownController.Actuator
runPreventingShutdown
-
Constructor Details
-
ExecutorShutdownController
-
-
Method Details
-
onPrepare
public void onPrepare(io.vavr.CheckedRunnable callback) - Specified by:
onPreparein interfaceShutdownController
-
onPerform
public void onPerform(io.vavr.CheckedRunnable callback) - Specified by:
onPerformin interfaceShutdownController
-
onFinalize
public void onFinalize(io.vavr.CheckedRunnable callback) - Specified by:
onFinalizein interfaceShutdownController
-
controller
- Specified by:
controllerin interfaceShutdownController.Actuator
-
state
- Specified by:
statein interfaceShutdownController- Specified by:
statein interfaceShutdownController.Actuator
-
actuator
-
getPreventingShutdown
Description copied from interface:ShutdownController.ActuatorRun an action that prevents a shutdown being performed while running.- Specified by:
getPreventingShutdownin interfaceShutdownController.Actuator
-
announceShutdown
public void announceShutdown()- Specified by:
announceShutdownin interfaceShutdownController.Actuator
-
performShutdown
- Specified by:
performShutdownin interfaceShutdownController.Actuator- Throws:
InterruptedException
-
onShutdownComplete
-
onDoShutdown
protected void onDoShutdown()
-