public class JobSchedulerImpl extends ServiceSupport implements Runnable, JobScheduler
Modifier and Type | Method and Description |
---|---|
void |
addListener(JobListener l) |
protected void |
doStart() |
protected void |
doStop(ServiceStopper stopper) |
List<Job> |
getAllJobs() |
List<Job> |
getAllJobs(long start,
long finish) |
protected List<org.apache.activemq.store.kahadb.scheduler.JobLocation> |
getAllScheduledJobs(Transaction tx)
Walks the Scheduled Job Tree and collects the add location and last update location
for all scheduled jobs.
|
String |
getName() |
List<Job> |
getNextScheduleJobs() |
long |
getNextScheduleTime() |
protected void |
mainLoop() |
protected void |
process(Transaction tx,
KahaAddScheduledJobCommand command,
Location location)
Adds a new Scheduled job to the index.
|
protected void |
process(Transaction tx,
KahaRemoveScheduledJobsCommand command,
Location location)
Removes all scheduled jobs within a given time range.
|
protected void |
process(Transaction tx,
KahaRescheduleJobCommand command,
Location location)
Reschedules a Job after it has be fired.
|
void |
remove(long time) |
void |
remove(String jobId) |
protected void |
removeAll(Transaction tx)
Removes all jobs from the schedulers index.
|
void |
removeAllJobs() |
void |
removeAllJobs(long start,
long finish) |
protected void |
removeInRange(Transaction tx,
long start,
long finish,
Location location)
Removes all scheduled jobs within the target range.
|
protected boolean |
removeJobAtTime(Transaction tx,
String jobId,
long executionTime)
Removes a Job from the index using it's Id value and the time it is currently set to
be executed.
|
void |
removeListener(JobListener l) |
void |
run() |
void |
schedule(String jobId,
ByteSequence payload,
long delay) |
void |
schedule(String jobId,
ByteSequence payload,
String cronEntry) |
void |
schedule(String jobId,
ByteSequence payload,
String cronEntry,
long delay,
long period,
int repeat) |
void |
setName(String name) |
void |
startDispatching() |
void |
stopDispatching() |
String |
toString() |
void |
write(DataOutput out) |
addServiceListener, dispose, isStarted, isStopped, isStopping, postStop, preStart, removeServiceListener, start, stop
public String getName()
getName
in interface JobScheduler
public void addListener(JobListener l)
addListener
in interface JobScheduler
public void removeListener(JobListener l)
removeListener
in interface JobScheduler
public void schedule(String jobId, ByteSequence payload, long delay) throws IOException
schedule
in interface JobScheduler
IOException
public void schedule(String jobId, ByteSequence payload, String cronEntry) throws Exception
schedule
in interface JobScheduler
Exception
public void schedule(String jobId, ByteSequence payload, String cronEntry, long delay, long period, int repeat) throws IOException
schedule
in interface JobScheduler
IOException
public void remove(long time) throws IOException
remove
in interface JobScheduler
IOException
public void remove(String jobId) throws IOException
remove
in interface JobScheduler
IOException
public void removeAllJobs() throws IOException
removeAllJobs
in interface JobScheduler
IOException
public void removeAllJobs(long start, long finish) throws IOException
removeAllJobs
in interface JobScheduler
IOException
public long getNextScheduleTime() throws IOException
getNextScheduleTime
in interface JobScheduler
IOException
public List<Job> getNextScheduleJobs() throws IOException
getNextScheduleJobs
in interface JobScheduler
IOException
public List<Job> getAllJobs() throws IOException
getAllJobs
in interface JobScheduler
IOException
public List<Job> getAllJobs(long start, long finish) throws IOException
getAllJobs
in interface JobScheduler
IOException
protected void process(Transaction tx, KahaAddScheduledJobCommand command, Location location) throws IOException
tx
- Transaction in which the update is performed.command
- The new scheduled job command to process.location
- The location where the add command is stored in the journal.IOException
- if an error occurs updating the index.protected void process(Transaction tx, KahaRescheduleJobCommand command, Location location) throws IOException
tx
- The TX under which the index is updated.command
- The reschedule command to process.location
- The location in the index where the reschedule command was stored.IOException
- if an error occurs during the reschedule.protected void process(Transaction tx, KahaRemoveScheduledJobsCommand command, Location location) throws IOException
tx
- The transaction under which the index is updated.command
- The remove command to process.location
- The location of the remove command in the Journal.IOException
- if an error occurs while updating the scheduler index.protected void removeAll(Transaction tx) throws IOException
tx
- The transaction under which the index entries for this scheduler are removed.IOException
- if an error occurs removing the jobs from the scheduler index.protected void removeInRange(Transaction tx, long start, long finish, Location location) throws IOException
tx
- The transaction under which the index is to be updated.start
- The start time for the remove operation.finish
- The end time for the remove operation.location
- (optional)
The location of the remove command that triggered this remove.IOException
- if an error occurs during the remove operation.protected boolean removeJobAtTime(Transaction tx, String jobId, long executionTime) throws IOException
tx
- the transaction under which this method is being executed.jobId
- the target Job Id to remove.executionTime
- the scheduled time that for the Job Id that is being removed.IOException
- if an error occurs while removing the Job.protected List<org.apache.activemq.store.kahadb.scheduler.JobLocation> getAllScheduledJobs(Transaction tx) throws IOException
tx
- the transaction under which this operation was invoked.IOException
- if an error occurs walking the scheduler tree.protected void mainLoop()
public void startDispatching() throws Exception
startDispatching
in interface JobScheduler
Exception
public void stopDispatching() throws Exception
stopDispatching
in interface JobScheduler
Exception
protected void doStart() throws Exception
doStart
in class ServiceSupport
Exception
protected void doStop(ServiceStopper stopper) throws Exception
doStop
in class ServiceSupport
Exception
public void write(DataOutput out) throws IOException
IOException
Copyright © 2005–2019 FuseSource, Corp.. All rights reserved.