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");
}
}
}
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);
}
}
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);
}
}
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);
}
}
}
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);
}
Aggregations