Package io.aleph.dirigiste
Class Executor
java.lang.Object
java.util.concurrent.AbstractExecutorService
io.aleph.dirigiste.Executor
- All Implemented Interfaces:
AutoCloseable
,Executor
,ExecutorService
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionExecutor
(ThreadFactory threadFactory, BlockingQueue queue, Executor.Controller controller, int initialThreadCount, EnumSet<Stats.Metric> metrics, long samplePeriod, long controlPeriod, TimeUnit unit) -
Method Summary
Modifier and TypeMethodDescriptionboolean
awaitTermination
(long timeout, TimeUnit unit) void
void
executeWithoutRejection
(Runnable runnable) A version of execute which will simply block until the task is accepted, rather than throwing a RejectedExceptionException.getStats()
boolean
boolean
void
shutdown()
Methods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.concurrent.ExecutorService
close
-
Constructor Details
-
Executor
public Executor(ThreadFactory threadFactory, BlockingQueue queue, Executor.Controller controller, int initialThreadCount, EnumSet<Stats.Metric> metrics, long samplePeriod, long controlPeriod, TimeUnit unit) - Parameters:
threadFactory
- the ThreadFactory used by the executorqueue
- the queue that holds Runnable objects waiting to be executedcontroller
- the Controller object that updates the thread countinitialThreadCount
- the number of threads that the executor will begin withmetrics
- the metrics that will be collected and delivered to the controllersamplePeriod
- the period at which the executor's state will be sampledcontrolPeriod
- the period at which the controller will be invoked with the gathered statisticsunit
- the time unit for the #samplePeriod and #controlPeriod
-
-
Method Details
-
getMetrics
- Returns:
- the metrics being gathered by the executor
-
getLastStats
- Returns:
- the last aggregate statistics given to the control loop.
-
getStats
- Returns:
- the aggregate statistics for the executor since the last control loop update.
-
awaitTermination
- Throws:
InterruptedException
-
executeWithoutRejection
public void executeWithoutRejection(Runnable runnable) throws NullPointerException, InterruptedException A version of execute which will simply block until the task is accepted, rather than throwing a RejectedExceptionException. RejectedExecutionException will only be thrown if the executor is shut down. -
execute
-
isShutdown
public boolean isShutdown() -
isTerminated
public boolean isTerminated() -
shutdown
public void shutdown() -
shutdownNow
-