001: /*
002: * Copyright 2007 The Kuali Foundation.
003: *
004: * Licensed under the Educational Community License, Version 1.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.opensource.org/licenses/ecl1.php
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.kuali.kfs.service;
017:
018: import java.util.Date;
019: import java.util.List;
020:
021: import org.kuali.kfs.batch.BatchJobStatus;
022: import org.kuali.kfs.batch.Job;
023: import org.quartz.JobDetail;
024: import org.quartz.JobExecutionContext;
025: import org.quartz.Scheduler;
026:
027: public interface SchedulerService {
028: public static final String PENDING_JOB_STATUS_CODE = "Pending";
029: public static final String SCHEDULED_JOB_STATUS_CODE = "Scheduled";
030: public static final String RUNNING_JOB_STATUS_CODE = "Running";
031: public static final String SUCCEEDED_JOB_STATUS_CODE = "Succeeded";
032: public static final String FAILED_JOB_STATUS_CODE = "Failed";
033: public static final String CANCELLED_JOB_STATUS_CODE = "Cancelled";
034:
035: public static final String SCHEDULED_GROUP = "scheduled";
036: public static final String UNSCHEDULED_GROUP = "unscheduled";
037:
038: public void initialize();
039:
040: public void initializeJob(String jobName, Job job);
041:
042: /**
043: * This method checks whether any jobs in the SCHEDULED job group are pending or currently scheduled.
044: *
045: * @return hasIncompleteJob
046: */
047: public boolean hasIncompleteJob();
048:
049: /**
050: * This method should be used to determine when the daily batch schedule should terminate. It compares the start time of the
051: * schedule job from quartz with a time specified by the scheduleStep_CUTOFF_TIME system parameter in the SYSTEM security group
052: * on the day after the schedule job started running.
053: *
054: * @return pastScheduleCutoffTime
055: */
056: public boolean isPastScheduleCutoffTime();
057:
058: public void processWaitingJobs();
059:
060: public void logScheduleResults();
061:
062: public boolean shouldNotRun(JobDetail jobDetail);
063:
064: public String getStatus(JobDetail jobDetail);
065:
066: public void updateStatus(JobDetail jobDetail, String jobStatus);
067:
068: public void setScheduler(Scheduler scheduler);
069:
070: public List<BatchJobStatus> getJobs(String groupName);
071:
072: /**
073: * Get all jobs known to the scheduler wrapped within a BusinessObject-derived class.
074: *
075: * @return
076: */
077: public List<BatchJobStatus> getJobs();
078:
079: /**
080: * Gets a single job based on its name and group.
081: *
082: * @param groupName
083: * @param jobName
084: * @return
085: */
086: public BatchJobStatus getJob(String groupName, String jobName);
087:
088: /**
089: * Immediately runs the specified job.
090: *
091: * @param jobName
092: * @param startStep
093: * @param stopStep
094: * @param requestorEmailAddress
095: */
096: public void runJob(String jobName, int startStep, int stopStep,
097: Date startTime, String requestorEmailAddress);
098:
099: /**
100: * Immediately runs the specified job.
101: *
102: * @param jobName
103: * @param requestorEmailAddress
104: */
105: public void runJob(String jobName, String requestorEmailAddress);
106:
107: /**
108: * Returns the list of job currently running within the scheduler.
109: *
110: * @return
111: */
112: public List<JobExecutionContext> getRunningJobs();
113:
114: /**
115: * Removes a job from the scheduled group.
116: *
117: * @param jobName
118: */
119: public void removeScheduled(String jobName);
120:
121: /**
122: * Adds the given job to the "scheduled" group.
123: *
124: * @param job
125: */
126: public void addScheduled(JobDetail job);
127:
128: /**
129: * Adds the given job to the "unscheduled" group.
130: *
131: * @param job
132: */
133: public void addUnscheduled(JobDetail job);
134:
135: /**
136: * Returns a list of all groups defined in the scheduler.
137: *
138: * @return
139: */
140: public List<String> getSchedulerGroups();
141:
142: /**
143: * Returns a list of all possible statuses.
144: *
145: * @return
146: */
147: public List<String> getJobStatuses();
148:
149: /**
150: * 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
151: * running steps may not end unless they check for the interrupted status on their current Thread ot Step instance.
152: *
153: * @param jobName
154: */
155: public void interruptJob(String jobName);
156:
157: /**
158: * Tests whether the referenced job name is running, regardless of group.
159: *
160: * @param jobName
161: * @return
162: */
163: public boolean isJobRunning(String jobName);
164:
165: /**
166: * Returns the next start time for the given job.
167: *
168: * @param job
169: * @return
170: */
171: public Date getNextStartTime(BatchJobStatus job);
172:
173: /**
174: * Returns the next start time for the given job.
175: *
176: * @param groupName
177: * @param jobName
178: * @return
179: */
180: public Date getNextStartTime(String groupName, String jobName);
181: }
|