public class InstrumentedExecutorService extends Object implements ExecutorService
InstrumentedExecutorService
that allows the metrics to be reset by MetricsSystem.resetAllMetrics()
.
Additional it tracks in a histogram called name.active.tasks
the number of active tasks (queued or running) each
time a new task is added to the executor. This histogram is additionally
tracks the maximum overall number active tasks at any time.Constructor and Description |
---|
InstrumentedExecutorService(ExecutorService executorService,
com.codahale.metrics.MetricRegistry registry,
String 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() |
protected void |
reset()
Resets the metrics monitored about the executor service.
|
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 executorService, com.codahale.metrics.MetricRegistry registry, String name)
executorService
- the executor service to instrumentregistry
- the metric registryname
- the name that will be used for the associated metricsprotected void reset()
MetricsSystem.resetAllMetrics()
after all metrics have already been cleared, then this method
will update the pointers of this object to the new metrics.public Future<?> submit(@Nonnull Runnable runnable)
submit
in interface ExecutorService
public <T> Future<T> submit(@Nonnull Runnable runnable, T result)
submit
in interface ExecutorService
public <T> Future<T> submit(@Nonnull Callable<T> task)
submit
in interface ExecutorService
public <T> List<Future<T>> invokeAll(@Nonnull Collection<? extends Callable<T>> tasks) throws InterruptedException
invokeAll
in interface ExecutorService
InterruptedException
public <T> List<Future<T>> invokeAll(@Nonnull Collection<? extends Callable<T>> tasks, long timeout, @Nonnull TimeUnit unit) throws InterruptedException
invokeAll
in interface ExecutorService
InterruptedException
public <T> T invokeAny(@Nonnull Collection<? extends Callable<T>> tasks) throws ExecutionException, InterruptedException
invokeAny
in interface ExecutorService
ExecutionException
InterruptedException
public <T> T invokeAny(@Nonnull Collection<? extends Callable<T>> tasks, long timeout, @Nonnull TimeUnit unit) throws ExecutionException, InterruptedException, TimeoutException
invokeAny
in interface ExecutorService
ExecutionException
InterruptedException
TimeoutException
public void shutdown()
shutdown
in interface ExecutorService
public List<Runnable> shutdownNow()
shutdownNow
in interface ExecutorService
public boolean isShutdown()
isShutdown
in interface ExecutorService
public boolean isTerminated()
isTerminated
in interface ExecutorService
public boolean awaitTermination(long l, @Nonnull TimeUnit timeUnit) throws InterruptedException
awaitTermination
in interface ExecutorService
InterruptedException
Copyright © 2023. All Rights Reserved.