-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic class -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ExecutorServiceExecutorServicethat executes submitted tasks on the current thread.static final Setting<Processors> Setting to manually control the number of allocated processors. -
Method Summary
Modifier and TypeMethodDescriptionstatic intallocatedProcessors(Settings settings) Returns the number of allocated processors.static ThreadFactorydaemonThreadFactory(String name) static ThreadFactorydaemonThreadFactory(String nodeName, String namePrefix) static ThreadFactorydaemonThreadFactory(String nodeName, String namePrefix, boolean isSystemThread) static ThreadFactorydaemonThreadFactory(Settings settings, String namePrefix) static StringexecutorName(String threadName) static StringexecutorName(Thread thread) static EsThreadPoolExecutornewFixed(String name, int size, int queueCapacity, ThreadFactory threadFactory, ThreadContext contextHolder, EsExecutors.TaskTrackingConfig config) static EsThreadPoolExecutornewScaling(String name, int min, int max, long keepAliveTime, TimeUnit unit, boolean rejectAfterShutdown, ThreadFactory threadFactory, ThreadContext contextHolder) Creates a scalingEsThreadPoolExecutorusing an unbounded work queue.static EsThreadPoolExecutornewScaling(String name, int min, int max, long keepAliveTime, TimeUnit unit, boolean rejectAfterShutdown, ThreadFactory threadFactory, ThreadContext contextHolder, EsExecutors.TaskTrackingConfig config) Creates a scalingEsThreadPoolExecutorusing an unbounded work queue.newSinglePrioritizing(String name, ThreadFactory threadFactory, ThreadContext contextHolder, ScheduledExecutorService timer) static ProcessorsnodeProcessors(Settings settings) static ThrowablerethrowErrors(Runnable runnable) Checks if the runnable arose from asynchronous submission of a task to an executor.static StringthreadName(String nodeName, String namePrefix) static StringthreadName(Settings settings, String namePrefix)
-
Field Details
-
NODE_PROCESSORS_SETTING
Setting to manually control the number of allocated processors. This setting is used to adjust thread pool sizes per node. The default value isRuntime.availableProcessors()but should be manually controlled if not all processors on the machine are available to Elasticsearch (e.g., because of CPU limits). Note that this setting accepts floating point processors. If a rounded number is needed, always useallocatedProcessors(Settings). -
DIRECT_EXECUTOR_SERVICE
ExecutorServicethat executes submitted tasks on the current thread. This executor service does not support being shutdown.
-
-
Method Details
-
allocatedProcessors
Returns the number of allocated processors. Defaults toRuntime.availableProcessors()but can be overridden by passing aSettingsinstance with the keynode.processorsset to the desired value.- Parameters:
settings- aSettingsinstance from which to derive the allocated processors- Returns:
- the number of allocated processors
-
nodeProcessors
-
newSinglePrioritizing
public static PrioritizedEsThreadPoolExecutor newSinglePrioritizing(String name, ThreadFactory threadFactory, ThreadContext contextHolder, ScheduledExecutorService timer) -
newScaling
public static EsThreadPoolExecutor newScaling(String name, int min, int max, long keepAliveTime, TimeUnit unit, boolean rejectAfterShutdown, ThreadFactory threadFactory, ThreadContext contextHolder, EsExecutors.TaskTrackingConfig config) Creates a scalingEsThreadPoolExecutorusing an unbounded work queue.The
EsThreadPoolExecutorscales the same way as a regularThreadPoolExecutoruntil the core pool size (and at least 1) is reached: each time a task is submitted a new worker is added regardless if an idle worker is available.Once having reached the core pool size, a
ThreadPoolExecutorwill only add a new worker if the work queue rejects a task offer. Typically, using a regular unbounded queue, task offers won't ever be rejected, meaning the worker pool would never scale beyond the core pool size.Scaling
EsThreadPoolExecutors use a customized unboundedLinkedTransferQueue, which rejects every task offer unless it can be immediately transferred to an available idle worker. If no such worker is available, the executor will add a new worker if capacity remains, otherwise the task is rejected and then appended to the work queue via theEsExecutors.ForceQueuePolicyrejection handler. -
newScaling
public static EsThreadPoolExecutor newScaling(String name, int min, int max, long keepAliveTime, TimeUnit unit, boolean rejectAfterShutdown, ThreadFactory threadFactory, ThreadContext contextHolder) Creates a scalingEsThreadPoolExecutorusing an unbounded work queue.The
EsThreadPoolExecutorscales the same way as a regularThreadPoolExecutoruntil the core pool size (and at least 1) is reached: each time a task is submitted a new worker is added regardless if an idle worker is available.Once having reached the core pool size, a
ThreadPoolExecutorwill only add a new worker if the work queue rejects a task offer. Typically, using a regular unbounded queue, task offers won't ever be rejected, meaning the worker pool would never scale beyond the core pool size.Scaling
EsThreadPoolExecutors use a customized unboundedLinkedTransferQueue, which rejects every task offer unless it can be immediately transferred to an available idle worker. If no such worker is available, the executor will add a new worker if capacity remains, otherwise the task is rejected and then appended to the work queue via theEsExecutors.ForceQueuePolicyrejection handler. -
newFixed
public static EsThreadPoolExecutor newFixed(String name, int size, int queueCapacity, ThreadFactory threadFactory, ThreadContext contextHolder, EsExecutors.TaskTrackingConfig config) -
rethrowErrors
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.
-
threadName
-
threadName
-
executorName
-
executorName
-
daemonThreadFactory
-
daemonThreadFactory
-
daemonThreadFactory
public static ThreadFactory daemonThreadFactory(String nodeName, String namePrefix, boolean isSystemThread) -
daemonThreadFactory
-