public class JdbcDelegate extends java.lang.Object implements DatabaseDelegate
DatabaseDelegate interface. Should work with most
reasonably behaved databases.| Constructor and Description |
|---|
JdbcDelegate(javax.sql.DataSource ds) |
| Modifier and Type | Method and Description |
|---|---|
void |
acquireTransactionLocks() |
boolean |
deleteJob(java.lang.String jobid,
java.lang.String nodeId)
Delete a job from the database.
|
java.util.List<org.apache.ode.scheduler.simple.Job> |
dequeueImmediate(java.lang.String nodeId,
long maxtime,
int maxjobs)
"Dequeue" jobs from the database that are ready for immediate execution; this basically
is a select/delete operation with constraints on the nodeId and scheduled time.
|
java.util.List<java.lang.String> |
getNodeIds()
Return a list of unique nodes identifiers found in the database.
|
boolean |
insertJob(org.apache.ode.scheduler.simple.Job job,
java.lang.String nodeId,
boolean loaded)
Save the job in the database.
|
int |
updateAssignToNode(java.lang.String node,
int i,
int numNodes,
long maxtime)
Assign a particular node identifier to a fraction of jobs in the database that do not have one,
and are up for execution within a certain time.
|
boolean |
updateJob(org.apache.ode.scheduler.simple.Job job)
Update the job in the database (only updates timestamp and retryCount)
|
int |
updateReassign(java.lang.String oldnode,
java.lang.String newnode)
Reassign jobs from one node to another.
|
public boolean deleteJob(java.lang.String jobid,
java.lang.String nodeId)
throws DatabaseException
DatabaseDelegatedeleteJob in interface DatabaseDelegatejobid - job identifiernodeId - node identifierDatabaseException - in case of errorpublic java.util.List<java.lang.String> getNodeIds()
throws DatabaseException
DatabaseDelegategetNodeIds in interface DatabaseDelegateDatabaseExceptionpublic boolean insertJob(org.apache.ode.scheduler.simple.Job job,
java.lang.String nodeId,
boolean loaded)
throws DatabaseException
DatabaseDelegateinsertJob in interface DatabaseDelegatejob - the jobnodeId - node assigned to the job (or null if no node has been asssigned)loaded - whether the job has been loaded into memory (i.e. in preperation for execution)DatabaseException - in case of errorpublic boolean updateJob(org.apache.ode.scheduler.simple.Job job)
throws DatabaseException
DatabaseDelegateupdateJob in interface DatabaseDelegatejob - the jobDatabaseException - in case of errorpublic java.util.List<org.apache.ode.scheduler.simple.Job> dequeueImmediate(java.lang.String nodeId,
long maxtime,
int maxjobs)
throws DatabaseException
DatabaseDelegatedequeueImmediate in interface DatabaseDelegatenodeId - node identifier of the jobsmaxtime - only jobs with scheduled time earlier than this will be dequeuedmaxjobs - maximum number of jobs to deqeueDatabaseException - in case of errorpublic int updateReassign(java.lang.String oldnode,
java.lang.String newnode)
throws DatabaseException
DatabaseDelegateupdateReassign in interface DatabaseDelegateoldnode - node assigning fromnewnode - new node asssigning toDatabaseExceptionpublic int updateAssignToNode(java.lang.String node,
int i,
int numNodes,
long maxtime)
throws DatabaseException
DatabaseDelegate
UPDATE jobs AS job
WHERE job.scheduledTime before :maxtime
AND job.nodeId is null
AND job.scheduledTime MOD :y == :x
SET job.nodeId = :nodeId
updateAssignToNode in interface DatabaseDelegatenode - node identifier to assign to jobsi - the result of the mod-divisionnumNodes - the dividend of the mod-divisionmaxtime - only jobs with scheduled time earlier than this will be updatedDatabaseException - in case of errorpublic void acquireTransactionLocks()
acquireTransactionLocks in interface DatabaseDelegate