org.apache.ode.scheduler.simple
Interface DatabaseDelegate

All Known Implementing Classes:
JdbcDelegate

public interface DatabaseDelegate

Database abstraction; provides all database access for the simple scheduler.


Method Summary
 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 nodeId, int x, int y, 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.
 int updateReassign(java.lang.String oldnode, java.lang.String newnode)
          Reassign jobs from one node to another.
 

Method Detail

insertJob

boolean insertJob(org.apache.ode.scheduler.simple.Job job,
                  java.lang.String nodeId,
                  boolean loaded)
                  throws DatabaseException
Save the job in the database.

Parameters:
job - the job
nodeId - 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)
Throws:
DatabaseException - in case of error

deleteJob

boolean deleteJob(java.lang.String jobid,
                  java.lang.String nodeId)
                  throws DatabaseException
Delete a job from the database.

Parameters:
jobid - job identifier
nodeId - node identifier
Throws:
DatabaseException - in case of error

getNodeIds

java.util.List<java.lang.String> getNodeIds()
                                            throws DatabaseException
Return a list of unique nodes identifiers found in the database. This is used to initialize the list of known nodes when a new node starts up.

Returns:
list of unique node identfiers found in the databaseuniqu
Throws:
DatabaseException

dequeueImmediate

java.util.List<org.apache.ode.scheduler.simple.Job> dequeueImmediate(java.lang.String nodeId,
                                                                     long maxtime,
                                                                     int maxjobs)
                                                                     throws DatabaseException
"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.

Parameters:
nodeId - node identifier of the jobs
maxtime - only jobs with scheduled time earlier than this will be dequeued
maxjobs - maximum number of jobs to deqeue
Returns:
list of jobs that met the criteria and were deleted from the database
Throws:
DatabaseException - in case of error

updateAssignToNode

int updateAssignToNode(java.lang.String nodeId,
                       int x,
                       int y,
                       long maxtime)
                       throws DatabaseException
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. Only a fraction of the jobs found are assigned the node identifier. This fraction is determined by the "y" parameter, while membership in the group (of jobs that get the nodeId) is determined by the "x" parameter. Essentially the logic is: UPDATE jobs AS job WHERE job.scheduledTime before :maxtime AND job.nodeId is null AND job.scheduledTime MOD :y == :x SET job.nodeId = :nodeId

Parameters:
nodeId - node identifier to assign to jobs
x - the result of the mod-division
y - the dividend of the mod-division
maxtime - only jobs with scheduled time earlier than this will be updated
Returns:
number of jobs updated
Throws:
DatabaseException - in case of error

updateReassign

int updateReassign(java.lang.String oldnode,
                   java.lang.String newnode)
                   throws DatabaseException
Reassign jobs from one node to another.

Parameters:
oldnode - node assigning from
newnode - new node asssigning to
Returns:
number of rows changed
Throws:
DatabaseException