Class AbstractThrottledTaskRunner<T extends ActionListener<Releasable>>

java.lang.Object
org.elasticsearch.common.util.concurrent.AbstractThrottledTaskRunner<T>
Direct Known Subclasses:
ThrottledTaskRunner

public class AbstractThrottledTaskRunner<T extends ActionListener<Releasable>> extends Object
AbstractThrottledTaskRunner runs the enqueued tasks using the given executor, limiting the number of tasks that are submitted to the executor at once.
  • Constructor Details

    • AbstractThrottledTaskRunner

      public AbstractThrottledTaskRunner(String name, int maxRunningTasks, Executor executor, Queue<T> taskQueue)
  • Method Details

    • enqueueTask

      public void enqueueTask(T task)
      Submits a task for execution. If there are fewer than maxRunningTasks 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 their ActionListener.onResponse(Response) method, receiving a Releasable which must be closed on completion of the task. Task which are rejected from their executor are notified via their ActionListener.onFailure(java.lang.Exception) method. Neither of these methods may themselves throw exceptions.
    • isForceExecution

      protected boolean isForceExecution(T task)
      Allows certain tasks to force their execution, bypassing the queue-length limit on the executor. See also AbstractRunnable.isForceExecution().