use of org.pentaho.platform.api.scheduler2.IScheduler in project pentaho-platform by pentaho.
the class GatherStatsListener method scheduleJob.
private void scheduleJob(int intervalInSeconds) throws Exception {
// $NON-NLS-1$
IScheduler scheduler = PentahoSystem.get(IScheduler.class, "IScheduler2", null);
JobTrigger trigger = new SimpleJobTrigger(new Date(), null, -1, intervalInSeconds);
jobMap.put("transFileName", getTransFileName());
scheduler.createJob(GatherStatsListener.JOB_NAME, GatherStatsAction.class, jobMap, trigger);
logger.info("Statistics gathering jop has been scheduled.");
}
use of org.pentaho.platform.api.scheduler2.IScheduler in project pentaho-platform by pentaho.
the class BlockoutManagerUtil method willFire.
public static boolean willFire(IJobTrigger jobTrigger, List<IJobTrigger> blockOutTriggers, IScheduler scheduler) {
// Short return as to avoid having to calculate fire times
if (blockOutTriggers.isEmpty()) {
return true;
}
List<Date> fireTimes = getFireTimes(jobTrigger, scheduler);
for (IJobTrigger blockOutJobTrigger : blockOutTriggers) {
// We must verify further if the schedule is blocked completely or if it will fire
if (willBlockSchedule(jobTrigger, blockOutJobTrigger, scheduler)) {
boolean isBlockoutComplex = isComplexTrigger(blockOutJobTrigger);
// If recurrence intervals are the same, it will never fire
if (!isBlockoutComplex && !isComplexTrigger(jobTrigger) && getRecurrenceInterval(blockOutJobTrigger) == getRecurrenceInterval(jobTrigger)) {
return false;
}
List<Date> blockoutFireTimes = null;
if (isBlockoutComplex) {
blockoutFireTimes = getFireTimes(blockOutJobTrigger, scheduler);
}
// Loop through fire times and verify whether block out is blocking the schedule completely
boolean scheduleCompletelyBlocked = true;
for (Date fireTime : fireTimes) {
scheduleCompletelyBlocked = isBlockoutComplex ? willComplexBlockOutTriggerBlockDate(blockOutJobTrigger, blockoutFireTimes, fireTime) : willBlockDate(blockOutJobTrigger, fireTime, scheduler);
if (!scheduleCompletelyBlocked) {
break;
}
}
// Return false if after n iterations
if (scheduleCompletelyBlocked) {
return false;
}
}
}
return true;
}
use of org.pentaho.platform.api.scheduler2.IScheduler in project pentaho-platform by pentaho.
the class EmbeddedVersionCheckSystemListener method deleteJobIfNecessary.
protected void deleteJobIfNecessary() throws SchedulerException {
// $NON-NLS-1$
IScheduler scheduler = PentahoSystem.get(IScheduler.class, "IScheduler2", null);
IJobFilter filter = new IJobFilter() {
public boolean accept(Job job) {
return job.getJobName().contains(EmbeddedVersionCheckSystemListener.VERSION_CHECK_JOBNAME);
}
};
// Like old code - remove the existing job and replace it
List<Job> matchingJobs = scheduler.getJobs(filter);
if ((matchingJobs != null) && (matchingJobs.size() > 0)) {
for (Job verCkJob : matchingJobs) {
scheduler.removeJob(verCkJob.getJobId());
}
}
}
use of org.pentaho.platform.api.scheduler2.IScheduler in project pentaho-platform by pentaho.
the class DefaultSchedulerService method start.
/**
* {@inheritDoc}
*/
public void start() throws SchedulerException {
// $NON-NLS-1$
IScheduler scheduler = PentahoSystem.get(IScheduler.class, "IScheduler2", null);
scheduler.start();
}
use of org.pentaho.platform.api.scheduler2.IScheduler in project pentaho-platform by pentaho.
the class DefaultSchedulerService method resumeJob.
/**
* {@inheritDoc}
*/
public void resumeJob(String jobId) throws SchedulerException {
// $NON-NLS-1$
IScheduler scheduler = PentahoSystem.get(IScheduler.class, "IScheduler2", null);
scheduler.resumeJob(jobId);
}
Aggregations