public interface JobQueue
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.
|
boolean insert(JobHolder jobHolder)
jobHolder
- The JobHolder to be insertedboolean insertOrReplace(JobHolder jobHolder)
JobManager.NOT_RUNNING_SESSION_ID
Is called when a job is re-added (due to exception during run)jobHolder
- The JobHolder to be addedvoid substitute(JobHolder newJob, JobHolder oldJob)
newJob
- To be insertedoldJob
- To be removedvoid remove(JobHolder jobHolder)
jobHolder
- The JobHolder to be removedint count()
int countReadyJobs(Constraint constraint)
Exclude groups are guaranteed to be ordered in natural order.
constraint
- The constraint to match the jobsJobHolder nextJobAndIncRunCount(Constraint constraint)
constraint
- The constraint to match the job.java.lang.Long getNextJobDelayUntilNs(Constraint constraint)
This method should check both delayed jobs and jobs that require network with a timeout.
constraint
- The constraint to match the job.void clear()
JobHolder findJobById(java.lang.String id)
id
- id of the jobjava.util.Set<JobHolder> findJobs(Constraint constraint)
constraint
- The constraint to match the job.void onJobCancelled(JobHolder holder)
It is important to not return this job from queries anymore.
holder
- The JobHolder that is being cancelled