public class InstrumentedScheduledExecutorService extends Object implements ScheduledExecutorService
ScheduledExecutorService that monitors the number of tasks submitted, running,
completed and also keeps a Timer for the task duration.
It will register the metrics using the given (or auto-generated) name as classifier, e.g:
"your-executor-service.submitted", "your-executor-service.running", etc.| Constructor and Description |
|---|
InstrumentedScheduledExecutorService(ScheduledExecutorService delegate,
MetricRegistry registry)
Wraps an
ScheduledExecutorService uses an auto-generated default name. |
InstrumentedScheduledExecutorService(ScheduledExecutorService delegate,
MetricRegistry registry,
String name)
Wraps an
ScheduledExecutorService with an explicit name. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long timeout,
TimeUnit unit) |
void |
execute(Runnable command) |
<T> List<Future<T>> |
invokeAll(Collection<? extends Callable<T>> tasks) |
<T> List<Future<T>> |
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 |
isShutdown() |
boolean |
isTerminated() |
<V> ScheduledFuture<V> |
schedule(Callable<V> callable,
long delay,
TimeUnit unit) |
ScheduledFuture<?> |
schedule(Runnable command,
long delay,
TimeUnit unit) |
ScheduledFuture<?> |
scheduleAtFixedRate(Runnable command,
long initialDelay,
long period,
TimeUnit unit) |
ScheduledFuture<?> |
scheduleWithFixedDelay(Runnable command,
long initialDelay,
long delay,
TimeUnit unit) |
void |
shutdown() |
List<Runnable> |
shutdownNow() |
<T> Future<T> |
submit(Callable<T> task) |
Future<?> |
submit(Runnable task) |
<T> Future<T> |
submit(Runnable task,
T result) |
public InstrumentedScheduledExecutorService(ScheduledExecutorService delegate, MetricRegistry registry)
ScheduledExecutorService uses an auto-generated default name.delegate - ScheduledExecutorService to wrap.registry - MetricRegistry that will contain the metrics.public InstrumentedScheduledExecutorService(ScheduledExecutorService delegate, MetricRegistry registry, String name)
ScheduledExecutorService with an explicit name.delegate - ScheduledExecutorService to wrap.registry - MetricRegistry that will contain the metrics.name - name for this executor service.@Nonnull public ScheduledFuture<?> schedule(@Nonnull Runnable command, long delay, @Nonnull TimeUnit unit)
schedule in interface ScheduledExecutorService@Nonnull public <V> ScheduledFuture<V> schedule(@Nonnull Callable<V> callable, long delay, @Nonnull TimeUnit unit)
schedule in interface ScheduledExecutorService@Nonnull public ScheduledFuture<?> scheduleAtFixedRate(@Nonnull Runnable command, long initialDelay, long period, @Nonnull TimeUnit unit)
scheduleAtFixedRate in interface ScheduledExecutorService@Nonnull public ScheduledFuture<?> scheduleWithFixedDelay(@Nonnull Runnable command, long initialDelay, long delay, @Nonnull TimeUnit unit)
scheduleWithFixedDelay in interface ScheduledExecutorServicepublic void shutdown()
shutdown in interface ExecutorService@Nonnull public List<Runnable> shutdownNow()
shutdownNow in interface ExecutorServicepublic boolean isShutdown()
isShutdown in interface ExecutorServicepublic boolean isTerminated()
isTerminated in interface ExecutorServicepublic boolean awaitTermination(long timeout,
@Nonnull
TimeUnit unit)
throws InterruptedException
awaitTermination in interface ExecutorServiceInterruptedException@Nonnull public <T> Future<T> submit(@Nonnull Callable<T> task)
submit in interface ExecutorService@Nonnull public <T> Future<T> submit(@Nonnull Runnable task, T result)
submit in interface ExecutorService@Nonnull public Future<?> submit(@Nonnull Runnable task)
submit in interface ExecutorService@Nonnull public <T> List<Future<T>> invokeAll(@Nonnull Collection<? extends Callable<T>> tasks) throws InterruptedException
invokeAll in interface ExecutorServiceInterruptedException@Nonnull public <T> List<Future<T>> invokeAll(@Nonnull Collection<? extends Callable<T>> tasks, long timeout, @Nonnull TimeUnit unit) throws InterruptedException
invokeAll in interface ExecutorServiceInterruptedException@Nonnull public <T> T invokeAny(@Nonnull Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException
invokeAny in interface ExecutorServiceInterruptedExceptionExecutionExceptionpublic <T> T invokeAny(@Nonnull Collection<? extends Callable<T>> tasks, long timeout, @Nonnull TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
invokeAny in interface ExecutorServiceInterruptedExceptionExecutionExceptionTimeoutExceptionCopyright © 2021. All rights reserved.