public class QueuedExecutionManager extends AbstractQueuedExecutionManager
Implementation of the interface ExecutionManager
which lets managing an execution queue in function of a maximum number of running jobs:
if there are more running jobs than a given number, the jobs to execute are put in the queue until a running job stops.
The order of queued jobs are preserved: it is implemented by a FIFO queue.
Modifier and Type | Field and Description |
---|---|
protected int |
nbMaxRunningJobs
The maximum number of running jobs.
|
static int |
NO_QUEUE
The value of
nbMaxRunningJobs which indicates that there is no queue. |
logger, queuedJobs, runningJobs
Constructor and Description |
---|
QueuedExecutionManager(UWSLog logger)
Builds an execution manager without queue.
|
QueuedExecutionManager(UWSLog logger,
int maxRunningJobs)
Builds an execution manager with a queue.
|
Modifier and Type | Method and Description |
---|---|
int |
getMaxRunningJobs()
Gets the maximum number of running jobs.
|
boolean |
isReadyForExecution(UWSJob jobToExecute)
Tells whether the given job can be executed NOW.
|
void |
setMaxRunningJobs(int maxRunningJobs)
Sets the maximum number of running jobs.
|
void |
setNoQueue() |
execute, getNbQueuedJobs, getNbRunningJobs, getQueuedJobs, getRunningJobs, hasQueue, refresh, remove, startJob, stopAll
protected int nbMaxRunningJobs
public static final int NO_QUEUE
nbMaxRunningJobs
which indicates that there is no queue.public QueuedExecutionManager(UWSLog logger)
logger
- The object to user to log some messages (error, info, debug).public QueuedExecutionManager(UWSLog logger, int maxRunningJobs)
logger
- The object to user to log some messages (error, info, debug).maxRunningJobs
- The maximum number of running jobs (must be > 0 to have a queue).public final void setNoQueue()
public final int getMaxRunningJobs()
public void setMaxRunningJobs(int maxRunningJobs) throws UWSException
Sets the maximum number of running jobs.
Note: If the new maximum number of running jobs is increasing the list of running jobs is immediately updated BUT NOT IF it is decreasing (that is to say, running jobs will not be interrupted to be put in the queue, they continue to run) !
maxRunningJobs
- The new maximum number of running jobs (NO_QUEUE
or a negative value means no maximum number of running jobs: there will be no queue any more).UWSException
- If there is an error while updating the list of running jobs (in other words if some queued jobs can not be executed).AbstractQueuedExecutionManager.refresh()
public final boolean isReadyForExecution(UWSJob jobToExecute)
AbstractQueuedExecutionManager
isReadyForExecution
in class AbstractQueuedExecutionManager