Constructor and Description |
---|
CachedJobQueue(JobQueue delegate) |
Modifier and Type | Method and Description |
---|---|
void |
clear()
clear all jobs in the queue.
|
int |
count()
Returns the # of jobs that are waiting to be run
|
int |
countReadyJobs(Constraint constraint)
counts the # of jobs that can run now.
|
JobHolder |
findJobById(java.lang.String id)
returns the job with the given id if it exists in the queue
|
java.util.Set<JobHolder> |
findJobs(Constraint constraint)
Returns jobs that matches the given constraints
|
java.lang.Long |
getNextJobDelayUntilNs(Constraint constraint)
Returns when the next job should run (in nanoseconds), should return null if there are no
jobs to run.
|
boolean |
insert(JobHolder jobHolder)
Inserts the given JobHolder.
|
boolean |
insertOrReplace(JobHolder jobHolder)
Does the same thing with insert but the only difference is that
if job has an insertion ID, it should replace the existing one
should also reset running session id to
JobManager.NOT_RUNNING_SESSION_ID
Is called when a job is re-added (due to exception during run) |
JobHolder |
nextJobAndIncRunCount(Constraint constraint)
Returns the next available job in the data set
It should also assign the sessionId as the RunningSessionId and persist that data if necessary.
|
void |
onJobCancelled(JobHolder holder)
Called when a job is cancelled by the user.
|
void |
remove(JobHolder jobHolder)
Removes the job from the data store.
|
void |
substitute(JobHolder newJob,
JobHolder oldJob)
Remove the old job from the queue while inserting the new one.
|
public CachedJobQueue(JobQueue delegate)
public boolean insert(JobHolder jobHolder)
JobQueue
public boolean insertOrReplace(JobHolder jobHolder)
JobQueue
JobManager.NOT_RUNNING_SESSION_ID
Is called when a job is re-added (due to exception during run)insertOrReplace
in interface JobQueue
jobHolder
- The JobHolder to be addedpublic void substitute(JobHolder newJob, JobHolder oldJob)
JobQueue
substitute
in interface JobQueue
newJob
- To be insertedoldJob
- To be removedpublic void remove(JobHolder jobHolder)
JobQueue
public int count()
JobQueue
public int countReadyJobs(Constraint constraint)
JobQueue
Exclude groups are guaranteed to be ordered in natural order.
countReadyJobs
in interface JobQueue
constraint
- The constraint to match the jobspublic JobHolder nextJobAndIncRunCount(Constraint constraint)
JobQueue
nextJobAndIncRunCount
in interface JobQueue
constraint
- The constraint to match the job.public java.lang.Long getNextJobDelayUntilNs(Constraint constraint)
JobQueue
This method should check both delayed jobs and jobs that require network with a timeout.
getNextJobDelayUntilNs
in interface JobQueue
constraint
- The constraint to match the job.public void clear()
JobQueue
public java.util.Set<JobHolder> findJobs(Constraint constraint)
JobQueue
public void onJobCancelled(JobHolder holder)
JobQueue
It is important to not return this job from queries anymore.
onJobCancelled
in interface JobQueue
holder
- The JobHolder that is being cancelledpublic JobHolder findJobById(java.lang.String id)
JobQueue
findJobById
in interface JobQueue
id
- id of the job