org.kuali.kfs.sys.batch.service.impl
Class SchedulerServiceImpl

java.lang.Object
  extended by org.kuali.kfs.sys.batch.service.impl.SchedulerServiceImpl
All Implemented Interfaces:
SchedulerService

@Transactional
public class SchedulerServiceImpl
extends Object
implements SchedulerService


Field Summary
protected  Map<String,JobDescriptor> externalizedJobDescriptors
          Holds a list of job name to job descriptor mappings for those jobs that are externalized (i.e.
protected static String HARD_DEPENDENCY_CODE
           
static String JOB_STATUS_PARAMETER
           
protected static List<String> jobStatuses
           
protected static String SCHEDULE_JOB_NAME
           
protected static String SOFT_DEPENDENCY_CODE
           
 
Fields inherited from interface org.kuali.kfs.sys.batch.service.SchedulerService
CANCELLED_JOB_STATUS_CODE, FAILED_JOB_STATUS_CODE, PENDING_JOB_STATUS_CODE, RUNNING_JOB_STATUS_CODE, SCHEDULED_GROUP, SCHEDULED_JOB_STATUS_CODE, SUCCEEDED_JOB_STATUS_CODE, UNSCHEDULED_GROUP
 
Constructor Summary
SchedulerServiceImpl()
           
 
Method Summary
protected  void addJob(org.quartz.JobDetail jobDetail)
           
 void addScheduled(org.quartz.JobDetail job)
          Adds the given job to the "scheduled" group.
protected  void addTrigger(org.quartz.Trigger trigger)
           
 void addUnscheduled(org.quartz.JobDetail job)
          Adds the given job to the "unscheduled" group.
 BatchJobStatus getJob(String groupName, String jobName)
          Gets a single job based on its name and group.
protected  Map<String,String> getJobDependencies(String jobName)
           
 List<BatchJobStatus> getJobs()
          Get all jobs known to the scheduler wrapped within a BusinessObject-derived class.
 List<BatchJobStatus> getJobs(String groupName)
           
 List<String> getJobStatuses()
          Returns a list of all possible statuses.
 Date getNextStartTime(BatchJobStatus job)
          Returns the next start time for the given job.
 Date getNextStartTime(String groupName, String jobName)
          Returns the next start time for the given job.
 List<org.quartz.JobExecutionContext> getRunningJobs()
          Returns the list of job currently running within the scheduler.
protected  org.quartz.JobDetail getScheduledJobDetail(String jobName)
           
 List<String> getSchedulerGroups()
          Returns a list of all groups defined in the scheduler.
 String getStatus(org.quartz.JobDetail jobDetail)
           
 boolean hasIncompleteJob()
          This method checks whether any jobs in the SCHEDULED job group are pending or currently scheduled.
 void initialize()
           
 void initializeJob(String jobName, Job job)
           
protected  void initializeJobsForModule(org.kuali.rice.kns.service.ModuleService moduleService)
          Initializes all of the jobs into Quartz for the given ModuleService
protected  void initializeTriggersForModule(org.kuali.rice.kns.service.ModuleService moduleService)
          Loops through all the triggers associated with the given module service, adding each trigger to Quartz
 void interruptJob(String jobName)
          Requests that the given job be stopped as soon as possble.
protected  boolean isCancelled(org.quartz.JobDetail jobDetail)
           
protected  boolean isDependencySatisfiedNegatively(org.quartz.JobDetail dependentJobDetail, org.quartz.JobDetail dependencyJobDetail)
           
protected  boolean isDependencySatisfiedPositively(org.quartz.JobDetail dependentJobDetail, org.quartz.JobDetail dependencyJobDetail)
           
protected  boolean isFailed(org.quartz.JobDetail jobDetail)
           
protected  boolean isIncomplete(org.quartz.JobDetail scheduledJobDetail)
           
 boolean isJobRunning(String jobName)
          Tests whether the referenced job name is running, regardless of group.
 boolean isPastScheduleCutoffTime()
          This method should be used to determine when the daily batch schedule should terminate.
protected  boolean isPastScheduleCutoffTime(Calendar dateTime, boolean log)
           
protected  boolean isPending(org.quartz.JobDetail jobDetail)
           
protected  boolean isScheduled(org.quartz.JobDetail jobDetail)
           
protected  boolean isSoftDependency(String dependentJobName, String dependencyJobName)
           
protected  boolean isSucceeded(org.quartz.JobDetail jobDetail)
           
protected  void loadJob(JobDescriptor jobDescriptor)
           
 void logScheduleResults()
           
 void processWaitingJobs()
           
 void reinitializeScheduledJobs()
           
 void removeScheduled(String jobName)
          Removes a job from the scheduled group.
protected  JobDescriptor retrieveJobDescriptor(String jobName)
           
 void runJob(String jobName, int startStep, int stopStep, Date startTime, String requestorEmailAddress)
          Immediately runs the specified job.
 void runJob(String jobName, String requestorEmailAddress)
          Immediately runs the specified job.
 void runJob(String groupName, String jobName, int startStep, int stopStep, Date jobStartTime, String requestorEmailAddress)
           
 void runStep(String groupName, String jobName, String stepName, Date startTime, String requestorEmailAddress)
           
protected  void scheduleJob(String groupName, String jobName, int startStep, int endStep, Date startTime, String requestorEmailAddress)
           
 void setDateTimeService(org.kuali.rice.kns.service.DateTimeService dateTimeService)
          Sets the dateTimeService attribute value.
 void setJobListener(JobListener jobListener)
          Sets the jobListener attribute value.
 void setKualiModuleService(org.kuali.rice.kns.service.KualiModuleService moduleService)
          Sets the moduleService attribute value.
 void setMailService(org.kuali.rice.kns.service.MailService mailService)
           
 void setParameterService(org.kuali.rice.kns.service.ParameterService parameterService)
           
 void setScheduler(org.quartz.Scheduler scheduler)
          Sets the scheduler attribute value.
protected  boolean shouldCancelJob(org.quartz.JobDetail jobDetail)
           
 boolean shouldNotRun(org.quartz.JobDetail jobDetail)
           
protected  boolean shouldScheduleJob(org.quartz.JobDetail jobDetail)
           
 void updateStatus(org.quartz.JobDetail jobDetail, String jobStatus)
           
protected  void updateStatus(String groupName, String jobName, String jobStatus)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCHEDULE_JOB_NAME

protected static final String SCHEDULE_JOB_NAME
See Also:
Constant Field Values

JOB_STATUS_PARAMETER

public static final String JOB_STATUS_PARAMETER
See Also:
Constant Field Values

SOFT_DEPENDENCY_CODE

protected static final String SOFT_DEPENDENCY_CODE
See Also:
Constant Field Values

HARD_DEPENDENCY_CODE

protected static final String HARD_DEPENDENCY_CODE
See Also:
Constant Field Values

externalizedJobDescriptors

protected Map<String,JobDescriptor> externalizedJobDescriptors
Holds a list of job name to job descriptor mappings for those jobs that are externalized (i.e. the module service is responsible for reporting their status)


jobStatuses

protected static final List<String> jobStatuses
Constructor Detail

SchedulerServiceImpl

public SchedulerServiceImpl()
Method Detail

initialize

public void initialize()
Specified by:
initialize in interface SchedulerService
See Also:
SchedulerService.initialize()

initializeJobsForModule

protected void initializeJobsForModule(org.kuali.rice.kns.service.ModuleService moduleService)
Initializes all of the jobs into Quartz for the given ModuleService

Parameters:
moduleService - the ModuleService implementation to initalize jobs for

initializeTriggersForModule

protected void initializeTriggersForModule(org.kuali.rice.kns.service.ModuleService moduleService)
Loops through all the triggers associated with the given module service, adding each trigger to Quartz

Parameters:
moduleService - the ModuleService instance to initialize triggers for

loadJob

protected void loadJob(JobDescriptor jobDescriptor)

initializeJob

public void initializeJob(String jobName,
                          Job job)
Specified by:
initializeJob in interface SchedulerService
See Also:
SchedulerService.initializeJob(java.lang.String,org.kuali.kfs.sys.batch.Job)

hasIncompleteJob

public boolean hasIncompleteJob()
Description copied from interface: SchedulerService
This method checks whether any jobs in the SCHEDULED job group are pending or currently scheduled.

Specified by:
hasIncompleteJob in interface SchedulerService
Returns:
hasIncompleteJob
See Also:
SchedulerService.hasIncompleteJob()

isIncomplete

protected boolean isIncomplete(org.quartz.JobDetail scheduledJobDetail)

isPastScheduleCutoffTime

public boolean isPastScheduleCutoffTime()
Description copied from interface: SchedulerService
This method should be used to determine when the daily batch schedule should terminate. It compares the start time of the schedule job from quartz with a time specified by the scheduleStep_CUTOFF_TIME system parameter in the SYSTEM security group on the day after the schedule job started running.

Specified by:
isPastScheduleCutoffTime in interface SchedulerService
Returns:
pastScheduleCutoffTime
See Also:
SchedulerService.isPastScheduleCutoffTime()

isPastScheduleCutoffTime

protected boolean isPastScheduleCutoffTime(Calendar dateTime,
                                           boolean log)

processWaitingJobs

public void processWaitingJobs()
Specified by:
processWaitingJobs in interface SchedulerService
See Also:
SchedulerService.processWaitingJobs()

logScheduleResults

public void logScheduleResults()
Specified by:
logScheduleResults in interface SchedulerService
See Also:
SchedulerService.logScheduleResults()

shouldNotRun

public boolean shouldNotRun(org.quartz.JobDetail jobDetail)
Specified by:
shouldNotRun in interface SchedulerService
See Also:
SchedulerService.shouldNotRun(org.quartz.JobDetail)

updateStatus

public void updateStatus(org.quartz.JobDetail jobDetail,
                         String jobStatus)
Specified by:
updateStatus in interface SchedulerService
See Also:
SchedulerService.updateStatus(org.quartz.JobDetail,java.lang.String jobStatus)

runJob

public void runJob(String jobName,
                   String requestorEmailAddress)
Description copied from interface: SchedulerService
Immediately runs the specified job.

Specified by:
runJob in interface SchedulerService

runJob

public void runJob(String jobName,
                   int startStep,
                   int stopStep,
                   Date startTime,
                   String requestorEmailAddress)
Description copied from interface: SchedulerService
Immediately runs the specified job.

Specified by:
runJob in interface SchedulerService

runJob

public void runJob(String groupName,
                   String jobName,
                   int startStep,
                   int stopStep,
                   Date jobStartTime,
                   String requestorEmailAddress)

runStep

public void runStep(String groupName,
                    String jobName,
                    String stepName,
                    Date startTime,
                    String requestorEmailAddress)

isJobRunning

public boolean isJobRunning(String jobName)
Description copied from interface: SchedulerService
Tests whether the referenced job name is running, regardless of group.

Specified by:
isJobRunning in interface SchedulerService
Returns:

addJob

protected void addJob(org.quartz.JobDetail jobDetail)

addTrigger

protected void addTrigger(org.quartz.Trigger trigger)

scheduleJob

protected void scheduleJob(String groupName,
                           String jobName,
                           int startStep,
                           int endStep,
                           Date startTime,
                           String requestorEmailAddress)

shouldScheduleJob

protected boolean shouldScheduleJob(org.quartz.JobDetail jobDetail)

shouldCancelJob

protected boolean shouldCancelJob(org.quartz.JobDetail jobDetail)

isDependencySatisfiedPositively

protected boolean isDependencySatisfiedPositively(org.quartz.JobDetail dependentJobDetail,
                                                  org.quartz.JobDetail dependencyJobDetail)

isDependencySatisfiedNegatively

protected boolean isDependencySatisfiedNegatively(org.quartz.JobDetail dependentJobDetail,
                                                  org.quartz.JobDetail dependencyJobDetail)

isSoftDependency

protected boolean isSoftDependency(String dependentJobName,
                                   String dependencyJobName)

getJobDependencies

protected Map<String,String> getJobDependencies(String jobName)

isPending

protected boolean isPending(org.quartz.JobDetail jobDetail)

isScheduled

protected boolean isScheduled(org.quartz.JobDetail jobDetail)

isSucceeded

protected boolean isSucceeded(org.quartz.JobDetail jobDetail)

isFailed

protected boolean isFailed(org.quartz.JobDetail jobDetail)

isCancelled

protected boolean isCancelled(org.quartz.JobDetail jobDetail)

getStatus

public String getStatus(org.quartz.JobDetail jobDetail)
Specified by:
getStatus in interface SchedulerService

getScheduledJobDetail

protected org.quartz.JobDetail getScheduledJobDetail(String jobName)

setScheduler

public void setScheduler(org.quartz.Scheduler scheduler)
Sets the scheduler attribute value.

Specified by:
setScheduler in interface SchedulerService
Parameters:
scheduler - The scheduler to set.

setParameterService

public void setParameterService(org.kuali.rice.kns.service.ParameterService parameterService)

setDateTimeService

public void setDateTimeService(org.kuali.rice.kns.service.DateTimeService dateTimeService)
Sets the dateTimeService attribute value.

Parameters:
dateTimeService - The dateTimeService to set.

setKualiModuleService

public void setKualiModuleService(org.kuali.rice.kns.service.KualiModuleService moduleService)
Sets the moduleService attribute value.

Parameters:
moduleService - The moduleService to set.

setJobListener

public void setJobListener(JobListener jobListener)
Sets the jobListener attribute value.

Parameters:
jobListener - The jobListener to set.

getJobs

public List<BatchJobStatus> getJobs()
Description copied from interface: SchedulerService
Get all jobs known to the scheduler wrapped within a BusinessObject-derived class.

Specified by:
getJobs in interface SchedulerService
Returns:

getJob

public BatchJobStatus getJob(String groupName,
                             String jobName)
Description copied from interface: SchedulerService
Gets a single job based on its name and group.

Specified by:
getJob in interface SchedulerService
Returns:

getJobs

public List<BatchJobStatus> getJobs(String groupName)
Specified by:
getJobs in interface SchedulerService

getRunningJobs

public List<org.quartz.JobExecutionContext> getRunningJobs()
Description copied from interface: SchedulerService
Returns the list of job currently running within the scheduler.

Specified by:
getRunningJobs in interface SchedulerService
Returns:

updateStatus

protected void updateStatus(String groupName,
                            String jobName,
                            String jobStatus)

removeScheduled

public void removeScheduled(String jobName)
Description copied from interface: SchedulerService
Removes a job from the scheduled group.

Specified by:
removeScheduled in interface SchedulerService

addScheduled

public void addScheduled(org.quartz.JobDetail job)
Description copied from interface: SchedulerService
Adds the given job to the "scheduled" group.

Specified by:
addScheduled in interface SchedulerService

addUnscheduled

public void addUnscheduled(org.quartz.JobDetail job)
Description copied from interface: SchedulerService
Adds the given job to the "unscheduled" group.

Specified by:
addUnscheduled in interface SchedulerService

getSchedulerGroups

public List<String> getSchedulerGroups()
Description copied from interface: SchedulerService
Returns a list of all groups defined in the scheduler.

Specified by:
getSchedulerGroups in interface SchedulerService
Returns:

getJobStatuses

public List<String> getJobStatuses()
Description copied from interface: SchedulerService
Returns a list of all possible statuses.

Specified by:
getJobStatuses in interface SchedulerService
Returns:

interruptJob

public void interruptJob(String jobName)
Description copied from interface: SchedulerService
Requests that the given job be stopped as soon as possble. It is up to the job to watch for this request and terminiate. Long running steps may not end unless they check for the interrupted status on their current Thread ot Step instance.

Specified by:
interruptJob in interface SchedulerService

getNextStartTime

public Date getNextStartTime(BatchJobStatus job)
Description copied from interface: SchedulerService
Returns the next start time for the given job.

Specified by:
getNextStartTime in interface SchedulerService
Returns:

getNextStartTime

public Date getNextStartTime(String groupName,
                             String jobName)
Description copied from interface: SchedulerService
Returns the next start time for the given job.

Specified by:
getNextStartTime in interface SchedulerService
Returns:

setMailService

public void setMailService(org.kuali.rice.kns.service.MailService mailService)

retrieveJobDescriptor

protected JobDescriptor retrieveJobDescriptor(String jobName)

reinitializeScheduledJobs

public void reinitializeScheduledJobs()
Specified by:
reinitializeScheduledJobs in interface SchedulerService


Copyright © 2005-2012 The Kuali Foundation. All Rights Reserved.