| Modifier and Type | Class and Description |
|---|---|
static class |
SqliteJobQueue.JavaSerializer |
static interface |
SqliteJobQueue.JobSerializer |
| Constructor and Description |
|---|
SqliteJobQueue(Configuration configuration,
long sessionId,
SqliteJobQueue.JobSerializer serializer) |
| 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
|
android.database.sqlite.SQLiteDatabase |
getDb() |
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) |
java.lang.String |
logJobs() |
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 SqliteJobQueue(Configuration configuration, long sessionId, SqliteJobQueue.JobSerializer serializer)
public android.database.sqlite.SQLiteDatabase getDb()
public boolean insert(JobHolder jobHolder)
public void substitute(JobHolder newJob, JobHolder oldJob)
JobQueuesubstitute in interface JobQueuenewJob - To be insertedoldJob - To be removedpublic boolean insertOrReplace(JobHolder jobHolder)
JobManager.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 remove(JobHolder jobHolder)
public int count()
public 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 findJobById(java.lang.String id)
findJobById 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 cancelledpublic JobHolder nextJobAndIncRunCount(Constraint constraint)
nextJobAndIncRunCount in interface JobQueueconstraint - The constraint to match the job.public java.lang.Long getNextJobDelayUntilNs(Constraint constraint)
This 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()
public java.lang.String logJobs()