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, suspend
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
shutdown
public DefaultExecutorServiceManager(CamelContext camelContext)
public ThreadPoolFactory getThreadPoolFactory()
ExecutorServiceManager
ThreadPoolFactory
to use for creating the thread pools.getThreadPoolFactory
in interface ExecutorServiceManager
public void setThreadPoolFactory(ThreadPoolFactory threadPoolFactory)
ExecutorServiceManager
ThreadPoolFactory
to usesetThreadPoolFactory
in interface ExecutorServiceManager
threadPoolFactory
- the thread pool factorypublic void registerThreadPoolProfile(ThreadPoolProfile profile)
ExecutorServiceManager
registerThreadPoolProfile
in interface ExecutorServiceManager
profile
- the profilepublic ThreadPoolProfile getThreadPoolProfile(String id)
ExecutorServiceManager
getThreadPoolProfile
in interface ExecutorServiceManager
id
- id of the thread pool profile to getpublic ThreadPoolProfile getDefaultThreadPoolProfile()
ExecutorServiceManager
getDefaultThreadPoolProfile
in interface ExecutorServiceManager
public void setDefaultThreadPoolProfile(ThreadPoolProfile defaultThreadPoolProfile)
ExecutorServiceManager
setDefaultThreadPoolProfile
in interface ExecutorServiceManager
defaultThreadPoolProfile
- the new default thread pool profilepublic String getThreadNamePattern()
ExecutorServiceManager
getThreadNamePattern
in interface ExecutorServiceManager
public void setThreadNamePattern(String threadNamePattern)
ExecutorServiceManager
CamelContext
setThreadNamePattern
in interface ExecutorServiceManager
threadNamePattern
- the patternpublic long getShutdownAwaitTermination()
ExecutorServiceManager
ShutdownableService.shutdown()
method.
The default value is 10000 millis.getShutdownAwaitTermination
in interface ExecutorServiceManager
public void setShutdownAwaitTermination(long shutdownAwaitTermination)
ExecutorServiceManager
ShutdownableService.shutdown()
method.
The default value is 10000 millis.setShutdownAwaitTermination
in interface ExecutorServiceManager
shutdownAwaitTermination
- time in millis.public String resolveThreadName(String name)
ExecutorServiceManager
resolveThreadName
in interface ExecutorServiceManager
name
- name which is appended to the full thread namepublic Thread newThread(String name, Runnable runnable)
ExecutorServiceManager
newThread
in interface ExecutorServiceManager
name
- name which is appended to the thread namerunnable
- a runnable to be executed by new thread instancepublic ExecutorService newDefaultThreadPool(Object source, String name)
ExecutorServiceManager
newDefaultThreadPool
in interface ExecutorServiceManager
source
- 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)
ExecutorServiceManager
newDefaultScheduledThreadPool
in interface ExecutorServiceManager
source
- 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)
ExecutorServiceManager
newThreadPool
in interface ExecutorServiceManager
source
- 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)
ExecutorServiceManager
newThreadPool
in interface ExecutorServiceManager
source
- 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)
ExecutorServiceManager
newThreadPool
in interface ExecutorServiceManager
source
- 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)
ExecutorServiceManager
newSingleThreadExecutor
in interface ExecutorServiceManager
source
- 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)
ExecutorServiceManager
newCachedThreadPool
in interface ExecutorServiceManager
source
- 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)
ExecutorServiceManager
newFixedThreadPool
in interface ExecutorServiceManager
source
- 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)
ExecutorServiceManager
newSingleThreadScheduledExecutor
in interface ExecutorServiceManager
source
- 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)
ExecutorServiceManager
newScheduledThreadPool
in interface ExecutorServiceManager
source
- 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)
ExecutorServiceManager
newScheduledThreadPool
in interface ExecutorServiceManager
source
- 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)
ExecutorServiceManager
newScheduledThreadPool
in interface ExecutorServiceManager
source
- 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)
ExecutorServiceManager
ExecutorService.shutdown()
and return.shutdown
in interface ExecutorServiceManager
executorService
- the executor service to shutdownExecutorService.shutdown()
public void shutdownGraceful(ExecutorService executorService)
ExecutorServiceManager
ExecutorServiceManager.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 ExecutorServiceManager
executorService
- the executor service to shutdownExecutorService.shutdown()
,
ExecutorServiceManager.getShutdownAwaitTermination()
public void shutdownGraceful(ExecutorService executorService, long shutdownAwaitTermination)
ExecutorServiceManager
ExecutorServiceManager.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 ExecutorServiceManager
executorService
- the executor service to shutdownshutdownAwaitTermination
- timeout in millis to wait for orderly shutdownExecutorService.shutdown()
public List<Runnable> shutdownNow(ExecutorService executorService)
ExecutorServiceManager
ExecutorService.shutdownNow()
and return.shutdownNow
in interface ExecutorServiceManager
executorService
- the executor service to shutdown nowExecutorService.shutdownNow()
public boolean awaitTermination(ExecutorService executorService, long shutdownAwaitTermination) throws InterruptedException
ExecutorServiceManager
awaitTermination
in interface ExecutorServiceManager
executorService
- 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 ExecutorService
protected void doStart() throws Exception
ServiceSupport
ServiceSupport.doStop()
for more details.doStart
in class ServiceSupport
Exception
ServiceSupport.doStop()
protected void doStop() throws Exception
ServiceSupport
ServiceSupport.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 ServiceSupport
Exception
ServiceSupport.doStart()
protected void doShutdown() throws Exception
ServiceSupport
doShutdown
in class ServiceSupport
Exception
Apache Camel