Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.ode.scheduler.simple
Class JdbcDelegate

    java.lang.Object
      org.apache.ode.scheduler.simple.JdbcDelegate

All Implemented Interfaces:
  DatabaseDelegate

    public class JdbcDelegate

extends java.lang.Object
implements DatabaseDelegate

JDBC-based implementation of the `DatabaseDelegate` interface. Should work with most reasonably behaved databases.

Constructor Summary
`JdbcDelegate(javax.sql.DataSource ds)`

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

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### JdbcDelegate

    public JdbcDelegate(javax.sql.DataSource ds)

Method Detail

### deleteJob

    public boolean deleteJob(java.lang.String jobid,
                             java.lang.String nodeId)
                      throws DatabaseException

  Description copied from interface: `DatabaseDelegate`
  Delete a job from the database.

  Specified by:
    `deleteJob` in interface `DatabaseDelegate`
  Parameters:
    `jobid` - job identifier
    `nodeId` - node identifier
  Throws:
    `DatabaseException` - in case of error

### getNodeIds

    public java.util.List<java.lang.String> getNodeIds()
                                                throws DatabaseException

  Description copied from interface: `DatabaseDelegate`
  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.

  Specified by:
    `getNodeIds` in interface `DatabaseDelegate`
  Returns:
    list of unique node identfiers found in the databaseuniqu
  Throws:
    `DatabaseException`

### insertJob

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

  Description copied from interface: `DatabaseDelegate`
  Save the job in the database.

  Specified by:
    `insertJob` in interface `DatabaseDelegate`
  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

### dequeueImmediate

    public java.util.List<org.apache.ode.scheduler.simple.Job> dequeueImmediate(java.lang.String nodeId,
                                                                                long maxtime,
                                                                                int maxjobs)
                                                                         throws DatabaseException

  Description copied from interface: `DatabaseDelegate`
  "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.

  Specified by:
    `dequeueImmediate` in interface `DatabaseDelegate`
  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

### updateReassign

    public int updateReassign(java.lang.String oldnode,
                              java.lang.String newnode)
                       throws DatabaseException

  Description copied from interface: `DatabaseDelegate`
  Reassign jobs from one node to another.

  Specified by:
    `updateReassign` in interface `DatabaseDelegate`
  Parameters:
    `oldnode` - node assigning from
    `newnode` - new node asssigning to
  Returns:
    number of rows changed
  Throws:
    `DatabaseException`

### updateAssignToNode

    public int updateAssignToNode(java.lang.String node,
                                  int i,
                                  int numNodes,
                                  long maxtime)
                           throws DatabaseException

  Description copied from interface: `DatabaseDelegate`
  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`

  Specified by:
    `updateAssignToNode` in interface `DatabaseDelegate`
  Parameters:
    `node` - node identifier to assign to jobs
    `i` - the result of the mod-division
    `numNodes` - 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

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD