Search in sources :

Example 1 with SchedulerException

use of org.quartz.SchedulerException in project zeppelin by apache.

the class Notebook method refreshCron.

public void refreshCron(String id) {
    removeCron(id);
    synchronized (notes) {
        Note note = notes.get(id);
        if (note == null) {
            return;
        }
        Map<String, Object> config = note.getConfig();
        if (config == null) {
            return;
        }
        String cronExpr = (String) note.getConfig().get("cron");
        if (cronExpr == null || cronExpr.trim().length() == 0) {
            return;
        }
        JobDetail newJob = JobBuilder.newJob(CronJob.class).withIdentity(id, "note").usingJobData("noteId", id).build();
        Map<String, Object> info = note.getInfo();
        info.put("cron", null);
        CronTrigger trigger = null;
        try {
            trigger = TriggerBuilder.newTrigger().withIdentity("trigger_" + id, "note").withSchedule(CronScheduleBuilder.cronSchedule(cronExpr)).forJob(id, "note").build();
        } catch (Exception e) {
            logger.error("Error", e);
            info.put("cron", e.getMessage());
        }
        try {
            if (trigger != null) {
                quartzSched.scheduleJob(newJob, trigger);
            }
        } catch (SchedulerException e) {
            logger.error("Error", e);
            info.put("cron", "Scheduler Exception");
        }
    }
}
Also used : JobDetail(org.quartz.JobDetail) CronTrigger(org.quartz.CronTrigger) SchedulerException(org.quartz.SchedulerException) AngularObject(org.apache.zeppelin.display.AngularObject) SchedulerException(org.quartz.SchedulerException) IOException(java.io.IOException) JobExecutionException(org.quartz.JobExecutionException)

Example 2 with SchedulerException

use of org.quartz.SchedulerException in project elastic-job by dangdangdotcom.

the class StatisticsScheduler method register.

/**
     * 注册统计作业.
     * 
     * @param statisticJob 统计作业
     */
void register(final StatisticJob statisticJob) {
    try {
        JobDetail jobDetail = statisticJob.buildJobDetail();
        Map<String, Object> dataMap = statisticJob.getDataMap();
        for (String each : dataMap.keySet()) {
            jobDetail.getJobDataMap().put(each, dataMap.get(each));
        }
        scheduler.scheduleJob(jobDetail, statisticJob.buildTrigger());
    } catch (final SchedulerException ex) {
        throw new JobStatisticException(ex);
    }
}
Also used : JobDetail(org.quartz.JobDetail) SchedulerException(org.quartz.SchedulerException) JobStatisticException(com.dangdang.ddframe.job.exception.JobStatisticException)

Example 3 with SchedulerException

use of org.quartz.SchedulerException in project elastic-job by dangdangdotcom.

the class StatisticsScheduler method start.

/**
     * 启动调度器.
     */
void start() {
    try {
        scheduler = factory.getScheduler();
        scheduler.start();
    } catch (final SchedulerException ex) {
        throw new JobStatisticException(ex);
    }
}
Also used : SchedulerException(org.quartz.SchedulerException) JobStatisticException(com.dangdang.ddframe.job.exception.JobStatisticException)

Example 4 with SchedulerException

use of org.quartz.SchedulerException in project elastic-job by dangdangdotcom.

the class TransientProducerScheduler method deregister.

void deregister(final CloudJobConfiguration jobConfig) {
    repository.remove(jobConfig.getJobName());
    String cron = jobConfig.getTypeConfig().getCoreConfig().getCron();
    if (!repository.containsKey(buildJobKey(cron))) {
        try {
            scheduler.unscheduleJob(TriggerKey.triggerKey(cron));
        } catch (final SchedulerException ex) {
            throw new JobSystemException(ex);
        }
    }
}
Also used : SchedulerException(org.quartz.SchedulerException) JobSystemException(com.dangdang.ddframe.job.exception.JobSystemException)

Example 5 with SchedulerException

use of org.quartz.SchedulerException in project pinot by linkedin.

the class AlertJobScheduler method scheduleJob.

private void scheduleJob(JobContext jobContext, EmailConfigurationDTO alertConfig) {
    LOG.info("Starting {}", jobContext.getJobName());
    String triggerKey = String.format("alert_scheduler_trigger_%d", alertConfig.getId());
    CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(triggerKey).withSchedule(CronScheduleBuilder.cronSchedule(alertConfig.getCron())).build();
    String jobKey = jobContext.getJobName();
    JobDetail job = JobBuilder.newJob(AlertJobRunner.class).withIdentity(jobKey).build();
    job.getJobDataMap().put(AlertJobRunner.ALERT_JOB_CONTEXT, jobContext);
    try {
        quartzScheduler.scheduleJob(job, trigger);
    } catch (SchedulerException e) {
        LOG.error("Exception while scheduling alert job", e);
    }
    LOG.info("Started {}: {}", jobKey, alertConfig);
}
Also used : CronTrigger(org.quartz.CronTrigger) JobDetail(org.quartz.JobDetail) SchedulerException(org.quartz.SchedulerException)

Aggregations

SchedulerException (org.quartz.SchedulerException)130 JobDetail (org.quartz.JobDetail)56 Trigger (org.quartz.Trigger)39 Scheduler (org.quartz.Scheduler)36 JobKey (org.quartz.JobKey)33 SimpleTrigger (org.quartz.SimpleTrigger)19 JobDataMap (org.quartz.JobDataMap)18 CronTrigger (org.quartz.CronTrigger)17 ApplicationContext (org.springframework.context.ApplicationContext)15 TriggerBuilder.newTrigger (org.quartz.TriggerBuilder.newTrigger)14 ArrayList (java.util.ArrayList)12 SchedulerContext (org.quartz.SchedulerContext)12 IOException (java.io.IOException)11 TriggerKey (org.quartz.TriggerKey)10 Date (java.util.Date)9 JobExecutionException (org.quartz.JobExecutionException)9 StdSchedulerFactory (org.quartz.impl.StdSchedulerFactory)6 ParseException (java.text.ParseException)5 Command (org.openhab.core.types.Command)5 JobSystemException (com.dangdang.ddframe.job.exception.JobSystemException)4