Class DynamicQuartzThreadPool
- java.lang.Object
-
- com.floragunn.searchsupport.jobs.core.DynamicQuartzThreadPool
-
- All Implemented Interfaces:
org.quartz.spi.ThreadPool
public class DynamicQuartzThreadPool extends Object implements org.quartz.spi.ThreadPool
-
-
Constructor Summary
Constructors Constructor Description DynamicQuartzThreadPool(ThreadGroup threadGroup, String threadPoolName, String threadNameSuffix, int maxThreadCount, int threadPriority, Duration threadKeepAlive)Create a newSimpleThreadPoolwith the specified number ofThreads that have the given priority.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intblockForAvailableThreads()protected com.floragunn.searchsupport.jobs.core.DynamicQuartzThreadPool.WorkerThreadcreateNewWorker(Runnable runnable)intgetCurrentAvailableWorkerCount()intgetCurrentBusyWorkerCount()intgetCurrentWorkerCount()longgetPollingIntervalMs()intgetPoolSize()voidinitialize()protected voidmakeAvailable(com.floragunn.searchsupport.jobs.core.DynamicQuartzThreadPool.WorkerThread workerThread)protected voidonTermination(com.floragunn.searchsupport.jobs.core.DynamicQuartzThreadPool.WorkerThread workerThread)booleanrunInThread(Runnable runnable)Run the givenRunnableobject in the next availableThread.voidsetInstanceId(String schedulerInstanceId)voidsetInstanceName(String schedulerInstanceName)voidsetPollingIntervalMs(long pollingIntervalMs)voidshutdown(boolean waitForJobsToComplete)voidstartAllWorkersNow()StringtoString()
-
-
-
Constructor Detail
-
DynamicQuartzThreadPool
public DynamicQuartzThreadPool(ThreadGroup threadGroup, String threadPoolName, String threadNameSuffix, int maxThreadCount, int threadPriority, Duration threadKeepAlive)
Create a new
SimpleThreadPoolwith the specified number ofThreads that have the given priority.- Parameters:
threadCount- the max number of workerThreadsin the pool, must be > 0.threadPriority- the thread priority for the worker threads.- See Also:
Thread
-
-
Method Detail
-
runInThread
public boolean runInThread(Runnable runnable)
Run the given
Runnableobject 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:
runInThreadin interfaceorg.quartz.spi.ThreadPool- Parameters:
runnable- theRunnableto be added.
-
blockForAvailableThreads
public int blockForAvailableThreads()
- Specified by:
blockForAvailableThreadsin interfaceorg.quartz.spi.ThreadPool
-
getPoolSize
public int getPoolSize()
- Specified by:
getPoolSizein interfaceorg.quartz.spi.ThreadPool
-
initialize
public void initialize() throws org.quartz.SchedulerConfigException- Specified by:
initializein interfaceorg.quartz.spi.ThreadPool- Throws:
org.quartz.SchedulerConfigException
-
startAllWorkersNow
public void startAllWorkersNow()
-
shutdown
public void shutdown(boolean waitForJobsToComplete)
- Specified by:
shutdownin interfaceorg.quartz.spi.ThreadPool
-
getCurrentWorkerCount
public int getCurrentWorkerCount()
-
getCurrentAvailableWorkerCount
public int getCurrentAvailableWorkerCount()
-
getCurrentBusyWorkerCount
public int getCurrentBusyWorkerCount()
-
setInstanceId
public void setInstanceId(String schedulerInstanceId)
- Specified by:
setInstanceIdin interfaceorg.quartz.spi.ThreadPool
-
setInstanceName
public void setInstanceName(String schedulerInstanceName)
- Specified by:
setInstanceNamein interfaceorg.quartz.spi.ThreadPool
-
createNewWorker
protected com.floragunn.searchsupport.jobs.core.DynamicQuartzThreadPool.WorkerThread createNewWorker(Runnable runnable)
-
makeAvailable
protected void makeAvailable(com.floragunn.searchsupport.jobs.core.DynamicQuartzThreadPool.WorkerThread workerThread)
-
onTermination
protected void onTermination(com.floragunn.searchsupport.jobs.core.DynamicQuartzThreadPool.WorkerThread workerThread)
-
getPollingIntervalMs
public long getPollingIntervalMs()
-
setPollingIntervalMs
public void setPollingIntervalMs(long pollingIntervalMs)
-
-