| Constructor and Description |
|---|
SimpleInMemoryPriorityQueue(Configuration configuration,
long sessionId) |
| 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 SimpleInMemoryPriorityQueue(Configuration configuration, long sessionId)
public boolean insert(JobHolder jobHolder)
JobQueuepublic boolean insertOrReplace(JobHolder jobHolder)
JobQueueJobManager.NOT_RUNNING_SESSION_ID
Is called when a job is re-added (due to exception during run)insertOrReplace in interface JobQueuejobHolder - The JobHolder to be addedpublic void substitute(JobHolder newJob, JobHolder oldJob)
JobQueuesubstitute in interface JobQueuenewJob - To be insertedoldJob - To be removedpublic void remove(JobHolder jobHolder)
JobQueuepublic int count()
JobQueuepublic int countReadyJobs(Constraint constraint)
JobQueueExclude groups are guaranteed to be ordered in natural order.
countReadyJobs in interface JobQueueconstraint - The constraint to match the jobspublic JobHolder nextJobAndIncRunCount(Constraint constraint)
JobQueuenextJobAndIncRunCount in interface JobQueueconstraint - The constraint to match the job.public java.lang.Long getNextJobDelayUntilNs(Constraint constraint)
JobQueueThis method should check both delayed jobs and jobs that require network with a timeout.
getNextJobDelayUntilNs in interface JobQueueconstraint - The constraint to match the job.public void clear()
JobQueuepublic JobHolder findJobById(java.lang.String id)
JobQueuefindJobById in interface JobQueueid - id of the jobpublic java.util.Set<JobHolder> findJobs(Constraint constraint)
JobQueuepublic void onJobCancelled(JobHolder holder)
JobQueueIt is important to not return this job from queries anymore.
onJobCancelled in interface JobQueueholder - The JobHolder that is being cancelled