public class InstrumentedExecutorService
extends java.lang.Object
implements java.util.concurrent.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(java.util.concurrent.ExecutorService delegate,
MetricRegistry registry)
Wraps an
ExecutorService uses an auto-generated default name. |
InstrumentedExecutorService(java.util.concurrent.ExecutorService delegate,
MetricRegistry registry,
java.lang.String name)
Wraps an
ExecutorService with an explicit name. |
Modifier and Type | Method and Description |
---|---|
boolean |
awaitTermination(long l,
java.util.concurrent.TimeUnit timeUnit) |
void |
execute(java.lang.Runnable runnable) |
<T> java.util.List<java.util.concurrent.Future<T>> |
invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks) |
<T> java.util.List<java.util.concurrent.Future<T>> |
invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
long timeout,
java.util.concurrent.TimeUnit unit) |
<T> T |
invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks) |
<T> T |
invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks,
long timeout,
java.util.concurrent.TimeUnit unit) |
boolean |
isShutdown() |
boolean |
isTerminated() |
void |
shutdown() |
java.util.List<java.lang.Runnable> |
shutdownNow() |
<T> java.util.concurrent.Future<T> |
submit(java.util.concurrent.Callable<T> task) |
java.util.concurrent.Future<?> |
submit(java.lang.Runnable runnable) |
<T> java.util.concurrent.Future<T> |
submit(java.lang.Runnable runnable,
T result) |
public InstrumentedExecutorService(java.util.concurrent.ExecutorService delegate, MetricRegistry registry)
ExecutorService
uses an auto-generated default name.delegate
- ExecutorService
to wrap.registry
- MetricRegistry
that will contain the metrics.public InstrumentedExecutorService(java.util.concurrent.ExecutorService delegate, MetricRegistry registry, java.lang.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 void execute(java.lang.Runnable runnable)
execute
in interface java.util.concurrent.Executor
public java.util.concurrent.Future<?> submit(java.lang.Runnable runnable)
submit
in interface java.util.concurrent.ExecutorService
public <T> java.util.concurrent.Future<T> submit(java.lang.Runnable runnable, T result)
submit
in interface java.util.concurrent.ExecutorService
public <T> java.util.concurrent.Future<T> submit(java.util.concurrent.Callable<T> task)
submit
in interface java.util.concurrent.ExecutorService
public <T> java.util.List<java.util.concurrent.Future<T>> invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks) throws java.lang.InterruptedException
invokeAll
in interface java.util.concurrent.ExecutorService
java.lang.InterruptedException
public <T> java.util.List<java.util.concurrent.Future<T>> invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks, long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
invokeAll
in interface java.util.concurrent.ExecutorService
java.lang.InterruptedException
public <T> T invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks) throws java.util.concurrent.ExecutionException, java.lang.InterruptedException
invokeAny
in interface java.util.concurrent.ExecutorService
java.util.concurrent.ExecutionException
java.lang.InterruptedException
public <T> T invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks, long timeout, java.util.concurrent.TimeUnit unit) throws java.util.concurrent.ExecutionException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
invokeAny
in interface java.util.concurrent.ExecutorService
java.util.concurrent.ExecutionException
java.lang.InterruptedException
java.util.concurrent.TimeoutException
public void shutdown()
shutdown
in interface java.util.concurrent.ExecutorService
public java.util.List<java.lang.Runnable> shutdownNow()
shutdownNow
in interface java.util.concurrent.ExecutorService
public boolean isShutdown()
isShutdown
in interface java.util.concurrent.ExecutorService
public boolean isTerminated()
isTerminated
in interface java.util.concurrent.ExecutorService
public boolean awaitTermination(long l, java.util.concurrent.TimeUnit timeUnit) throws java.lang.InterruptedException
awaitTermination
in interface java.util.concurrent.ExecutorService
java.lang.InterruptedException
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"