Package io.dropwizard.metrics5
Class InstrumentedExecutorService
- java.lang.Object
-
- io.dropwizard.metrics5.InstrumentedExecutorService
-
- All Implemented Interfaces:
Executor,ExecutorService
public class InstrumentedExecutorService extends Object implements ExecutorService
AnExecutorServicethat monitors the number of tasks submitted, running, completed and also keeps aTimerfor 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 Summary
Constructors Constructor Description InstrumentedExecutorService(ExecutorService delegate, MetricRegistry registry)Wraps anExecutorServiceuses an auto-generated default name.InstrumentedExecutorService(ExecutorService delegate, MetricRegistry registry, String name)Wraps anExecutorServicewith an explicit name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanawaitTermination(long l, TimeUnit timeUnit)voidexecute(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> TinvokeAny(Collection<? extends Callable<T>> tasks)<T> TinvokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit)booleanisShutdown()booleanisTerminated()voidshutdown()List<Runnable>shutdownNow()Future<?>submit(Runnable runnable)<T> Future<T>submit(Runnable runnable, T result)<T> Future<T>submit(Callable<T> task)
-
-
-
Constructor Detail
-
InstrumentedExecutorService
public InstrumentedExecutorService(ExecutorService delegate, MetricRegistry registry)
Wraps anExecutorServiceuses an auto-generated default name.- Parameters:
delegate-ExecutorServiceto wrap.registry-MetricRegistrythat will contain the metrics.
-
InstrumentedExecutorService
public InstrumentedExecutorService(ExecutorService delegate, MetricRegistry registry, String name)
Wraps anExecutorServicewith an explicit name.- Parameters:
delegate-ExecutorServiceto wrap.registry-MetricRegistrythat will contain the metrics.name- name for this executor service.
-
-
Method Detail
-
submit
public Future<?> submit(Runnable runnable)
- Specified by:
submitin interfaceExecutorService
-
submit
public <T> Future<T> submit(Runnable runnable, T result)
- Specified by:
submitin interfaceExecutorService
-
submit
public <T> Future<T> submit(Callable<T> task)
- Specified by:
submitin interfaceExecutorService
-
invokeAll
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException
- Specified by:
invokeAllin interfaceExecutorService- Throws:
InterruptedException
-
invokeAll
public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException
- Specified by:
invokeAllin interfaceExecutorService- Throws:
InterruptedException
-
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws ExecutionException, InterruptedException
- Specified by:
invokeAnyin interfaceExecutorService- Throws:
ExecutionExceptionInterruptedException
-
invokeAny
public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws ExecutionException, InterruptedException, TimeoutException
- Specified by:
invokeAnyin interfaceExecutorService- Throws:
ExecutionExceptionInterruptedExceptionTimeoutException
-
shutdown
public void shutdown()
- Specified by:
shutdownin interfaceExecutorService
-
shutdownNow
public List<Runnable> shutdownNow()
- Specified by:
shutdownNowin interfaceExecutorService
-
isShutdown
public boolean isShutdown()
- Specified by:
isShutdownin interfaceExecutorService
-
isTerminated
public boolean isTerminated()
- Specified by:
isTerminatedin interfaceExecutorService
-
awaitTermination
public boolean awaitTermination(long l, TimeUnit timeUnit) throws InterruptedException- Specified by:
awaitTerminationin interfaceExecutorService- Throws:
InterruptedException
-
-