public class JobManager extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_NUM_JOBS |
static int |
QUEUE_LENGTH_UNLIMITED |
| Constructor and Description |
|---|
JobManager()
Creates a new JobManager with DEFAULT_NUM_JOBS executors.
|
JobManager(int maxJobs)
Creates a new JobManager with the given number of executors.
|
| Modifier and Type | Method and Description |
|---|---|
<T> Job<T> |
claimInterest(AbstractJob<T> job,
long duration)
Claim interest in the given job for the given duration.
|
<T> Job<T> |
claimInterest(AbstractJob<T> job,
long duration,
int maxQueuePosition)
Claim interest in the given job for the given duration.
|
Job<?> |
claimInterest(String jobId,
long duration)
Claims interest in the job with the given id for the given duration.
|
<T> Job<T> |
getJob(String jobId)
Get the job with the given id or null if not found.
|
int |
getMaxQueueLength() |
int |
getNumFinished()
Get number of finished jobs that can be retrieved.
|
int |
getNumQueued()
Get number of queued jobs.
|
int |
getNumRunning() |
ProgressStatus |
getProgressStatus(String jobId)
Returns the progress status for the job with the given id.
|
List<Job<?>> |
getQueuedJobs()
Returns a List of the currently queued jobs.
|
Integer |
getQueuePosition(AbstractJob<?> job)
Gets the queue position for the given job.
|
Integer |
getQueuePosition(String jobId)
Gets the queue position for the job with the given id.
|
<T> T |
getResult(String jobId) |
Set<Job<?>> |
getRunningJobs()
Returns a Set of the currently processed jobs.
|
boolean |
isJobFinished(String jobId) |
void |
setMaxQueueLength(int maxQueueLength) |
void |
stop()
Stops the jobManager, MUST be called or the runner threads are not shutdown.
|
public static final int QUEUE_LENGTH_UNLIMITED
public static int DEFAULT_NUM_JOBS
public JobManager()
public JobManager(int maxJobs)
maxJobs - Maximum number of jobs to execute in parallel.public void setMaxQueueLength(int maxQueueLength)
public int getMaxQueueLength()
public <T> Job<T> claimInterest(AbstractJob<T> job, long duration) throws OvercapacityException
job - The job to claim interest in.duration - The maximum duration that we want the job to stay alive.OvercapacityException - Thrown if the job didn't exist yet and the job queue is full.public <T> Job<T> claimInterest(AbstractJob<T> job, long duration, int maxQueuePosition) throws OvercapacityException
job - The job to claim interest in.duration - The maximum duration that we want the job to stay alive.maxQueuePosition - Only enqueue job if the job's queue position would not be greater than the given
position.OvercapacityException - Thrown if the job didn't exist yet and the job queue is full.public Job<?> claimInterest(String jobId, long duration)
jobId - The jobId.duration - The duration for which one is interested in the job.public ProgressStatus getProgressStatus(String jobId)
jobId - The job id to get the progress status for.public Integer getQueuePosition(String jobId)
jobId - The job to get the queue position for.public Integer getQueuePosition(AbstractJob<?> job)
job - The job to get the queue position for.public int getNumFinished()
public int getNumQueued()
public void stop()
public int getNumRunning()
public <T> Job<T> getJob(String jobId)
jobId - The id of the job to find.public boolean isJobFinished(String jobId)
public <T> T getResult(String jobId)
Copyright © 2012. All Rights Reserved.