|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.camel.util.concurrent.ExecutorServiceHelper
public final class ExecutorServiceHelper
Helper for ExecutorService to construct executors using a thread factory that
create thread names with Camel prefix.
ExecutorServiceStrategy which you obtain from CamelContext
to create thread pools.
This helper should only be used internally in Camel.
| Field Summary | |
|---|---|
static String |
DEFAULT_PATTERN
|
| Method Summary | |
|---|---|
static ExecutorService |
getConfiguredExecutorService(RouteContext routeContext,
String name,
ExecutorServiceAwareDefinition definition)
Will lookup and get the configured ExecutorService from the given definition. |
static ScheduledExecutorService |
getConfiguredScheduledExecutorService(RouteContext routeContext,
String name,
ExecutorServiceAwareDefinition definition)
Will lookup and get the configured ScheduledExecutorService from the given definition. |
static String |
getThreadName(String pattern,
String name)
Creates a new thread name with the given prefix |
static ExecutorService |
newCachedThreadPool(String pattern,
String name,
boolean daemon)
Creates a new cached thread pool. |
static ExecutorService |
newFixedThreadPool(int poolSize,
String pattern,
String name,
boolean daemon)
Creates a new fixed thread pool. |
static ScheduledExecutorService |
newScheduledThreadPool(int poolSize,
String pattern,
String name,
boolean daemon)
Creates a new scheduled thread pool which can schedule threads. |
static ExecutorService |
newSingleThreadExecutor(String pattern,
String name,
boolean daemon)
Creates a new single thread pool (usually for background tasks) |
static ExecutorService |
newSynchronousThreadPool()
Creates a new synchronous executor service which always executes the task in the call thread (its just a thread pool facade) |
static ExecutorService |
newThreadPool(String pattern,
String name,
int corePoolSize,
int maxPoolSize)
Creates a new custom thread pool using 60 seconds as keep alive and with an unbounded queue. |
static ExecutorService |
newThreadPool(String pattern,
String name,
int corePoolSize,
int maxPoolSize,
int maxQueueSize)
Creates a new custom thread pool using 60 seconds as keep alive and with bounded queue. |
static ExecutorService |
newThreadPool(String pattern,
String name,
int corePoolSize,
int maxPoolSize,
long keepAliveTime,
TimeUnit timeUnit,
int maxQueueSize,
RejectedExecutionHandler rejectedExecutionHandler,
boolean daemon)
Creates a new custom thread pool |
static void |
timeoutTask(CompletionService completionService)
Timeout the completion service. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String DEFAULT_PATTERN
| Method Detail |
|---|
public static String getThreadName(String pattern,
String name)
pattern - the patternname - the name
public static ScheduledExecutorService newScheduledThreadPool(int poolSize,
String pattern,
String name,
boolean daemon)
poolSize - the core pool sizepattern - pattern of the thread namename - ${name} in the pattern namedaemon - whether the threads is daemon or not
public static ExecutorService newFixedThreadPool(int poolSize,
String pattern,
String name,
boolean daemon)
poolSize - the fixed pool sizepattern - pattern of the thread namename - ${name} in the pattern namedaemon - whether the threads is daemon or not
public static ExecutorService newSingleThreadExecutor(String pattern,
String name,
boolean daemon)
pattern - pattern of the thread namename - ${name} in the pattern namedaemon - whether the threads is daemon or not
public static ExecutorService newCachedThreadPool(String pattern,
String name,
boolean daemon)
pattern - pattern of the thread namename - ${name} in the pattern namedaemon - whether the threads is daemon or not
public static ExecutorService newSynchronousThreadPool()
SynchronousExecutorService
public static ExecutorService newThreadPool(String pattern,
String name,
int corePoolSize,
int maxPoolSize)
pattern - pattern of the thread namename - ${name} in the pattern namecorePoolSize - the core pool sizemaxPoolSize - the maximum pool size
public static ExecutorService newThreadPool(String pattern,
String name,
int corePoolSize,
int maxPoolSize,
int maxQueueSize)
pattern - pattern of the thread namename - ${name} in the pattern namecorePoolSize - the core pool sizemaxPoolSize - the maximum pool sizemaxQueueSize - the maximum number of tasks in the queue, use Integer.MAX_VALUE or -1 to indicate unbounded
public static ExecutorService newThreadPool(String pattern,
String name,
int corePoolSize,
int maxPoolSize,
long keepAliveTime,
TimeUnit timeUnit,
int maxQueueSize,
RejectedExecutionHandler rejectedExecutionHandler,
boolean daemon)
pattern - pattern of the thread namename - ${name} in the pattern namecorePoolSize - the core pool sizemaxPoolSize - the maximum pool sizekeepAliveTime - keep alive timetimeUnit - keep alive time unitmaxQueueSize - the maximum number of tasks in the queue, use Integer.MAX_VALUE or -1 to indicate unboundedrejectedExecutionHandler - the handler for tasks which cannot be executed by the thread pool.
If null is provided then CallerRunsPolicy is used.daemon - whether the threads is daemon or not
IllegalArgumentException - if parameters is not valid
public static ExecutorService getConfiguredExecutorService(RouteContext routeContext,
String name,
ExecutorServiceAwareDefinition definition)
throws IllegalArgumentException
ExecutorService from the given definition.
This method will lookup for configured thread pool in the following order
Registry if foundThreadPoolProfile(s).ExecutorServiceAwareDefinition should use this helper method to ensure they support
configured executor services in the same coherent way.
routeContext - the rout contextname - name which is appended to the thread name, when the ExecutorService
is created based on a ThreadPoolProfile.definition - the node definition which may leverage executor service.
IllegalArgumentException - is thrown if lookup of executor service in Registry was not found
public static ScheduledExecutorService getConfiguredScheduledExecutorService(RouteContext routeContext,
String name,
ExecutorServiceAwareDefinition definition)
throws IllegalArgumentException
ScheduledExecutorService from the given definition.
This method will lookup for configured thread pool in the following order
Registry if foundThreadPoolProfile(s).ExecutorServiceAwareDefinition should use this helper method to ensure they support
configured executor services in the same coherent way.
routeContext - the rout contextname - name which is appended to the thread name, when the ExecutorService
is created based on a ThreadPoolProfile.definition - the node definition which may leverage executor service.
IllegalArgumentException - is thrown if lookup of executor service in Registry was not found
or the found instance is not a ScheduledExecutorService type.public static void timeoutTask(CompletionService completionService)
SubmitOrderedCompletionService.
completionService - the completion service.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||