public class QuartzScheduler extends Object implements IScheduler
IScheduler
IScheduler.SchedulerStatus
Modifier and Type | Field and Description |
---|---|
static String |
RESERVEDMAPKEY_ACTIONCLASS |
static String |
RESERVEDMAPKEY_ACTIONID |
static String |
RESERVEDMAPKEY_ACTIONUSER |
static String |
RESERVEDMAPKEY_LINEAGE_ID |
static String |
RESERVEDMAPKEY_RESTART_FLAG |
static String |
RESERVEDMAPKEY_STREAMPROVIDER |
static String |
RESERVEDMAPKEY_UIPASSPARAM |
Constructor and Description |
---|
QuartzScheduler() |
QuartzScheduler(org.quartz.SchedulerFactory schedulerFactory) |
Modifier and Type | Method and Description |
---|---|
void |
addListener(ISchedulerListener listener) |
static ComplexJobTrigger |
createComplexTrigger(String cronExpression) |
Job |
createJob(String jobName,
Class<? extends org.pentaho.platform.api.action.IAction> action,
Map<String,Serializable> jobParams,
IJobTrigger trigger)
Schedules a job to be run at one or more times in the future.
|
Job |
createJob(String jobName,
Class<? extends org.pentaho.platform.api.action.IAction> action,
Map<String,Serializable> jobParams,
IJobTrigger trigger,
IBackgroundExecutionStreamProvider outputStreamProvider)
Schedules a job to be run at one or more times in the future.
|
Job |
createJob(String jobName,
String actionId,
Map<String,Serializable> jobParams,
IJobTrigger trigger)
Schedules a job to be run at one or more times in the future.
|
Job |
createJob(String jobName,
String actionId,
Map<String,Serializable> jobParams,
IJobTrigger trigger,
IBackgroundExecutionStreamProvider outputStreamProvider)
Schedules a job to be run at one or more times in the future.
|
static org.quartz.Trigger |
createQuartzTrigger(IJobTrigger jobTrigger,
QuartzJobKey jobId) |
void |
fireJobCompleted(org.pentaho.platform.api.action.IAction actionBean,
String actionUser,
Map<String,Serializable> params,
IBackgroundExecutionStreamProvider streamProvider)
Not intended for public use.
|
Map<IScheduleSubject,ComplexJobTrigger> |
getAvailabilityWindows()
Gets the scheduler availability window for all subjects for whom a window has been set
|
Job |
getJob(String jobId)
Fetches a Job by jobId
|
List<IJobResult> |
getJobHistory(String jobId)
Returns a history of the runs for a particular job.
|
List<Job> |
getJobs(IJobFilter filter)
Lists currently scheduled jobs.
|
Integer |
getMinScheduleInterval(IScheduleSubject subject)
Get the minimum time that must elapse between job runs.
|
org.quartz.Scheduler |
getQuartzScheduler() |
IScheduler.SchedulerStatus |
getStatus()
Returns the current scheduler status.
|
ComplexJobTrigger |
getSubjectAvailabilityWindow(IScheduleSubject subject)
Gets the scheduler availability window to the specified subject
|
void |
pause()
Pauses the entire scheduler, which prevents all scheduled jobs from running.
|
void |
pauseJob(String jobId)
Prevents the specified job from running in the future.
|
static String |
prettyPrintMap(Map<String,Serializable> map) |
void |
removeJob(String jobId)
Removes the specified job from the list of scheduled jobs
|
void |
resumeJob(String jobId)
Allows previously paused jobs to resume running in the future.
|
void |
setAvailabilityWindows(Map<IScheduleSubject,ComplexJobTrigger> availability)
Replaces the scheduler availability map with the provided availability map.
|
void |
setListeners(Collection<ISchedulerListener> listeners) |
void |
setMinScheduleInterval(IScheduleSubject subject,
int intervalInSeconds)
Sets the minimum time that must elapse between runs of any jobs.
|
void |
setQuartzSchedulerFactory(org.quartz.SchedulerFactory quartzSchedulerFactory)
Overrides the default Quartz
SchedulerFactory . |
void |
setSubjectAvailabilityWindow(IScheduleSubject subject,
ComplexJobTrigger availability)
Sets when a particular subject is allowed to schedule jobs.
|
void |
shutdown()
Shuts the scheduler down so it will process no more jobs.
|
void |
start()
Allows the scheduler to process scheduled jobs.
|
void |
triggerNow(String jobId)
Triggers the given quartz job by jobId to be executed immediately
|
void |
updateJob(String jobId,
Map<String,Serializable> jobParams,
IJobTrigger trigger)
Updates both the parameters and trigger to be used to execute an existing scheduled action.
|
public static final String RESERVEDMAPKEY_ACTIONCLASS
public static final String RESERVEDMAPKEY_ACTIONUSER
public static final String RESERVEDMAPKEY_ACTIONID
public static final String RESERVEDMAPKEY_STREAMPROVIDER
public static final String RESERVEDMAPKEY_UIPASSPARAM
public static final String RESERVEDMAPKEY_LINEAGE_ID
public static final String RESERVEDMAPKEY_RESTART_FLAG
public QuartzScheduler(org.quartz.SchedulerFactory schedulerFactory)
public QuartzScheduler()
public void setQuartzSchedulerFactory(org.quartz.SchedulerFactory quartzSchedulerFactory) throws SchedulerException
SchedulerFactory
. Note: depending on the type of scheduler you are setting
here, there may be initializing required prior to this setter being called. Only the
SchedulerFactory.getScheduler()
will be called later, so the factory set here must already be in a state
where that invocation will be successful.quartzSchedulerFactory
- the quartz factory to use for generating scheduler instancesSchedulerException
public org.quartz.Scheduler getQuartzScheduler() throws org.quartz.SchedulerException
org.quartz.SchedulerException
public Job createJob(String jobName, String actionId, Map<String,Serializable> jobParams, IJobTrigger trigger) throws SchedulerException
createJob
in interface IScheduler
jobName
- the user defined name for the jobactionId
- the bean Id of the action to be run as defined an a plugin's plugin.xmljobParams
- the parameters to be passed to the action when it runstrigger
- the time(s) at which to run the actionSchedulerException
- If the job could not be scheduledpublic Job createJob(String jobName, Class<? extends org.pentaho.platform.api.action.IAction> action, Map<String,Serializable> jobParams, IJobTrigger trigger) throws SchedulerException
createJob
in interface IScheduler
jobName
- the user defined name for the jobaction
- the action to be run at the scheduled time(s)jobParams
- the parameters to be passed to the action when it runstrigger
- the time(s) at which to run the actionSchedulerException
- If the job could not be scheduledpublic Job createJob(String jobName, Class<? extends org.pentaho.platform.api.action.IAction> action, Map<String,Serializable> jobParams, IJobTrigger trigger, IBackgroundExecutionStreamProvider outputStreamProvider) throws SchedulerException
createJob
in interface IScheduler
jobName
- the user defined name for the jobaction
- the action to be run at the scheduled time(s)jobParams
- the parameters to be passed to the action when it runstrigger
- the time(s) at which to run the actionoutputStreamProvider
- if the action being scheduled expects to write to an output stream, at the time of action execution the
this provider will be used to create the stream that passed to the action.SchedulerException
- If the job could not be scheduledpublic Job createJob(String jobName, String actionId, Map<String,Serializable> jobParams, IJobTrigger trigger, IBackgroundExecutionStreamProvider outputStreamProvider) throws SchedulerException
createJob
in interface IScheduler
jobName
- the user defined name for the jobactionId
- the bean Id of the action to be run as defined an a plugin's plugin.xmljobParams
- the parameters to be passed to the action when it runstrigger
- the time(s) at which to run the actionoutputStreamProvider
- if the action being scheduled expects to write to an output stream, at the time of action execution the
this provider will be used to create the stream that passed to the action.SchedulerException
- If the job could not be scheduledpublic static org.quartz.Trigger createQuartzTrigger(IJobTrigger jobTrigger, QuartzJobKey jobId) throws SchedulerException
SchedulerException
public void updateJob(String jobId, Map<String,Serializable> jobParams, IJobTrigger trigger) throws SchedulerException
IScheduler
updateJob
in interface IScheduler
jobId
- the ID of an existing scheduled jobjobParams
- the parameters to be passed to the action when it runstrigger
- the time(s) at which to run the actionSchedulerException
- If the job could not be updatedpublic Map<IScheduleSubject,ComplexJobTrigger> getAvailabilityWindows()
getAvailabilityWindows
in interface IScheduler
public List<IJobResult> getJobHistory(String jobId)
getJobHistory
in interface IScheduler
jobId
- the job for which to query it's execution historypublic void triggerNow(String jobId) throws SchedulerException
triggerNow
in interface IScheduler
jobId
- the job to be executedSchedulerException
public Job getJob(String jobId) throws SchedulerException
getJob
in interface IScheduler
jobId
- the job to be returnedSchedulerException
public List<Job> getJobs(IJobFilter filter) throws SchedulerException
getJobs
in interface IScheduler
filter
- the filter to use to determine which jobs to return. If null all scheduled jobs are return.SchedulerException
public Integer getMinScheduleInterval(IScheduleSubject subject)
getMinScheduleInterval
in interface IScheduler
subject
- the subject whose min interval is being requested return the minimum interval or null if no interval has
been setpublic ComplexJobTrigger getSubjectAvailabilityWindow(IScheduleSubject subject)
getSubjectAvailabilityWindow
in interface IScheduler
subject
- the subject whose window is being requestedpublic void pause() throws SchedulerException
pause
in interface IScheduler
SchedulerException
public void pauseJob(String jobId) throws SchedulerException
pauseJob
in interface IScheduler
jobId
- the job to be pausedSchedulerException
public void removeJob(String jobId) throws SchedulerException
removeJob
in interface IScheduler
jobId
- the job to be removedSchedulerException
public void start() throws SchedulerException
start
in interface IScheduler
SchedulerException
public void resumeJob(String jobId) throws SchedulerException
resumeJob
in interface IScheduler
jobId
- the job to be resumedSchedulerException
public void setAvailabilityWindows(Map<IScheduleSubject,ComplexJobTrigger> availability)
setAvailabilityWindows
in interface IScheduler
availability
- the new scheduler availability mappublic void setMinScheduleInterval(IScheduleSubject subject, int intervalInSeconds)
setMinScheduleInterval
in interface IScheduler
subject
- the subject to which the interval appliespublic void setSubjectAvailabilityWindow(IScheduleSubject subject, ComplexJobTrigger availability)
setSubjectAvailabilityWindow
in interface IScheduler
subject
- the subject to which the subject appliesavailability
- the window of time at which the scheduler is availablepublic static ComplexJobTrigger createComplexTrigger(String cronExpression)
public IScheduler.SchedulerStatus getStatus() throws SchedulerException
getStatus
in interface IScheduler
SchedulerException
public void shutdown() throws SchedulerException
shutdown
in interface IScheduler
SchedulerException
public static String prettyPrintMap(Map<String,Serializable> map)
public void addListener(ISchedulerListener listener)
addListener
in interface IScheduler
public void setListeners(Collection<ISchedulerListener> listeners)
public void fireJobCompleted(org.pentaho.platform.api.action.IAction actionBean, String actionUser, Map<String,Serializable> params, IBackgroundExecutionStreamProvider streamProvider)
IScheduler
fireJobCompleted
in interface IScheduler