Class HadoopExecutors

java.lang.Object
org.apache.hadoop.util.concurrent.HadoopExecutors

public final class HadoopExecutors extends Object
Factory methods for ExecutorService, ScheduledExecutorService instances. These executor service instances provide additional functionality (e.g logging uncaught exceptions).
  • Method Details

    • newCachedThreadPool

      public static ExecutorService newCachedThreadPool(ThreadFactory threadFactory)
    • newFixedThreadPool

      public static ExecutorService newFixedThreadPool(int nThreads, ThreadFactory threadFactory)
    • newFixedThreadPool

      public static ExecutorService newFixedThreadPool(int nThreads)
    • newSingleThreadExecutor

      public static ExecutorService newSingleThreadExecutor()
    • newSingleThreadExecutor

      public static ExecutorService newSingleThreadExecutor(ThreadFactory threadFactory)
    • newScheduledThreadPool

      public static ScheduledExecutorService newScheduledThreadPool(int corePoolSize)
    • newScheduledThreadPool

      public static ScheduledExecutorService newScheduledThreadPool(int corePoolSize, ThreadFactory threadFactory)
    • newSingleThreadScheduledExecutor

      public static ScheduledExecutorService newSingleThreadScheduledExecutor()
    • newSingleThreadScheduledExecutor

      public static ScheduledExecutorService newSingleThreadScheduledExecutor(ThreadFactory threadFactory)
    • shutdown

      public static void shutdown(ExecutorService executorService, org.slf4j.Logger logger, long timeout, TimeUnit unit)
      Helper routine to shutdown a ExecutorService. Will wait up to a certain timeout for the ExecutorService to gracefully shutdown. If the ExecutorService did not shutdown and there are still tasks unfinished after the timeout period, the ExecutorService will be notified to forcibly shut down. Another timeout period will be waited before giving up. So, at most, a shutdown will be allowed to wait up to twice the timeout value before giving up.
      Parameters:
      executorService - ExecutorService to shutdown
      logger - Logger
      timeout - the maximum time to wait
      unit - the time unit of the timeout argument