01: /*
02: * Copyright 2007 The Kuali Foundation.
03: *
04: * Licensed under the Educational Community License, Version 1.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.opensource.org/licenses/ecl1.php
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.kuali.kfs.batch;
17:
18: import org.apache.log4j.Logger;
19: import org.kuali.kfs.KFSConstants;
20: import org.kuali.kfs.service.SchedulerService;
21:
22: public class ScheduleStep extends AbstractStep {
23: private static final Logger LOG = Logger
24: .getLogger(ScheduleStep.class);
25: private SchedulerService schedulerService;
26:
27: /**
28: * @see org.kuali.kfs.batch.Step#execute()
29: */
30: public boolean execute(String jobName) {
31: boolean isPastScheduleCutoffTime = false;
32: while (schedulerService.hasIncompleteJob()
33: && !isPastScheduleCutoffTime) {
34: schedulerService.processWaitingJobs();
35: isPastScheduleCutoffTime = schedulerService
36: .isPastScheduleCutoffTime();
37: try {
38: Thread
39: .sleep(Integer
40: .parseInt(getParameterService()
41: .getParameterValue(
42: getClass(),
43: KFSConstants.SystemGroupParameterNames.BATCH_SCHEDULE_STATUS_CHECK_INTERVAL)));
44: } catch (InterruptedException e) {
45: throw new RuntimeException(
46: "Schedule step encountered interrupt exception while trying to wait for the specified batch schedule status check interval",
47: e);
48: }
49: }
50: if (isPastScheduleCutoffTime) {
51: LOG
52: .info("Schedule exceeded cutoff time, so it was terminated before completion");
53: }
54: schedulerService.logScheduleResults();
55: return !isPastScheduleCutoffTime;
56: }
57:
58: /**
59: * Sets the schedulerService attribute value.
60: *
61: * @param schedulerService The schedulerService to set.
62: */
63: public void setSchedulerService(SchedulerService schedulerService) {
64: this.schedulerService = schedulerService;
65: }
66: }
|