public class InstrumentedExecutorService extends Object implements ExecutorService
ExecutorService 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 |
|---|
InstrumentedExecutorService(ExecutorService delegate,
MetricRegistry registry)
Wraps an
ExecutorService uses an auto-generated default name. |
InstrumentedExecutorService(ExecutorService delegate,
MetricRegistry registry,
String name)
Wraps an
ExecutorService with an explicit name. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(long l,
TimeUnit timeUnit) |
void |
execute(Runnable runnable) |
<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() |
void |
shutdown() |
List<Runnable> |
shutdownNow() |
<T> Future<T> |
submit(Callable<T> task) |
Future<?> |
submit(Runnable runnable) |
<T> Future<T> |
submit(Runnable runnable,
T result) |
public InstrumentedExecutorService(ExecutorService delegate, MetricRegistry registry)
ExecutorService uses an auto-generated default name.delegate - ExecutorService to wrap.registry - MetricRegistry that will contain the metrics.public InstrumentedExecutorService(ExecutorService delegate, MetricRegistry registry, String name)
ExecutorService with an explicit name.delegate - ExecutorService to wrap.registry - MetricRegistry that will contain the metrics.name - name for this executor service.public Future<?> submit(Runnable runnable)
submit in interface ExecutorServicepublic <T> Future<T> submit(Runnable runnable, T result)
submit in interface ExecutorServicepublic <T> Future<T> submit(Callable<T> task)
submit in interface ExecutorServicepublic <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException
invokeAll in interface ExecutorServiceInterruptedExceptionpublic <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException
invokeAll in interface ExecutorServiceInterruptedExceptionpublic <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws ExecutionException, InterruptedException
invokeAny in interface ExecutorServiceExecutionExceptionInterruptedExceptionpublic <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws ExecutionException, InterruptedException, TimeoutException
invokeAny in interface ExecutorServiceExecutionExceptionInterruptedExceptionTimeoutExceptionpublic void shutdown()
shutdown in interface ExecutorServicepublic List<Runnable> shutdownNow()
shutdownNow in interface ExecutorServicepublic boolean isShutdown()
isShutdown in interface ExecutorServicepublic boolean isTerminated()
isTerminated in interface ExecutorServicepublic boolean awaitTermination(long l,
TimeUnit timeUnit)
throws InterruptedException
awaitTermination in interface ExecutorServiceInterruptedExceptionCopyright © 2019. All Rights Reserved.