Package alluxio.metrics
Class InstrumentedExecutorService
- java.lang.Object
-
- alluxio.metrics.InstrumentedExecutorService
-
- All Implemented Interfaces:
java.util.concurrent.Executor
,java.util.concurrent.ExecutorService
public class InstrumentedExecutorService extends java.lang.Object implements java.util.concurrent.ExecutorService
A wrapper aroundInstrumentedExecutorService
that allows the metrics to be reset byMetricsSystem.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 Summary
Constructors Constructor Description InstrumentedExecutorService(java.util.concurrent.ExecutorService executorService, com.codahale.metrics.MetricRegistry registry, java.lang.String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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()
protected void
reset()
Resets the metrics monitored about the executor service.void
shutdown()
java.util.List<java.lang.Runnable>
shutdownNow()
java.util.concurrent.Future<?>
submit(java.lang.Runnable runnable)
<T> java.util.concurrent.Future<T>
submit(java.lang.Runnable runnable, T result)
<T> java.util.concurrent.Future<T>
submit(java.util.concurrent.Callable<T> task)
-
-
-
Constructor Detail
-
InstrumentedExecutorService
public InstrumentedExecutorService(java.util.concurrent.ExecutorService executorService, com.codahale.metrics.MetricRegistry registry, java.lang.String name)
- Parameters:
executorService
- the executor service to instrumentregistry
- the metric registryname
- the name that will be used for the associated metrics
-
-
Method Detail
-
reset
protected void reset()
Resets the metrics monitored about the executor service. This is only called byMetricsSystem.resetAllMetrics()
after all metrics have already been cleared, then this method will update the pointers of this object to the new metrics.
-
execute
public void execute(@Nonnull java.lang.Runnable runnable)
- Specified by:
execute
in interfacejava.util.concurrent.Executor
-
submit
public java.util.concurrent.Future<?> submit(@Nonnull java.lang.Runnable runnable)
- Specified by:
submit
in interfacejava.util.concurrent.ExecutorService
-
submit
public <T> java.util.concurrent.Future<T> submit(@Nonnull java.lang.Runnable runnable, T result)
- Specified by:
submit
in interfacejava.util.concurrent.ExecutorService
-
submit
public <T> java.util.concurrent.Future<T> submit(@Nonnull java.util.concurrent.Callable<T> task)
- Specified by:
submit
in interfacejava.util.concurrent.ExecutorService
-
invokeAll
public <T> java.util.List<java.util.concurrent.Future<T>> invokeAll(@Nonnull java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks) throws java.lang.InterruptedException
- Specified by:
invokeAll
in interfacejava.util.concurrent.ExecutorService
- Throws:
java.lang.InterruptedException
-
invokeAll
public <T> java.util.List<java.util.concurrent.Future<T>> invokeAll(@Nonnull java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks, long timeout, @Nonnull java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
- Specified by:
invokeAll
in interfacejava.util.concurrent.ExecutorService
- Throws:
java.lang.InterruptedException
-
invokeAny
public <T> T invokeAny(@Nonnull java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks) throws java.util.concurrent.ExecutionException, java.lang.InterruptedException
- Specified by:
invokeAny
in interfacejava.util.concurrent.ExecutorService
- Throws:
java.util.concurrent.ExecutionException
java.lang.InterruptedException
-
invokeAny
public <T> T invokeAny(@Nonnull java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks, long timeout, @Nonnull java.util.concurrent.TimeUnit unit) throws java.util.concurrent.ExecutionException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
- Specified by:
invokeAny
in interfacejava.util.concurrent.ExecutorService
- Throws:
java.util.concurrent.ExecutionException
java.lang.InterruptedException
java.util.concurrent.TimeoutException
-
shutdown
public void shutdown()
- Specified by:
shutdown
in interfacejava.util.concurrent.ExecutorService
-
shutdownNow
public java.util.List<java.lang.Runnable> shutdownNow()
- Specified by:
shutdownNow
in interfacejava.util.concurrent.ExecutorService
-
isShutdown
public boolean isShutdown()
- Specified by:
isShutdown
in interfacejava.util.concurrent.ExecutorService
-
isTerminated
public boolean isTerminated()
- Specified by:
isTerminated
in interfacejava.util.concurrent.ExecutorService
-
awaitTermination
public boolean awaitTermination(long l, @Nonnull java.util.concurrent.TimeUnit timeUnit) throws java.lang.InterruptedException
- Specified by:
awaitTermination
in interfacejava.util.concurrent.ExecutorService
- Throws:
java.lang.InterruptedException
-
-