Class MonitoredScheduledThreadPoolExecutor
- All Implemented Interfaces:
AdvancedScheduledExecutorService
,Executor
,ExecutorService
,ScheduledExecutorService
-
Constructor Summary
ConstructorsConstructorDescriptionMonitoredScheduledThreadPoolExecutor
(MetricsService metricsService, AdvancedScheduledExecutorService delegate) -
Method Summary
Modifier and TypeMethodDescriptionboolean
awaitTermination
(long timeout, TimeUnit unit) void
invokeAll
(Collection<? extends Callable<T>> tasks) invokeAll
(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) <T> T
invokeAny
(Collection<? extends Callable<T>> tasks) <T> T
invokeAny
(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) boolean
boolean
<V> ScheduledFuture<V>
scheduleAdvanced
(Runnable command, ScheduleConfig<?> config) Submits an action with advanced config that becomes enabled first after the given initial delay, and subsequently with the given period or with given time after previous execution.<T> ScheduledFuture<T>
scheduleAdvanced
(Callable<T> command, ScheduleConfig<T> config) Submits an action with advanced config that becomes enabled first after the given initial delay, and subsequently with the given period or with given time after previous execution.scheduleAtFixedRate
(Runnable command, long initialDelay, long period, TimeUnit unit) scheduleWithFixedDelay
(Runnable command, long initialDelay, long delay, TimeUnit unit) void
shutdown()
Future<?>
<T> Future<T>
<T> Future<T>
-
Constructor Details
-
MonitoredScheduledThreadPoolExecutor
MonitoredScheduledThreadPoolExecutor(MetricsService metricsService, AdvancedScheduledExecutorService delegate)
-
-
Method Details
-
scheduleAdvanced
Description copied from interface:AdvancedScheduledExecutorService
Submits an action with advanced config that becomes enabled first after the given initial delay, and subsequently with the given period or with given time after previous execution. Repeats count may be limited if provided such information in config.The sequence of task executions continues indefinitely until one of the following completions occur:
- Repeat count are reached
- Condition of specified predicate for cancellation was met
- The task is explicitly cancelled via the returned future.
- The executor terminates, also resulting in task cancellation.
- An execution of the task throws an exception. In this case
calling
get
on the returned future will throwExecutionException
, holding the exception as its cause.
isDone()
on the returned future will returntrue
.If any execution of this task takes longer than its period, then subsequent executions may start late, but will not concurrently execute.
If task is not executed due to provided in config predicate, then repeat count does not go up. Repeats are only counted for execution that took place. So if task is specified to repeat 5 time, it will be run 5 times. For example: if task is scheduled to repeat each 10 second 5 times, and will execute 3 times, then execution predicate will prevent it from execution for 1h. The remaining 2 times will be executed after this 1h.
- Specified by:
scheduleAdvanced
in interfaceAdvancedScheduledExecutorService
- Parameters:
command
- the task to executeconfig
- the config of task- Returns:
- a ScheduledFuture representing pending completion of
the series of repeated tasks. The future's
get()
method will never return normally, and will throw an exception upon task cancellation or abnormal termination of a task execution.
-
scheduleAdvanced
Description copied from interface:AdvancedScheduledExecutorService
Submits an action with advanced config that becomes enabled first after the given initial delay, and subsequently with the given period or with given time after previous execution. Repeats count may be limited if provided such information in config.The sequence of task executions continues indefinitely until one of the following completions occur:
- Repeat count are reached
- Condition of specified predicate for cancellation was met
- The task is explicitly cancelled via the returned future.
- The executor terminates, also resulting in task cancellation.
- An execution of the task throws an exception. In this case
calling
get
on the returned future will throwExecutionException
, holding the exception as its cause.
isDone()
on the returned future will returntrue
.If any execution of this task takes longer than its period, then subsequent executions may start late, but will not concurrently execute.
If task is not executed due to provided in config predicate, then repeat count does not go up. Repeats are only counted for execution that took place. So if task is specified to repeat 5 time, it will be run 5 times. For example: if task is scheduled to repeat each 10 second 5 times, and will execute 3 times, then execution predicate will prevent it from execution for 1h. The remaining 2 times will be executed after this 1h.
- Specified by:
scheduleAdvanced
in interfaceAdvancedScheduledExecutorService
- Parameters:
command
- the task to executeconfig
- the config of task- Returns:
- a ScheduledFuture representing pending completion of
the series of repeated tasks. The future's
get()
method will never return normally, and will throw an exception upon task cancellation or abnormal termination of a task execution.
-
schedule
- Specified by:
schedule
in interfaceScheduledExecutorService
-
schedule
- Specified by:
schedule
in interfaceScheduledExecutorService
-
scheduleAtFixedRate
public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) - Specified by:
scheduleAtFixedRate
in interfaceScheduledExecutorService
-
scheduleWithFixedDelay
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) - Specified by:
scheduleWithFixedDelay
in interfaceScheduledExecutorService
-
invokeAll
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException - Specified by:
invokeAll
in interfaceExecutorService
- Throws:
InterruptedException
-
invokeAll
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException - Specified by:
invokeAll
in interfaceExecutorService
- Throws:
InterruptedException
-
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException - Specified by:
invokeAny
in interfaceExecutorService
- Throws:
InterruptedException
ExecutionException
-
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException - Specified by:
invokeAny
in interfaceExecutorService
- Throws:
InterruptedException
ExecutionException
TimeoutException
-
execute
-
shutdown
public void shutdown()- Specified by:
shutdown
in interfaceExecutorService
-
shutdownNow
- Specified by:
shutdownNow
in interfaceExecutorService
-
isShutdown
public boolean isShutdown()- Specified by:
isShutdown
in interfaceExecutorService
-
isTerminated
public boolean isTerminated()- Specified by:
isTerminated
in interfaceExecutorService
-
awaitTermination
- Specified by:
awaitTermination
in interfaceExecutorService
- Throws:
InterruptedException
-
submit
- Specified by:
submit
in interfaceExecutorService
-
submit
- Specified by:
submit
in interfaceExecutorService
-
submit
- Specified by:
submit
in interfaceExecutorService
-