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.Logger
general 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 TypeMethodDescriptionint
int
int
Returns the number of currently running jobs.int
Returns the number of currently waiting jobs.boolean
isBusy()
Returns if the service is overloaded.void
setMaxQueueLen
(int maxQueueLen) void
setMaxThreads
(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
-