1 /*
2 * Copyright 2007 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
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.ole.sys.batch.service;
17
18 import java.util.Date;
19 import java.util.List;
20
21 import org.kuali.ole.sys.batch.BatchJobStatus;
22 import org.kuali.ole.sys.batch.Job;
23 import org.quartz.JobDetail;
24 import org.quartz.JobExecutionContext;
25 import org.quartz.Scheduler;
26
27 public interface SchedulerService {
28 public static final String SCHEDULE_JOB_NAME = "scheduleJob";
29
30 public static final String PENDING_JOB_STATUS_CODE = "Pending";
31 public static final String SCHEDULED_JOB_STATUS_CODE = "Scheduled";
32 public static final String RUNNING_JOB_STATUS_CODE = "Running";
33 public static final String SUCCEEDED_JOB_STATUS_CODE = "Succeeded";
34 public static final String FAILED_JOB_STATUS_CODE = "Failed";
35 public static final String CANCELLED_JOB_STATUS_CODE = "Cancelled";
36
37 public static final String JOB_STATUS_PARAMETER = "status";
38
39 public static final String SCHEDULED_GROUP = "scheduled";
40 public static final String UNSCHEDULED_GROUP = "unscheduled";
41
42 public void initialize();
43
44 public void initializeJob(String jobName, Job job);
45
46 /**
47 * This method checks whether any jobs in the SCHEDULED job group are pending or currently scheduled.
48 *
49 * @return hasIncompleteJob
50 */
51 public boolean hasIncompleteJob();
52
53 /**
54 * This method should be used to determine when the daily batch schedule should terminate. It compares the start time of the
55 * schedule job from quartz with a time specified by the scheduleStep_CUTOFF_TIME system parameter in the SYSTEM security group
56 * on the day after the schedule job started running.
57 *
58 * @return pastScheduleCutoffTime
59 */
60 public boolean isPastScheduleCutoffTime();
61
62 public void processWaitingJobs();
63
64 public void logScheduleResults();
65
66 public boolean shouldNotRun(JobDetail jobDetail);
67
68 public String getStatus(JobDetail jobDetail);
69
70 public void updateStatus(JobDetail jobDetail, String jobStatus);
71
72 public void setScheduler(Scheduler scheduler);
73
74 public List<BatchJobStatus> getJobs(String groupName);
75
76 /**
77 * Get all jobs known to the scheduler wrapped within a BusinessObject-derived class.
78 *
79 * @return
80 */
81 public List<BatchJobStatus> getJobs();
82
83 /**
84 * Gets a single job based on its name and group.
85 *
86 * @param groupName
87 * @param jobName
88 * @return
89 */
90 public BatchJobStatus getJob(String groupName, String jobName);
91
92 /**
93 * Immediately runs the specified job.
94 *
95 * @param jobName
96 * @param startStep
97 * @param stopStep
98 * @param requestorEmailAddress
99 */
100 public void runJob(String jobName, int startStep, int stopStep, Date startTime, String requestorEmailAddress);
101
102
103 public void runJob(String groupName, String jobName, int startStep, int stopStep, Date jobStartTime, String requestorEmailAddress);
104 /**
105 * Immediately runs the specified job.
106 *
107 * @param jobName
108 * @param requestorEmailAddress
109 */
110 public void runJob(String jobName, String requestorEmailAddress);
111
112 /**
113 * Returns the list of job currently running within the scheduler.
114 *
115 * @return
116 */
117 public List<JobExecutionContext> getRunningJobs();
118
119 /**
120 * Removes a job from the scheduled group.
121 *
122 * @param jobName
123 */
124 public void removeScheduled(String jobName);
125
126 /**
127 * Adds the given job to the "scheduled" group.
128 *
129 * @param job
130 */
131 public void addScheduled(JobDetail job);
132
133 /**
134 * Adds the given job to the "unscheduled" group.
135 *
136 * @param job
137 */
138 public void addUnscheduled(JobDetail job);
139
140 /**
141 * Returns a list of all groups defined in the scheduler.
142 *
143 * @return
144 */
145 public List<String> getSchedulerGroups();
146
147 /**
148 * Returns a list of all possible statuses.
149 *
150 * @return
151 */
152 public List<String> getJobStatuses();
153
154 /**
155 * 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
156 * running steps may not end unless they check for the interrupted status on their current Thread ot Step instance.
157 *
158 * @param jobName
159 */
160 public void interruptJob(String jobName);
161
162 /**
163 * Tests whether the referenced job name is running, regardless of group.
164 *
165 * @param jobName
166 * @return
167 */
168 public boolean isJobRunning(String jobName);
169
170 /**
171 * Returns the next start time for the given job.
172 *
173 * @param job
174 * @return
175 */
176 public Date getNextStartTime(BatchJobStatus job);
177
178 /**
179 * Returns the next start time for the given job.
180 *
181 * @param groupName
182 * @param jobName
183 * @return
184 */
185 public Date getNextStartTime(String groupName, String jobName);
186
187 public void reinitializeScheduledJobs();
188 }