Class EsExecutors
- java.lang.Object
-
- org.elasticsearch.common.util.concurrent.EsExecutors
-
public class EsExecutors extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static Setting<java.lang.Integer>
PROCESSORS_SETTING
Settings key to manually set the number of available processors.
-
Method Summary
Modifier and Type Method Description static java.util.concurrent.ThreadFactory
daemonThreadFactory(java.lang.String namePrefix)
static java.util.concurrent.ThreadFactory
daemonThreadFactory(java.lang.String nodeName, java.lang.String namePrefix)
static java.util.concurrent.ThreadFactory
daemonThreadFactory(Settings settings, java.lang.String namePrefix)
static java.util.concurrent.ThreadFactory
daemonThreadFactory(Settings settings, java.lang.String... names)
static EsThreadPoolExecutor
newAutoQueueFixed(java.lang.String name, int size, int initialQueueCapacity, int minQueueSize, int maxQueueSize, int frameSize, TimeValue targetedResponseTime, java.util.concurrent.ThreadFactory threadFactory, ThreadContext contextHolder)
Return a new executor that will automatically adjust the queue size based on queue throughput.static java.util.concurrent.ExecutorService
newDirectExecutorService()
Returns anExecutorService
that executes submitted tasks on the current thread.static EsThreadPoolExecutor
newFixed(java.lang.String name, int size, int queueCapacity, java.util.concurrent.ThreadFactory threadFactory, ThreadContext contextHolder)
static EsThreadPoolExecutor
newScaling(java.lang.String name, int min, int max, long keepAliveTime, java.util.concurrent.TimeUnit unit, java.util.concurrent.ThreadFactory threadFactory, ThreadContext contextHolder)
static PrioritizedEsThreadPoolExecutor
newSinglePrioritizing(java.lang.String name, java.util.concurrent.ThreadFactory threadFactory, ThreadContext contextHolder, java.util.concurrent.ScheduledExecutorService timer)
static int
numberOfProcessors(Settings settings)
Returns the number of available processors.static java.lang.Throwable
rethrowErrors(java.lang.Runnable runnable)
Checks if the runnable arose from asynchronous submission of a task to an executor.static java.lang.String
threadName(java.lang.String nodeName, java.lang.String namePrefix)
static java.lang.String
threadName(Settings settings, java.lang.String namePrefix)
static java.lang.String
threadName(Settings settings, java.lang.String... names)
-
-
-
Field Detail
-
PROCESSORS_SETTING
public static final Setting<java.lang.Integer> PROCESSORS_SETTING
Settings key to manually set the number of available processors. This is used to adjust thread pools sizes etc. per node.
-
-
Method Detail
-
numberOfProcessors
public static int numberOfProcessors(Settings settings)
Returns the number of available processors. Defaults toRuntime.availableProcessors()
but can be overridden by passing aSettings
instance with the key "processors" set to the desired value.- Parameters:
settings
- aSettings
instance from which to derive the available processors- Returns:
- the number of available processors
-
newSinglePrioritizing
public static PrioritizedEsThreadPoolExecutor newSinglePrioritizing(java.lang.String name, java.util.concurrent.ThreadFactory threadFactory, ThreadContext contextHolder, java.util.concurrent.ScheduledExecutorService timer)
-
newScaling
public static EsThreadPoolExecutor newScaling(java.lang.String name, int min, int max, long keepAliveTime, java.util.concurrent.TimeUnit unit, java.util.concurrent.ThreadFactory threadFactory, ThreadContext contextHolder)
-
newFixed
public static EsThreadPoolExecutor newFixed(java.lang.String name, int size, int queueCapacity, java.util.concurrent.ThreadFactory threadFactory, ThreadContext contextHolder)
-
newAutoQueueFixed
public static EsThreadPoolExecutor newAutoQueueFixed(java.lang.String name, int size, int initialQueueCapacity, int minQueueSize, int maxQueueSize, int frameSize, TimeValue targetedResponseTime, java.util.concurrent.ThreadFactory threadFactory, ThreadContext contextHolder)
Return a new executor that will automatically adjust the queue size based on queue throughput.- Parameters:
size
- number of fixed threads to use for executing tasksinitialQueueCapacity
- initial size of the executor queueminQueueSize
- minimum queue size that the queue can be adjusted tomaxQueueSize
- maximum queue size that the queue can be adjusted toframeSize
- number of tasks during which stats are collected before adjusting queue size
-
rethrowErrors
public static java.lang.Throwable rethrowErrors(java.lang.Runnable runnable)
Checks if the runnable arose from asynchronous submission of a task to an executor. If an uncaught exception was thrown during the execution of this task, we need to inspect this runnable and see if it is an error that should be propagated to the uncaught exception handler.- Parameters:
runnable
- the runnable to inspect, should be a RunnableFuture- Returns:
- non fatal exception or null if no exception.
-
newDirectExecutorService
public static java.util.concurrent.ExecutorService newDirectExecutorService()
Returns anExecutorService
that executes submitted tasks on the current thread. This executor service does not support being shutdown.- Returns:
- an
ExecutorService
that executes submitted tasks on the current thread
-
threadName
public static java.lang.String threadName(Settings settings, java.lang.String... names)
-
threadName
public static java.lang.String threadName(Settings settings, java.lang.String namePrefix)
-
threadName
public static java.lang.String threadName(java.lang.String nodeName, java.lang.String namePrefix)
-
daemonThreadFactory
public static java.util.concurrent.ThreadFactory daemonThreadFactory(Settings settings, java.lang.String namePrefix)
-
daemonThreadFactory
public static java.util.concurrent.ThreadFactory daemonThreadFactory(java.lang.String nodeName, java.lang.String namePrefix)
-
daemonThreadFactory
public static java.util.concurrent.ThreadFactory daemonThreadFactory(Settings settings, java.lang.String... names)
-
daemonThreadFactory
public static java.util.concurrent.ThreadFactory daemonThreadFactory(java.lang.String namePrefix)
-
-