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 openhab1-addons by openhab.
the class WeatherJobScheduler method stop.
/**
* Stops all scheduled jobs and clears the WeatherPublisher cache.
*/
public void stop() {
try {
for (JobKey jobKey : scheduler.getJobKeys(jobGroupEquals(JOB_GROUP))) {
logger.info("Deleting " + jobKey.getName());
scheduler.deleteJob(jobKey);
}
} catch (SchedulerException ex) {
logger.error(ex.getMessage(), ex);
}
}
use of org.quartz.SchedulerException in project openhab1-addons by openhab.
the class WeatherJobScheduler method scheduleIntervalJob.
/**
* Schedules the WeatherJob with the specified interval and starts it
* immediately.
*/
public void scheduleIntervalJob(LocationConfig locationConfig) {
String jobName = "weatherJob-" + locationConfig.getLocationId();
int interval = locationConfig.getUpdateInterval() * 60;
JobDataMap jobDataMap = new JobDataMap();
jobDataMap.put("locationId", locationConfig.getLocationId());
try {
Trigger trigger = newTrigger().withIdentity(jobName + "-Trigger", JOB_GROUP).startNow().withSchedule(simpleSchedule().repeatForever().withIntervalInSeconds(interval)).build();
JobDetail jobDetail = newJob(WeatherJob.class).withIdentity(jobName, JOB_GROUP).usingJobData(jobDataMap).build();
scheduler.scheduleJob(jobDetail, trigger);
logger.info("Starting and scheduling {} with interval of {} minutes", jobName, locationConfig.getUpdateInterval());
} catch (SchedulerException ex) {
logger.error(ex.getMessage(), ex);
}
}
Aggregations