Class PrioritizedEsThreadPoolExecutor

java.lang.Object
java.util.concurrent.AbstractExecutorService
java.util.concurrent.ThreadPoolExecutor
org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor
org.elasticsearch.common.util.concurrent.PrioritizedEsThreadPoolExecutor
All Implemented Interfaces:
java.util.concurrent.Executor, java.util.concurrent.ExecutorService

public class PrioritizedEsThreadPoolExecutor
extends EsThreadPoolExecutor
A prioritizing executor which uses a priority queue as a work queue. The jobs that will be submitted will be treated as PrioritizedRunnable and/or PrioritizedCallable, those tasks that are not instances of these two will be wrapped and assign a default Priority.NORMAL priority.

Note, if two tasks have the same priority, the first to arrive will be executed first (FIFO style).

  • Nested Class Summary

    Nested Classes 
    Modifier and Type Class Description
    static class  PrioritizedEsThreadPoolExecutor.Pending  

    Nested classes/interfaces inherited from class org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor

    EsThreadPoolExecutor.ShutdownListener

    Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor

    java.util.concurrent.ThreadPoolExecutor.AbortPolicy, java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardPolicy
  • Constructor Summary

    Constructors 
    Constructor Description
    PrioritizedEsThreadPoolExecutor​(java.lang.String name, int corePoolSize, int maximumPoolSize, long keepAliveTime, java.util.concurrent.TimeUnit unit, java.util.concurrent.ThreadFactory threadFactory, ThreadContext contextHolder, java.util.concurrent.ScheduledExecutorService timer)  
  • Method Summary

    Modifier and Type Method Description
    protected void afterExecute​(java.lang.Runnable r, java.lang.Throwable t)  
    protected void beforeExecute​(java.lang.Thread t, java.lang.Runnable r)  
    void execute​(java.lang.Runnable command, TimeValue timeout, java.lang.Runnable timeoutCallback)  
    TimeValue getMaxTaskWaitTime()
    Returns the waiting time of the first task in the queue
    int getNumberOfPendingTasks()  
    PrioritizedEsThreadPoolExecutor.Pending[] getPending()  
    protected <T> java.util.concurrent.RunnableFuture<T> newTaskFor​(java.lang.Runnable runnable, T value)  
    protected <T> java.util.concurrent.RunnableFuture<T> newTaskFor​(java.util.concurrent.Callable<T> callable)  
    protected java.lang.Runnable unwrap​(java.lang.Runnable runnable)  
    protected java.lang.Runnable wrapRunnable​(java.lang.Runnable command)  

    Methods inherited from class org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor

    appendThreadPoolExecutorDetails, execute, getTasks, terminated, toString

    Methods inherited from class java.util.concurrent.ThreadPoolExecutor

    allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, shutdown, shutdownNow

    Methods inherited from class java.util.concurrent.AbstractExecutorService

    invokeAll, invokeAll, invokeAny, invokeAny, submit, submit, submit

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • PrioritizedEsThreadPoolExecutor

      public PrioritizedEsThreadPoolExecutor​(java.lang.String name, int corePoolSize, int maximumPoolSize, long keepAliveTime, java.util.concurrent.TimeUnit unit, java.util.concurrent.ThreadFactory threadFactory, ThreadContext contextHolder, java.util.concurrent.ScheduledExecutorService timer)
  • Method Details

    • getPending

    • getNumberOfPendingTasks

      public int getNumberOfPendingTasks()
    • getMaxTaskWaitTime

      public TimeValue getMaxTaskWaitTime()
      Returns the waiting time of the first task in the queue
    • beforeExecute

      protected void beforeExecute​(java.lang.Thread t, java.lang.Runnable r)
      Overrides:
      beforeExecute in class java.util.concurrent.ThreadPoolExecutor
    • afterExecute

      protected void afterExecute​(java.lang.Runnable r, java.lang.Throwable t)
      Overrides:
      afterExecute in class EsThreadPoolExecutor
    • execute

      public void execute​(java.lang.Runnable command, TimeValue timeout, java.lang.Runnable timeoutCallback)
    • wrapRunnable

      protected java.lang.Runnable wrapRunnable​(java.lang.Runnable command)
      Overrides:
      wrapRunnable in class EsThreadPoolExecutor
    • unwrap

      protected java.lang.Runnable unwrap​(java.lang.Runnable runnable)
      Overrides:
      unwrap in class EsThreadPoolExecutor
    • newTaskFor

      protected <T> java.util.concurrent.RunnableFuture<T> newTaskFor​(java.lang.Runnable runnable, T value)
      Overrides:
      newTaskFor in class java.util.concurrent.AbstractExecutorService
    • newTaskFor

      protected <T> java.util.concurrent.RunnableFuture<T> newTaskFor​(java.util.concurrent.Callable<T> callable)
      Overrides:
      newTaskFor in class java.util.concurrent.AbstractExecutorService