1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sys.batch;
17
18 import java.util.Date;
19
20 import org.apache.log4j.Logger;
21 import org.kuali.ole.sys.OLEConstants;
22 import org.kuali.ole.sys.batch.service.SchedulerService;
23
24 public class ScheduleStep extends AbstractStep {
25 private static final Logger LOG = Logger.getLogger(ScheduleStep.class);
26 private SchedulerService schedulerService;
27
28
29
30
31 public boolean execute(String jobName, Date jobRunDate) {
32 boolean isPastScheduleCutoffTime = false;
33 schedulerService.reinitializeScheduledJobs();
34 while (schedulerService.hasIncompleteJob() && !isPastScheduleCutoffTime) {
35 schedulerService.processWaitingJobs();
36 isPastScheduleCutoffTime = schedulerService.isPastScheduleCutoffTime();
37 try {
38 Thread.sleep(Integer.parseInt(getParameterService().getParameterValueAsString(getClass(), OLEConstants.SystemGroupParameterNames.BATCH_SCHEDULE_STATUS_CHECK_INTERVAL)));
39 }
40 catch (InterruptedException e) {
41 throw new RuntimeException("Schedule step encountered interrupt exception while trying to wait for the specified batch schedule status check interval", e);
42 }
43 }
44 if (isPastScheduleCutoffTime) {
45 LOG.info("Schedule exceeded cutoff time, so it was terminated before completion");
46 }
47 schedulerService.logScheduleResults();
48 return !isPastScheduleCutoffTime;
49 }
50
51
52
53
54
55
56 public void setSchedulerService(SchedulerService schedulerService) {
57 this.schedulerService = schedulerService;
58 }
59 }