Package io.dropwizard.metrics5
Class InstrumentedExecutorService
java.lang.Object
io.dropwizard.metrics5.InstrumentedExecutorService
- All Implemented Interfaces:
Executor,ExecutorService
An
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 Summary
ConstructorsConstructorDescriptionInstrumentedExecutorService(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
Modifier and TypeMethodDescriptionbooleanawaitTermination(long l, TimeUnit timeUnit) voidinvokeAll(Collection<? extends Callable<T>> tasks) 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) booleanbooleanvoidshutdown()Future<?><T> Future<T><T> Future<T>
-
Constructor Details
-
InstrumentedExecutorService
Wraps anExecutorServiceuses an auto-generated default name.- Parameters:
delegate-ExecutorServiceto wrap.registry-MetricRegistrythat will contain the metrics.
-
InstrumentedExecutorService
Wraps anExecutorServicewith an explicit name.- Parameters:
delegate-ExecutorServiceto wrap.registry-MetricRegistrythat will contain the metrics.name- name for this executor service.
-
-
Method Details
-
execute
-
submit
- Specified by:
submitin interfaceExecutorService
-
submit
- Specified by:
submitin interfaceExecutorService
-
submit
- 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
- Specified by:
shutdownNowin interfaceExecutorService
-
isShutdown
public boolean isShutdown()- Specified by:
isShutdownin interfaceExecutorService
-
isTerminated
public boolean isTerminated()- Specified by:
isTerminatedin interfaceExecutorService
-
awaitTermination
- Specified by:
awaitTerminationin interfaceExecutorService- Throws:
InterruptedException
-