Package digilib.util
Class DigilibJobCenter<V>
- java.lang.Object
-
- digilib.util.DigilibJobCenter<V>
-
public class DigilibJobCenter<V> extends Object
Wrapper around ExecutionService.- Author:
- casties
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.slf4j.Logger
logger
general logger for this class
-
Constructor Summary
Constructors Constructor Description DigilibJobCenter(int maxThreads, int maxQueueLen, boolean prestart, String label)
Create a DigilibJobcenter with the given number of threads and queue length.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getMaxQueueLen()
int
getMaxThreads()
int
getRunningJobs()
Returns the number of currently running jobs.int
getWaitingJobs()
Returns the number of currently waiting jobs.boolean
isBusy()
Returns if the service is overloaded.void
setMaxQueueLen(int maxQueueLen)
void
setMaxThreads(int maxThreads)
List<Runnable>
shutdownNow()
Shuts down the Executor.Future<?>
submit(Runnable job)
Submit Runnable job to execute.Future<V>
submit(Callable<V> job)
Submit Callable job that returns a Value to execute.
-
-
-
Constructor Detail
-
DigilibJobCenter
public DigilibJobCenter(int maxThreads, int maxQueueLen, boolean prestart, String label)
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 Detail
-
submit
public Future<V> submit(Callable<V> job)
Submit Callable job that returns a Value to execute.- Parameters:
job
- the Callable- Returns:
- Future to control the job
-
submit
public Future<?> submit(Runnable job)
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
-
-