|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.ode.scheduler.simple.SimpleScheduler
public class SimpleScheduler
A reliable and relatively simple scheduler that uses a database to persist information about scheduled tasks. The challenge 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.MapSerializableRunnable, Scheduler.Synchronizer |
Constructor Summary | |
---|---|
SimpleScheduler(java.lang.String nodeId,
DatabaseDelegate del,
java.util.Properties conf)
|
Method Summary | ||
---|---|---|
void |
cancelJob(java.lang.String jobId)
Make a good effort to cancel the job. |
|
|
execIsolatedTransaction(java.util.concurrent.Callable<T> transaction)
Same as execTransaction but executes in a different thread to guarantee isolation from the main execution thread. |
|
|
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. |
|
protected void |
runPolledRunnable(org.apache.ode.scheduler.simple.Job job)
Run a job from a polled runnable thread. |
|
void |
runTask(org.apache.ode.scheduler.simple.Task task)
|
|
java.lang.String |
scheduleMapSerializableRunnable(Scheduler.MapSerializableRunnable runnable,
java.util.Date when)
Schedule a Runnable that will be executed on a dedicated thread pool. |
|
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 |
setPolledRunnableProcesser(Scheduler.JobProcessor polledRunnableProcessor)
|
|
void |
setPollIntervalForPolledRunnable(long pollIntervalForPolledRunnable)
|
|
void |
setRollbackOnly()
|
|
void |
setStaleInterval(long staleInterval)
|
|
void |
setTransactionManager(javax.transaction.TransactionManager txm)
|
|
void |
setTransactionsPerSecond(int tps)
|
|
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 |
---|
public SimpleScheduler(java.lang.String nodeId, DatabaseDelegate del, java.util.Properties conf)
Method Detail |
---|
public void setPollIntervalForPolledRunnable(long pollIntervalForPolledRunnable)
public void setNodeId(java.lang.String nodeId)
public void setStaleInterval(long staleInterval)
public void setImmediateInterval(long immediateInterval)
public void setNearFutureInterval(long nearFutureInterval)
public void setTransactionsPerSecond(int tps)
public void setTransactionManager(javax.transaction.TransactionManager txm)
public void setDatabaseDelegate(DatabaseDelegate dbd)
public void setExecutorService(java.util.concurrent.ExecutorService executorService)
public void setPolledRunnableProcesser(Scheduler.JobProcessor polledRunnableProcessor)
setPolledRunnableProcesser
in interface Scheduler
public void cancelJob(java.lang.String jobId) throws ContextException
Scheduler
cancelJob
in interface Scheduler
jobId
- job identifier of the job
ContextException
public <T> java.util.concurrent.Future<T> execIsolatedTransaction(java.util.concurrent.Callable<T> transaction) throws java.lang.Exception, ContextException
Scheduler
execIsolatedTransaction
in interface Scheduler
java.lang.Exception
ContextException
public <T> T execTransaction(java.util.concurrent.Callable<T> transaction) throws java.lang.Exception, ContextException
Scheduler
Callable
in a transactional context. If the callable
throws an exception, then the transaction will be rolled back, otherwise
the transaction will commit.
execTransaction
in interface Scheduler
T
- return typetransaction
- transaction to execute
java.lang.Exception
ContextException
public void setRollbackOnly() throws java.lang.Exception
setRollbackOnly
in interface Scheduler
java.lang.Exception
public void registerSynchronizer(Scheduler.Synchronizer synch) throws ContextException
Scheduler
registerSynchronizer
in interface Scheduler
synch
- synchronizer
ContextException
public java.lang.String schedulePersistedJob(java.util.Map<java.lang.String,java.lang.Object> jobDetail, java.util.Date when) throws ContextException
Scheduler
schedulePersistedJob
in interface Scheduler
jobDetail
- information about the jobwhen
- when the job should run (null
means now)
ContextException
public java.lang.String scheduleMapSerializableRunnable(Scheduler.MapSerializableRunnable runnable, java.util.Date when) throws ContextException
Scheduler
scheduleMapSerializableRunnable
in interface Scheduler
ContextException
public java.lang.String scheduleVolatileJob(boolean transacted, java.util.Map<java.lang.String,java.lang.Object> jobDetail) throws ContextException
Scheduler
scheduleVolatileJob
in interface Scheduler
jobDetail
- information about the job
ContextException
public void setJobProcessor(Scheduler.JobProcessor processor) throws ContextException
setJobProcessor
in interface Scheduler
ContextException
public void shutdown()
shutdown
in interface Scheduler
public void start()
start
in interface Scheduler
public void stop()
stop
in interface Scheduler
protected void runJob(org.apache.ode.scheduler.simple.Job job)
job
- job to run.protected void runPolledRunnable(org.apache.ode.scheduler.simple.Job job)
job
- job to run.public boolean isTransacted()
isTransacted
in interface Scheduler
public void runTask(org.apache.ode.scheduler.simple.Task task)
public void updateHeartBeat(java.lang.String nodeId)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |