Class 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

      All Methods Static Methods Concrete Methods 
      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 an ExecutorService 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.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)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 to Runtime.availableProcessors() but can be overridden by passing a Settings instance with the key "processors" set to the desired value.
        Parameters:
        settings - a Settings 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 tasks
        initialQueueCapacity - initial size of the executor queue
        minQueueSize - minimum queue size that the queue can be adjusted to
        maxQueueSize - maximum queue size that the queue can be adjusted to
        frameSize - number of tasks during which stats are collected before adjusting queue size
      • newDirectExecutorService

        public static java.util.concurrent.ExecutorService newDirectExecutorService()
        Returns an ExecutorService 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)