Search in sources :

Example 1 with IScheduler

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.");
}
Also used : SimpleJobTrigger(org.pentaho.platform.api.scheduler2.SimpleJobTrigger) IScheduler(org.pentaho.platform.api.scheduler2.IScheduler) SimpleJobTrigger(org.pentaho.platform.api.scheduler2.SimpleJobTrigger) JobTrigger(org.pentaho.platform.api.scheduler2.JobTrigger) Date(java.util.Date)

Example 2 with IScheduler

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;
}
Also used : IJobTrigger(org.pentaho.platform.api.scheduler2.IJobTrigger) Date(java.util.Date)

Example 3 with IScheduler

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());
        }
    }
}
Also used : IJobFilter(org.pentaho.platform.api.scheduler2.IJobFilter) Job(org.pentaho.platform.api.scheduler2.Job) IScheduler(org.pentaho.platform.api.scheduler2.IScheduler)

Example 4 with IScheduler

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();
}
Also used : IScheduler(org.pentaho.platform.api.scheduler2.IScheduler)

Example 5 with IScheduler

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);
}
Also used : IScheduler(org.pentaho.platform.api.scheduler2.IScheduler)

Aggregations

IScheduler (org.pentaho.platform.api.scheduler2.IScheduler)14 SimpleJobTrigger (org.pentaho.platform.api.scheduler2.SimpleJobTrigger)8 Job (org.pentaho.platform.api.scheduler2.Job)7 Serializable (java.io.Serializable)6 Date (java.util.Date)6 ComplexJobTrigger (org.pentaho.platform.api.scheduler2.ComplexJobTrigger)5 JobTrigger (org.pentaho.platform.api.scheduler2.JobTrigger)5 IJobTrigger (org.pentaho.platform.api.scheduler2.IJobTrigger)4 SchedulerException (org.pentaho.platform.api.scheduler2.SchedulerException)4 HashMap (java.util.HashMap)3 ArrayList (java.util.ArrayList)2 IAuthorizationPolicy (org.pentaho.platform.api.engine.IAuthorizationPolicy)2 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)2 IBlockoutManager (org.pentaho.platform.api.scheduler2.IBlockoutManager)2 IJobFilter (org.pentaho.platform.api.scheduler2.IJobFilter)2 QuartzScheduler (org.pentaho.platform.scheduler2.quartz.QuartzScheduler)2 Calendar (java.util.Calendar)1 GregorianCalendar (java.util.GregorianCalendar)1 Map (java.util.Map)1 WebService (javax.jws.WebService)1