Package digilib.util
Class DigilibJobCenter<V>
java.lang.Object
digilib.util.DigilibJobCenter<V>
Wrapper around ExecutionService.
- Author:
- casties
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final org.slf4j.Loggergeneral logger for this class -
Constructor Summary
ConstructorsConstructorDescriptionDigilibJobCenter(int maxThreads, int maxQueueLen, boolean prestart, String label) Create a DigilibJobcenter with the given number of threads and queue length. -
Method Summary
Modifier and TypeMethodDescriptionintintintReturns the number of currently running jobs.intReturns the number of currently waiting jobs.booleanisBusy()Returns if the service is overloaded.voidsetMaxQueueLen(int maxQueueLen) voidsetMaxThreads(int maxThreads) Shuts down the Executor.Future<?> Submit Runnable job to execute.Submit Callable job that returns a Value to execute.
-
Field Details
-
logger
protected static final org.slf4j.Logger loggergeneral logger for this class
-
-
Constructor Details
-
DigilibJobCenter
Create a DigilibJobcenter with the given number of threads and queue length. If prestart=true it starts the threads in the thread pool.- Parameters:
maxThreads- the max threadsmaxQueueLen- the max queue lengthprestart- the prestartlabel- the label
-
-
Method Details
-
submit
Submit Callable job that returns a Value to execute.- Parameters:
job- the Callable- Returns:
- Future to control the job
-
submit
Submit Runnable job to execute.- Parameters:
job- the Runnable- Returns:
- Future to control the job
-
isBusy
public boolean isBusy()Returns if the service is overloaded.- Returns:
- true if busy
-
getRunningJobs
public int getRunningJobs()Returns the number of currently running jobs.- Returns:
- the number of running jobs
-
getWaitingJobs
public int getWaitingJobs()Returns the number of currently waiting jobs.- Returns:
- the number of waiting jobs
-
setMaxThreads
public void setMaxThreads(int maxThreads) - Parameters:
maxThreads- the max threads
-
getMaxThreads
public int getMaxThreads()- Returns:
- the max threads
-
setMaxQueueLen
public void setMaxQueueLen(int maxQueueLen) - Parameters:
maxQueueLen- the max queue length
-
getMaxQueueLen
public int getMaxQueueLen()- Returns:
- the max queue length
-
shutdownNow
Shuts down the Executor. Tries to stop running threads and returns a list of waiting threads.- Returns:
- list of waiting tasks
-