Class HadoopExecutors
java.lang.Object
org.apache.hadoop.util.concurrent.HadoopExecutors
Factory methods for ExecutorService, ScheduledExecutorService instances.
These executor service instances provide additional functionality (e.g
logging uncaught exceptions).
-
Method Summary
Modifier and TypeMethodDescriptionstatic ExecutorServicenewCachedThreadPool(ThreadFactory threadFactory) static ExecutorServicenewFixedThreadPool(int nThreads) static ExecutorServicenewFixedThreadPool(int nThreads, ThreadFactory threadFactory) static ScheduledExecutorServicenewScheduledThreadPool(int corePoolSize) static ScheduledExecutorServicenewScheduledThreadPool(int corePoolSize, ThreadFactory threadFactory) static ExecutorServicestatic ExecutorServicenewSingleThreadExecutor(ThreadFactory threadFactory) static ScheduledExecutorServicestatic ScheduledExecutorServicenewSingleThreadScheduledExecutor(ThreadFactory threadFactory) static voidshutdown(ExecutorService executorService, org.slf4j.Logger logger, long timeout, TimeUnit unit) Helper routine to shutdown aExecutorService.
-
Method Details
-
newCachedThreadPool
-
newFixedThreadPool
-
newFixedThreadPool
-
newSingleThreadExecutor
-
newSingleThreadExecutor
-
newScheduledThreadPool
-
newScheduledThreadPool
public static ScheduledExecutorService newScheduledThreadPool(int corePoolSize, ThreadFactory threadFactory) -
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 aExecutorService. 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 shutdownlogger- Loggertimeout- the maximum time to waitunit- the time unit of the timeout argument
-