|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.path.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue
public class SqliteJobQueue
Persistent Job Queue that keeps its data in an sqlite database.
Nested Class Summary | |
---|---|
static class |
SqliteJobQueue.JavaSerializer
|
static interface |
SqliteJobQueue.JobSerializer
|
Constructor Summary | |
---|---|
SqliteJobQueue(Context context,
long sessionId,
java.lang.String id,
SqliteJobQueue.JobSerializer jobSerializer)
|
Method Summary | |
---|---|
void |
clear()
clear all jobs in the queue. |
int |
count()
Returns the # of jobs that are waiting to be run |
int |
countReadyJobs(boolean hasNetwork,
java.util.Collection<java.lang.String> excludeGroups)
counts the # of jobs that can run now. |
JobHolder |
findJobById(long id)
returns the job with the given id if it exists in the queue |
java.lang.Long |
getNextJobDelayUntilNs(boolean hasNetwork)
returns when the next job should run (in nanoseconds), should return null if there are no jobs to run. |
long |
insert(JobHolder jobHolder)
Inserts the given JobHolder, assigns it a unique id and returns the id back Is called when a job is added |
long |
insertOrReplace(JobHolder jobHolder)
Does the same thing with insert but the only difference is that if job has an 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(boolean hasNetwork,
java.util.Collection<java.lang.String> excludeGroups)
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 |
remove(JobHolder jobHolder)
Removes the job from the data store. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SqliteJobQueue(Context context, long sessionId, java.lang.String id, SqliteJobQueue.JobSerializer jobSerializer)
context
- application contextsessionId
- session id should match JobManager
id
- uses this value to construct database name "db_" + id
Method Detail |
---|
public long insert(JobHolder jobHolder)
insert
in interface JobQueue
public long insertOrReplace(JobHolder jobHolder)
JobManager.NOT_RUNNING_SESSION_ID
Is called when a job is re-added (due to exception during run)
insertOrReplace
in interface JobQueue
public void remove(JobHolder jobHolder)
remove
in interface JobQueue
public int count()
count
in interface JobQueue
public int countReadyJobs(boolean hasNetwork, java.util.Collection<java.lang.String> excludeGroups)
JobQueue
countReadyJobs
in interface JobQueue
public JobHolder findJobById(long id)
findJobById
in interface JobQueue
id
- id of the job, returned by insert method
public JobHolder nextJobAndIncRunCount(boolean hasNetwork, java.util.Collection<java.lang.String> excludeGroups)
nextJobAndIncRunCount
in interface JobQueue
hasNetwork
- if true, should return any job, if false, should return jobs that do NOT require networkexcludeGroups
- if provided, jobs from these groups will NOT be returned
public java.lang.Long getNextJobDelayUntilNs(boolean hasNetwork)
getNextJobDelayUntilNs
in interface JobQueue
hasNetwork
- if true, should return nanoseconds for any job, if false, should return nanoseconds for next
job's delay until.
public void clear()
clear
in interface JobQueue
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |