Module org.elasticsearch.server
Class AbstractThrottledTaskRunner<T extends ActionListener<Releasable>>
java.lang.Object
org.elasticsearch.common.util.concurrent.AbstractThrottledTaskRunner<T>
- Direct Known Subclasses:
ThrottledTaskRunner
AbstractThrottledTaskRunner
runs the enqueued tasks using the given executor, limiting the number of tasks that are submitted to
the executor at once.-
Constructor Summary
ConstructorsConstructorDescriptionAbstractThrottledTaskRunner
(String name, int maxRunningTasks, Executor executor, Queue<T> taskQueue) -
Method Summary
Modifier and TypeMethodDescriptionvoid
enqueueTask
(T task) Submits a task for execution.protected boolean
isForceExecution
(T task) Allows certain tasks to force their execution, bypassing the queue-length limit on the executor.void
runSyncTasksEagerly
(Executor executor) Run a single task on the given executor which eagerly pulls tasks from the queue and executes them.
-
Constructor Details
-
AbstractThrottledTaskRunner
-
-
Method Details
-
enqueueTask
Submits a task for execution. If there are fewer thanmaxRunningTasks
tasks currently running then this task is immediately submitted to the executor. Otherwise this task is enqueued and will be submitted to the executor in turn on completion of some other task. Tasks are executed via theirActionListener.onResponse(Response)
method, receiving aReleasable
which must be closed on completion of the task. Task which are rejected from their executor are notified via theirActionListener.onFailure(java.lang.Exception)
method. Neither of these methods may themselves throw exceptions. -
isForceExecution
Allows certain tasks to force their execution, bypassing the queue-length limit on the executor. See alsoAbstractRunnable.isForceExecution()
. -
runSyncTasksEagerly
Run a single task on the given executor which eagerly pulls tasks from the queue and executes them. This must only be used if the tasks in the queue are all synchronous, i.e. they release their ref before returning fromonResponse()
.
-