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:
Executor,ExecutorService
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 ClassesModifier and TypeClassDescriptionstatic classstatic interfaceWe expect the work queue to be empty fairly frequently; if the queue remains nonempty for sufficiently long then there's a risk that some lower-priority tasks are being starved of access to the executor.Nested classes/interfaces inherited from class org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor
EsThreadPoolExecutor.ShutdownListenerNested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
ThreadPoolExecutor.AbortPolicy, ThreadPoolExecutor.CallerRunsPolicy, ThreadPoolExecutor.DiscardOldestPolicy, ThreadPoolExecutor.DiscardPolicy -
Constructor Summary
ConstructorsConstructorDescriptionPrioritizedEsThreadPoolExecutor(String name, int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, ThreadFactory threadFactory, ThreadContext contextHolder, ScheduledExecutorService timer, PrioritizedEsThreadPoolExecutor.StarvationWatcher starvationWatcher) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidafterExecute(Runnable r, Throwable t) protected voidbeforeExecute(Thread t, Runnable r) voidReturns the waiting time of the first task in the queueintprotected <T> RunnableFuture<T>newTaskFor(Runnable runnable, T value) protected <T> RunnableFuture<T>newTaskFor(Callable<T> callable) protected Runnableprotected RunnablewrapRunnable(Runnable command) Methods inherited from class org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor
appendThreadPoolExecutorDetails, execute, getTasks, terminated, toStringMethods 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
-
Constructor Details
-
PrioritizedEsThreadPoolExecutor
public PrioritizedEsThreadPoolExecutor(String name, int corePoolSize, int maximumPoolSize, long keepAliveTime, TimeUnit unit, ThreadFactory threadFactory, ThreadContext contextHolder, ScheduledExecutorService timer, PrioritizedEsThreadPoolExecutor.StarvationWatcher starvationWatcher)
-
-
Method Details
-
getPending
-
getNumberOfPendingTasks
public int getNumberOfPendingTasks() -
getMaxTaskWaitTime
Returns the waiting time of the first task in the queue -
beforeExecute
- Overrides:
beforeExecutein classThreadPoolExecutor
-
afterExecute
- Overrides:
afterExecutein classEsThreadPoolExecutor
-
execute
-
wrapRunnable
- Overrides:
wrapRunnablein classEsThreadPoolExecutor
-
unwrap
- Overrides:
unwrapin classEsThreadPoolExecutor
-
newTaskFor
- Overrides:
newTaskForin classAbstractExecutorService
-
newTaskFor
- Overrides:
newTaskForin classAbstractExecutorService
-