Package org.opencms.scheduler
Class CmsSchedulerThreadPool
java.lang.Object
org.opencms.scheduler.CmsSchedulerThreadPool
- All Implemented Interfaces:
org.quartz.spi.ThreadPool
Simple thread pool used for the Quartz scheduler in OpenCms.
- Since:
- 6.0.0
-
Constructor Summary
ConstructorDescriptionCreate a newCmsSchedulerThreadPool
with default values.CmsSchedulerThreadPool
(int initialThreadCount, int maxThreadCount, int threadPriority) Create a newCmsSchedulerThreadPool
with the specified number of threads that have the given priority. -
Method Summary
Modifier and TypeMethodDescriptionint
protected Runnable
Dequeue the next pendingRunnable
.int
int
Returns the thread priority of the threads in the scheduler pool.void
boolean
runInThread
(Runnable runnable) Run the givenRunnable
object in the next availableThread
.void
setInstanceId
(String schedInstId) void
setInstanceName
(String schedName) void
shutdown()
Terminate any worker threads in this thread group.void
shutdown
(boolean waitForJobsToComplete) Terminate all threads in this thread group.
-
Constructor Details
-
CmsSchedulerThreadPool
public CmsSchedulerThreadPool()Create a newCmsSchedulerThreadPool
with default values. This will create a pool with 0 initial and 10 maximum threads running in normal priority.- See Also:
-
CmsSchedulerThreadPool
Create a newCmsSchedulerThreadPool
with the specified number of threads that have the given priority. The OpenCms scheduler thread pool will initially start with provided number of active scheduler threads. When a thread is requested by the scheduler, and no "free" threads are available, a new thread will be added to the pool and used for execution. The pool will be allowed to grow until it has reached the configured number of maximum threads.- Parameters:
initialThreadCount
- the initial number of threads for the poolmaxThreadCount
- maximum number of threads the pool is allowed to growthreadPriority
- the thread priority for the scheduler threads- See Also:
-
-
Method Details
-
blockForAvailableThreads
- Specified by:
blockForAvailableThreads
in interfaceorg.quartz.spi.ThreadPool
- Returns:
- if the pool should be blocked for available threads
- See Also:
-
ThreadPool
-
getPoolSize
- Specified by:
getPoolSize
in interfaceorg.quartz.spi.ThreadPool
- See Also:
-
ThreadPool.getPoolSize()
-
getThreadPriority
Returns the thread priority of the threads in the scheduler pool.- Returns:
- the thread priority of the threads in the scheduler pool
-
initialize
- Specified by:
initialize
in interfaceorg.quartz.spi.ThreadPool
- Throws:
org.quartz.SchedulerConfigException
- See Also:
-
ThreadPool.initialize()
-
runInThread
Run the givenRunnable
object in the next availableThread
.If while waiting the thread pool is asked to shut down, the Runnable is executed immediately within a new additional thread.
- Specified by:
runInThread
in interfaceorg.quartz.spi.ThreadPool
- Parameters:
runnable
- theRunnable
to run- Returns:
- true if the
Runnable
was run
-
shutdown
Terminate any worker threads in this thread group.Jobs currently in progress will be allowed to complete.
-
shutdown
Terminate all threads in this thread group.- Specified by:
shutdown
in interfaceorg.quartz.spi.ThreadPool
- Parameters:
waitForJobsToComplete
- if true,, all current jobs will be allowed to complete
-
getNextRunnable
Dequeue the next pendingRunnable
.- Returns:
- the next pending
Runnable
- Throws:
InterruptedException
- if something goes wrong
-
setInstanceId
- Specified by:
setInstanceId
in interfaceorg.quartz.spi.ThreadPool
-
setInstanceName
- Specified by:
setInstanceName
in interfaceorg.quartz.spi.ThreadPool
-