类 GracefulExecutorServicesShutdown
java.lang.Object
org.apache.pulsar.common.util.GracefulExecutorServicesShutdown
This a builder like class for providing a fluent API for graceful shutdown
Executors are added with the
shutdown(ExecutorService...)
method. The ExecutorService.shutdown() method is called immediately.
Calling the handle() method returns a future which completes when all executors
have been terminated.
The executors will waited for completion with the ExecutorService.awaitTermination(long, TimeUnit) method.
If the shutdown times out or the future is cancelled, all executors will be terminated and the termination
timeout value will be used for waiting for termination.
The default value for termination timeout is 10% of the shutdown timeout.-
方法概要
修饰符和类型方法说明handle()Starts the handler for polling frequently for the completed termination of enlisted executors.initiate()Initiates a new shutdown for one or manyExecutorServices.shutdown(ExecutorService... executorServices) CallsExecutorService.shutdown()and enlists the executor as part of the shutdown handling.terminationTimeout(Duration terminationTimeout) Sets the timeout for waiting for executors to complete in forceful termination.Sets the timeout for graceful shutdown.
-
方法详细资料
-
initiate
Initiates a new shutdown for one or manyExecutorServices.- 返回:
- a new instance for controlling graceful shutdown
-
shutdown
CallsExecutorService.shutdown()and enlists the executor as part of the shutdown handling.- 参数:
executorServices- one or many executors to shutdown- 返回:
- the current instance for controlling graceful shutdown
-
timeout
Sets the timeout for graceful shutdown.- 参数:
timeout- duration for the timeout- 返回:
- the current instance for controlling graceful shutdown
-
terminationTimeout
Sets the timeout for waiting for executors to complete in forceful termination.- 参数:
terminationTimeout- duration for the timeout- 返回:
- the current instance for controlling graceful shutdown
-
handle
Starts the handler for polling frequently for the completed termination of enlisted executors. If the termination times out or the future is cancelled, all active executors will be forcefully terminated by callingExecutorService.shutdownNow().- 返回:
- a future which completes when all executors have terminated
-