public class DefaultExecutorServiceManager extends ServiceSupport implements ExecutorServiceManager
ExecutorServiceManager.shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending| Constructor and Description |
|---|
DefaultExecutorServiceManager(CamelContext camelContext) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
awaitTermination(ExecutorService executorService,
long shutdownAwaitTermination)
Awaits the termination of the thread pool.
|
protected void |
doShutdown()
Implementations override this method to perform customized shutdown.
|
protected void |
doStart()
Implementations override this method to support customized start/stop.
|
protected void |
doStop()
Implementations override this method to support customized start/stop.
|
ThreadPoolProfile |
getDefaultThreadPoolProfile()
Gets the default thread pool profile
|
long |
getShutdownAwaitTermination()
Gets the time to wait for thread pools to shutdown orderly, when invoking the
ShutdownableService.shutdown() method. |
String |
getThreadNamePattern()
Gets the thread name patter to use
|
ThreadPoolFactory |
getThreadPoolFactory()
Gets the
ThreadPoolFactory to use for creating the thread pools. |
ThreadPoolProfile |
getThreadPoolProfile(String id)
Gets the thread pool profile by the given id
|
ExecutorService |
newCachedThreadPool(Object source,
String name)
Creates a new cached thread pool.
|
ScheduledExecutorService |
newDefaultScheduledThreadPool(Object source,
String name)
Creates a new scheduled thread pool using the default thread pool profile.
|
ExecutorService |
newDefaultThreadPool(Object source,
String name)
Creates a new thread pool using the default thread pool profile.
|
ExecutorService |
newFixedThreadPool(Object source,
String name,
int poolSize)
Creates a new fixed thread pool.
|
ScheduledExecutorService |
newScheduledThreadPool(Object source,
String name,
int poolSize)
Creates a new scheduled thread pool.
|
ScheduledExecutorService |
newScheduledThreadPool(Object source,
String name,
String profileId)
Creates a new scheduled thread pool using a profile id
|
ScheduledExecutorService |
newScheduledThreadPool(Object source,
String name,
ThreadPoolProfile profile)
Creates a new scheduled thread pool using a profile
|
ExecutorService |
newSingleThreadExecutor(Object source,
String name)
Creates a new single-threaded thread pool.
|
ScheduledExecutorService |
newSingleThreadScheduledExecutor(Object source,
String name)
Creates a new single-threaded thread pool.
|
Thread |
newThread(String name,
Runnable runnable)
Creates a new daemon thread with the given name.
|
ExecutorService |
newThreadPool(Object source,
String name,
int poolSize,
int maxPoolSize)
Creates a new thread pool.
|
ExecutorService |
newThreadPool(Object source,
String name,
String profileId)
Creates a new thread pool using using the given profile id
|
ExecutorService |
newThreadPool(Object source,
String name,
ThreadPoolProfile profile)
Creates a new thread pool using the given profile
|
protected void |
onNewExecutorService(ExecutorService executorService)
Strategy callback when a new
ExecutorService have been created. |
void |
registerThreadPoolProfile(ThreadPoolProfile profile)
Registers the given thread pool profile
|
String |
resolveThreadName(String name)
Creates a full thread name
|
void |
setDefaultThreadPoolProfile(ThreadPoolProfile defaultThreadPoolProfile)
Sets the default thread pool profile
|
void |
setShutdownAwaitTermination(long shutdownAwaitTermination)
Sets the time to wait for thread pools to shutdown orderly, when invoking the
ShutdownableService.shutdown() method. |
void |
setThreadNamePattern(String threadNamePattern)
Sets the thread name pattern used for creating the full thread name.
|
void |
setThreadPoolFactory(ThreadPoolFactory threadPoolFactory)
Sets a custom
ThreadPoolFactory to use |
void |
shutdown(ExecutorService executorService)
Shutdown the given executor service (not graceful).
|
void |
shutdownGraceful(ExecutorService executorService)
Shutdown the given executor service graceful at first, and then aggressively
if the await termination timeout was hit.
|
void |
shutdownGraceful(ExecutorService executorService,
long shutdownAwaitTermination)
Shutdown the given executor service graceful at first, and then aggressively
if the await termination timeout was hit.
|
List<Runnable> |
shutdownNow(ExecutorService executorService)
Shutdown now the given executor service aggressively.
|
doResume, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspendclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitshutdownpublic DefaultExecutorServiceManager(CamelContext camelContext)
public ThreadPoolFactory getThreadPoolFactory()
ExecutorServiceManagerThreadPoolFactory to use for creating the thread pools.getThreadPoolFactory in interface ExecutorServiceManagerpublic void setThreadPoolFactory(ThreadPoolFactory threadPoolFactory)
ExecutorServiceManagerThreadPoolFactory to usesetThreadPoolFactory in interface ExecutorServiceManagerthreadPoolFactory - the thread pool factorypublic void registerThreadPoolProfile(ThreadPoolProfile profile)
ExecutorServiceManagerregisterThreadPoolProfile in interface ExecutorServiceManagerprofile - the profilepublic ThreadPoolProfile getThreadPoolProfile(String id)
ExecutorServiceManagergetThreadPoolProfile in interface ExecutorServiceManagerid - id of the thread pool profile to getpublic ThreadPoolProfile getDefaultThreadPoolProfile()
ExecutorServiceManagergetDefaultThreadPoolProfile in interface ExecutorServiceManagerpublic void setDefaultThreadPoolProfile(ThreadPoolProfile defaultThreadPoolProfile)
ExecutorServiceManagersetDefaultThreadPoolProfile in interface ExecutorServiceManagerdefaultThreadPoolProfile - the new default thread pool profilepublic String getThreadNamePattern()
ExecutorServiceManagergetThreadNamePattern in interface ExecutorServiceManagerpublic void setThreadNamePattern(String threadNamePattern)
ExecutorServiceManagerCamelContext
setThreadNamePattern in interface ExecutorServiceManagerthreadNamePattern - the patternpublic long getShutdownAwaitTermination()
ExecutorServiceManagerShutdownableService.shutdown() method.
The default value is 10000 millis.getShutdownAwaitTermination in interface ExecutorServiceManagerpublic void setShutdownAwaitTermination(long shutdownAwaitTermination)
ExecutorServiceManagerShutdownableService.shutdown() method.
The default value is 10000 millis.setShutdownAwaitTermination in interface ExecutorServiceManagershutdownAwaitTermination - time in millis.public String resolveThreadName(String name)
ExecutorServiceManagerresolveThreadName in interface ExecutorServiceManagername - name which is appended to the full thread namepublic Thread newThread(String name, Runnable runnable)
ExecutorServiceManagernewThread in interface ExecutorServiceManagername - name which is appended to the thread namerunnable - a runnable to be executed by new thread instancepublic ExecutorService newDefaultThreadPool(Object source, String name)
ExecutorServiceManagernewDefaultThreadPool in interface ExecutorServiceManagersource - the source object, usually it should be this passed in as parametername - name which is appended to the thread namepublic ScheduledExecutorService newDefaultScheduledThreadPool(Object source, String name)
ExecutorServiceManagernewDefaultScheduledThreadPool in interface ExecutorServiceManagersource - the source object, usually it should be this passed in as parametername - name which is appended to the thread namepublic ExecutorService newThreadPool(Object source, String name, String profileId)
ExecutorServiceManagernewThreadPool in interface ExecutorServiceManagersource - the source object, usually it should be this passed in as parametername - name which is appended to the thread nameprofileId - the id of the profile with the thread pool settings to usepublic ExecutorService newThreadPool(Object source, String name, ThreadPoolProfile profile)
ExecutorServiceManagernewThreadPool in interface ExecutorServiceManagersource - the source object, usually it should be this passed in as parametername - name which is appended to the thread nameprofile - the profile with the thread pool settings to usepublic ExecutorService newThreadPool(Object source, String name, int poolSize, int maxPoolSize)
ExecutorServiceManagernewThreadPool in interface ExecutorServiceManagersource - the source object, usually it should be this passed in as parametername - name which is appended to the thread namepoolSize - the core pool sizemaxPoolSize - the maximum pool sizepublic ExecutorService newSingleThreadExecutor(Object source, String name)
ExecutorServiceManagernewSingleThreadExecutor in interface ExecutorServiceManagersource - the source object, usually it should be this passed in as parametername - name which is appended to the thread namepublic ExecutorService newCachedThreadPool(Object source, String name)
ExecutorServiceManagernewCachedThreadPool in interface ExecutorServiceManagersource - the source object, usually it should be this passed in as parametername - name which is appended to the thread namepublic ExecutorService newFixedThreadPool(Object source, String name, int poolSize)
ExecutorServiceManagernewFixedThreadPool in interface ExecutorServiceManagersource - the source object, usually it should be this passed in as parametername - name which is appended to the thread namepoolSize - the core pool sizepublic ScheduledExecutorService newSingleThreadScheduledExecutor(Object source, String name)
ExecutorServiceManagernewSingleThreadScheduledExecutor in interface ExecutorServiceManagersource - the source object, usually it should be this passed in as parametername - name which is appended to the thread namepublic ScheduledExecutorService newScheduledThreadPool(Object source, String name, ThreadPoolProfile profile)
ExecutorServiceManagernewScheduledThreadPool in interface ExecutorServiceManagersource - the source object, usually it should be this passed in as parametername - name which is appended to the thread nameprofile - the profile with the thread pool settings to usepublic ScheduledExecutorService newScheduledThreadPool(Object source, String name, String profileId)
ExecutorServiceManagernewScheduledThreadPool in interface ExecutorServiceManagersource - the source object, usually it should be this passed in as parametername - name which is appended to the thread nameprofileId - the id of the profile with the thread pool settings to usepublic ScheduledExecutorService newScheduledThreadPool(Object source, String name, int poolSize)
ExecutorServiceManagernewScheduledThreadPool in interface ExecutorServiceManagersource - the source object, usually it should be this passed in as parametername - name which is appended to the thread namepoolSize - the core pool sizepublic void shutdown(ExecutorService executorService)
ExecutorServiceManagerExecutorService.shutdown() and return.shutdown in interface ExecutorServiceManagerexecutorService - the executor service to shutdownExecutorService.shutdown()public void shutdownGraceful(ExecutorService executorService)
ExecutorServiceManagerExecutorServiceManager.shutdownNow(java.util.concurrent.ExecutorService) which
forces a shutdown. The ExecutorServiceManager.getShutdownAwaitTermination()
is used as timeout value waiting for orderly shutdown to
complete normally, before going aggressively.shutdownGraceful in interface ExecutorServiceManagerexecutorService - the executor service to shutdownExecutorService.shutdown(),
ExecutorServiceManager.getShutdownAwaitTermination()public void shutdownGraceful(ExecutorService executorService, long shutdownAwaitTermination)
ExecutorServiceManagerExecutorServiceManager.shutdownNow(java.util.concurrent.ExecutorService) which
forces a shutdown. The parameter shutdownAwaitTermination
is used as timeout value waiting for orderly shutdown to
complete normally, before going aggressively.shutdownGraceful in interface ExecutorServiceManagerexecutorService - the executor service to shutdownshutdownAwaitTermination - timeout in millis to wait for orderly shutdownExecutorService.shutdown()public List<Runnable> shutdownNow(ExecutorService executorService)
ExecutorServiceManagerExecutorService.shutdownNow() and return.shutdownNow in interface ExecutorServiceManagerexecutorService - the executor service to shutdown nowExecutorService.shutdownNow()public boolean awaitTermination(ExecutorService executorService, long shutdownAwaitTermination) throws InterruptedException
ExecutorServiceManagerawaitTermination in interface ExecutorServiceManagerexecutorService - the thread poolshutdownAwaitTermination - time in millis to use as timeoutInterruptedException - is thrown if we are interrupted during waitingprotected void onNewExecutorService(ExecutorService executorService)
ExecutorService have been created.executorService - the created ExecutorServiceprotected void doStart() throws Exception
ServiceSupportServiceSupport.doStop() for more details.doStart in class ServiceSupportExceptionServiceSupport.doStop()protected void doStop() throws Exception
ServiceSupportServiceSupport.doStop() method when
the service is being stopped. This method will also be invoked
if the service is still in uninitialized state (eg has not
been started). The method is always called to allow the service
to do custom logic when the service is being stopped, such as when
CamelContext is shutting down.doStop in class ServiceSupportExceptionServiceSupport.doStart()protected void doShutdown() throws Exception
ServiceSupportdoShutdown in class ServiceSupportExceptionApache Camel