Class QuartzScheduler

    • Constructor Detail

      • QuartzScheduler

        public QuartzScheduler​(org.quartz.SchedulerFactory schedulerFactory)
      • QuartzScheduler

        public QuartzScheduler()
    • Method Detail

      • setQuartzSchedulerFactory

        public void setQuartzSchedulerFactory​(org.quartz.SchedulerFactory quartzSchedulerFactory)
                                       throws SchedulerException
        Overrides the default Quartz 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.
        Parameters:
        quartzSchedulerFactory - the quartz factory to use for generating scheduler instances
        Throws:
        SchedulerException
      • getQuartzScheduler

        public org.quartz.Scheduler getQuartzScheduler()
                                                throws org.quartz.SchedulerException
        Throws:
        org.quartz.SchedulerException
      • createJob

        public Job createJob​(String jobName,
                             String actionId,
                             Map<String,​Serializable> jobParams,
                             IJobTrigger trigger)
                      throws SchedulerException
        Schedules a job to be run at one or more times in the future.
        Specified by:
        createJob in interface IScheduler
        Parameters:
        jobName - the user defined name for the job
        actionId - the bean Id of the action to be run as defined an a plugin's plugin.xml
        jobParams - the parameters to be passed to the action when it runs
        trigger - the time(s) at which to run the action
        Returns:
        the scheduled job
        Throws:
        SchedulerException - If the job could not be scheduled
      • createJob

        public Job createJob​(String jobName,
                             Class<? extends org.pentaho.platform.api.action.IAction> action,
                             Map<String,​Serializable> jobParams,
                             IJobTrigger trigger)
                      throws SchedulerException
        Schedules a job to be run at one or more times in the future.
        Specified by:
        createJob in interface IScheduler
        Parameters:
        jobName - the user defined name for the job
        action - the action to be run at the scheduled time(s)
        jobParams - the parameters to be passed to the action when it runs
        trigger - the time(s) at which to run the action
        Returns:
        the scheduled job
        Throws:
        SchedulerException - If the job could not be scheduled
      • createJob

        public Job createJob​(String jobName,
                             Class<? extends org.pentaho.platform.api.action.IAction> action,
                             Map<String,​Serializable> jobParams,
                             IJobTrigger trigger,
                             IBackgroundExecutionStreamProvider outputStreamProvider)
                      throws SchedulerException
        Schedules a job to be run at one or more times in the future.
        Specified by:
        createJob in interface IScheduler
        Parameters:
        jobName - the user defined name for the job
        action - the action to be run at the scheduled time(s)
        jobParams - the parameters to be passed to the action when it runs
        trigger - the time(s) at which to run the action
        outputStreamProvider - 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.
        Returns:
        the scheduled job
        Throws:
        SchedulerException - If the job could not be scheduled
      • createJob

        public Job createJob​(String jobName,
                             String actionId,
                             Map<String,​Serializable> jobParams,
                             IJobTrigger trigger,
                             IBackgroundExecutionStreamProvider outputStreamProvider)
                      throws SchedulerException
        Schedules a job to be run at one or more times in the future.
        Specified by:
        createJob in interface IScheduler
        Parameters:
        jobName - the user defined name for the job
        actionId - the bean Id of the action to be run as defined an a plugin's plugin.xml
        jobParams - the parameters to be passed to the action when it runs
        trigger - the time(s) at which to run the action
        outputStreamProvider - 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.
        Returns:
        the scheduled job
        Throws:
        SchedulerException - If the job could not be scheduled
      • updateJob

        public void updateJob​(String jobId,
                              Map<String,​Serializable> jobParams,
                              IJobTrigger trigger)
                       throws SchedulerException
        Description copied from interface: IScheduler
        Updates both the parameters and trigger to be used to execute an existing scheduled action.
        Specified by:
        updateJob in interface IScheduler
        Parameters:
        jobId - the ID of an existing scheduled job
        jobParams - the parameters to be passed to the action when it runs
        trigger - the time(s) at which to run the action
        Throws:
        SchedulerException - If the job could not be updated
      • getJobHistory

        public List<IJobResult> getJobHistory​(String jobId)
        Returns a history of the runs for a particular job.
        Specified by:
        getJobHistory in interface IScheduler
        Parameters:
        jobId - the job for which to query it's execution history
        Returns:
        the execution history for the given job
      • setJobNextRun

        protected void setJobNextRun​(Job job,
                                     org.quartz.Trigger trigger)
      • getMinScheduleInterval

        public Integer getMinScheduleInterval​(IScheduleSubject subject)
        Get the minimum time that must elapse between job runs.
        Specified by:
        getMinScheduleInterval in interface IScheduler
        Parameters:
        subject - the subject whose min interval is being requested return the minimum interval or null if no interval has been set
      • getSubjectAvailabilityWindow

        public ComplexJobTrigger getSubjectAvailabilityWindow​(IScheduleSubject subject)
        Gets the scheduler availability window to the specified subject
        Specified by:
        getSubjectAvailabilityWindow in interface IScheduler
        Parameters:
        subject - the subject whose window is being requested
        Returns:
        the subject's availability window
      • pause

        public void pause()
                   throws SchedulerException
        Pauses the entire scheduler, which prevents all scheduled jobs from running. Any currently running jobs are allowed to complete. Note that the "paused" state of individual jobs is not changed by this call.
        Specified by:
        pause in interface IScheduler
        Throws:
        SchedulerException
      • pauseJob

        public void pauseJob​(String jobId)
                      throws SchedulerException
        Prevents the specified job from running in the future. The job remains in the list of scheduled jobs in a "paused" state. If the job is currently running, the currently running job is allowed to complete.
        Specified by:
        pauseJob in interface IScheduler
        Parameters:
        jobId - the job to be paused
        Throws:
        SchedulerException
      • setMinScheduleInterval

        public void setMinScheduleInterval​(IScheduleSubject subject,
                                           int intervalInSeconds)
        Sets the minimum time that must elapse between runs of any jobs. For example if set to "5" then a job may not be scheduled to run less than 5 seconds apart.
        Specified by:
        setMinScheduleInterval in interface IScheduler
        Parameters:
        subject - the subject to which the interval applies
        intervalInSeconds - the interval in seconds
      • setSubjectAvailabilityWindow

        public void setSubjectAvailabilityWindow​(IScheduleSubject subject,
                                                 ComplexJobTrigger availability)
        Sets when a particular subject is allowed to schedule jobs.
        Specified by:
        setSubjectAvailabilityWindow in interface IScheduler
        Parameters:
        subject - the subject to which the subject applies
        availability - the window of time at which the scheduler is available
      • getCurrentUser

        protected String getCurrentUser()
        Returns:
      • shutdown

        public void shutdown()
                      throws SchedulerException
        Shuts the scheduler down so it will process no more jobs. The implementation will decide if this means kill jobs in progress or let them finish.
        Specified by:
        shutdown in interface IScheduler
        Throws:
        SchedulerException
      • validateJobParams

        public void validateJobParams​(Map<String,​Serializable> jobParams)
                               throws SchedulerException
        Checks if the text configuration for the input/output files is present. If not - silently returns. If present checks if the input file is allowed to be scheduled.
        Specified by:
        validateJobParams in interface IScheduler
        Parameters:
        jobParams - scheduling job parameters
        Throws:
        SchedulerException - the configuration is recognized but the file can't be scheduled, is a folder or doesn't exist.