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 SimpleScheduler

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

All Implemented Interfaces:
  Scheduler

    public class SimpleScheduler

extends java.lang.Object
implements Scheduler

A reliable and relatively simple scheduler that uses a database to persist information about scheduled tasks. The challange is to achieve high performance in a small memory footprint without loss of reliability while supporting distributed/clustered configurations. The design is based around three time horizons: "immediate", "near future", and "everything else". Immediate jobs (i.e. jobs that are about to be up) are written to the database and kept in an in-memory priority queue. When they execute, they are removed from the database. Near future jobs are placed in the database and assigned to the current node, however they are not stored in memory. Periodically jobs are "upgraded" from near-future to immediate status, at which point they get loaded into memory. Jobs that are further out in time, are placed in the database without a node identifer; when they are ready to be "upgraded" to near-future jobs they are assigned to one of the known live nodes. Recovery is rather straighforward, with stale node identifiers being reassigned to known good nodes.

Nested Class Summary

Nested classes/interfaces inherited from interface org.apache.ode.bpel.iapi.Scheduler
`Scheduler.JobInfo, Scheduler.JobProcessor, Scheduler.JobProcessorException, Scheduler.Synchronizer`

Constructor Summary
`SimpleScheduler(java.lang.String nodeId, DatabaseDelegate del)`

Method Summary
`void` | `cancelJob(java.lang.String jobId)` Make a good effort to cancel the job.
`
`<T> java.util.concurrent.Future<T>`
` | `execIsolatedTransaction(java.util.concurrent.Callable<T> transaction)` Same as execTransaction but executes in a different thread to guarantee isolation from the main execution thread.
`
`<T> T`
` | `execTransaction(java.util.concurrent.Callable<T> transaction)` Execute a `Callable` in a transactional context.
`boolean` | `isTransacted()`
`void` | `registerSynchronizer(Scheduler.Synchronizer synch)` Register a transaction synchronizer.
`protected void` | `runJob(org.apache.ode.scheduler.simple.Job job)` Run a job in the current thread.
`void` | `runTask(org.apache.ode.scheduler.simple.Task task)`
`java.lang.String` | `schedulePersistedJob(java.util.Map<java.lang.String,java.lang.Object> jobDetail, java.util.Date when)` Schedule a persisted job.
`java.lang.String` | `scheduleVolatileJob(boolean transacted, java.util.Map<java.lang.String,java.lang.Object> jobDetail)` Schedule a volatile (non-persisted) job.
`void` | `setDatabaseDelegate(DatabaseDelegate dbd)`
`void` | `setExecutorService(java.util.concurrent.ExecutorService executorService)`
`void` | `setImmediateInterval(long immediateInterval)`
`void` | `setJobProcessor(Scheduler.JobProcessor processor)`
`void` | `setNearFutureInterval(long nearFutureInterval)`
`void` | `setNodeId(java.lang.String nodeId)`
`void` | `setStaleInterval(long staleInterval)`
`void` | `setTransactionManager(javax.transaction.TransactionManager txm)`
`void` | `shutdown()`
`void` | `start()`
`void` | `stop()`
`void` | `updateHeartBeat(java.lang.String nodeId)`

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

Constructor Detail

### SimpleScheduler

    public SimpleScheduler(java.lang.String nodeId,
                           DatabaseDelegate del)

Method Detail

### setNodeId

    public void setNodeId(java.lang.String nodeId)

### setStaleInterval

    public void setStaleInterval(long staleInterval)

### setImmediateInterval

    public void setImmediateInterval(long immediateInterval)

### setNearFutureInterval

    public void setNearFutureInterval(long nearFutureInterval)

### setTransactionManager

    public void setTransactionManager(javax.transaction.TransactionManager txm)

### setDatabaseDelegate

    public void setDatabaseDelegate(DatabaseDelegate dbd)

### setExecutorService

    public void setExecutorService(java.util.concurrent.ExecutorService executorService)

### cancelJob

    public void cancelJob(java.lang.String jobId)
                   throws ContextException

  Description copied from interface: `Scheduler`
  Make a good effort to cancel the job. If its already running no big deal.

  Specified by:
    `cancelJob` in interface `Scheduler`
  Parameters:
    `jobId` - job identifier of the job
  Throws:
    `ContextException`

### execIsolatedTransaction

    public <T> java.util.concurrent.Future<T> execIsolatedTransaction(java.util.concurrent.Callable<T> transaction)
                                                           throws java.lang.Exception,
                                                                  ContextException

  Description copied from interface: `Scheduler`
  Same as execTransaction but executes in a different thread to guarantee isolation from the main execution thread.

  Specified by:
    `execIsolatedTransaction` in interface `Scheduler`
  Returns:
  Throws:
    `java.lang.Exception`
    `ContextException`

### execTransaction

    public <T> T execTransaction(java.util.concurrent.Callable<T> transaction)
                      throws java.lang.Exception,
                             ContextException

  Description copied from interface: `Scheduler`
  Execute a `Callable` in a transactional context. If the callable throws an exception, then the transaction will be rolled back, otherwise the transaction will commit.

  Specified by:
    `execTransaction` in interface `Scheduler`
  Type Parameters:
    `T` - return type
  Parameters:
    `transaction` - transaction to execute
  Returns:
    result
  Throws:
    `java.lang.Exception`
    `ContextException`

### registerSynchronizer

    public void registerSynchronizer(Scheduler.Synchronizer synch)
                              throws ContextException

  Description copied from interface: `Scheduler`
  Register a transaction synchronizer.

  Specified by:
    `registerSynchronizer` in interface `Scheduler`
  Parameters:
    `synch` - synchronizer
  Throws:
    `ContextException`

### schedulePersistedJob

    public java.lang.String schedulePersistedJob(java.util.Map<java.lang.String,java.lang.Object> jobDetail,
                                                 java.util.Date when)
                                          throws ContextException

  Description copied from interface: `Scheduler`
  Schedule a persisted job. Persisted jobs MUST survive system failure. They also must not be scheduled unless the transaction associated with the calling thread commits.

  Specified by:
    `schedulePersistedJob` in interface `Scheduler`
  Parameters:
    `jobDetail` - information about the job
    `when` - when the job should run (`null` means now)
  Returns:
    unique job identifier
  Throws:
    `ContextException`

### scheduleVolatileJob

    public java.lang.String scheduleVolatileJob(boolean transacted,
                                                java.util.Map<java.lang.String,java.lang.Object> jobDetail)
                                         throws ContextException

  Description copied from interface: `Scheduler`
  Schedule a volatile (non-persisted) job. Volatile jobs should not be saved in the database and should not survive system crash. Volatile jobs scheduled from a transactional context should be scheduled regardless of whether the transaction commits.

  Specified by:
    `scheduleVolatileJob` in interface `Scheduler`
    `jobDetail` - information about the job
  Returns:
    unique (as far as the scheduler is concerned) job identifier
  Throws:
    `ContextException`

### setJobProcessor

    public void setJobProcessor(Scheduler.JobProcessor processor)
                         throws ContextException

  Specified by:
    `setJobProcessor` in interface `Scheduler`
  Throws:
    `ContextException`

### shutdown

    public void shutdown()

  Specified by:
    `shutdown` in interface `Scheduler`

### start

    public void start()

  Specified by:
    `start` in interface `Scheduler`

### stop

    public void stop()

  Specified by:
    `stop` in interface `Scheduler`

### runJob

    protected void runJob(org.apache.ode.scheduler.simple.Job job)

  Run a job in the current thread.

  Parameters:
    `job` - job to run.

### isTransacted

    public boolean isTransacted()

  Specified by:
    `isTransacted` in interface `Scheduler`
  Returns:
    true if the current thread is associated with a transaction.

### runTask

    public void runTask(org.apache.ode.scheduler.simple.Task task)

### updateHeartBeat

    public void updateHeartBeat(java.lang.String nodeId)

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