Search in sources :

Example 16 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 17 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 18 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 19 with SchedulerException

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);
    }
}
Also used : JobKey(org.quartz.JobKey) SchedulerException(org.quartz.SchedulerException)

Example 20 with SchedulerException

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);
    }
}
Also used : JobDataMap(org.quartz.JobDataMap) JobDetail(org.quartz.JobDetail) TriggerBuilder.newTrigger(org.quartz.TriggerBuilder.newTrigger) Trigger(org.quartz.Trigger) SchedulerException(org.quartz.SchedulerException)

Aggregations

SchedulerException (org.quartz.SchedulerException)133 JobDetail (org.quartz.JobDetail)59 Trigger (org.quartz.Trigger)42 Scheduler (org.quartz.Scheduler)37 JobKey (org.quartz.JobKey)33 SimpleTrigger (org.quartz.SimpleTrigger)19 JobDataMap (org.quartz.JobDataMap)18 CronTrigger (org.quartz.CronTrigger)17 TriggerBuilder.newTrigger (org.quartz.TriggerBuilder.newTrigger)15 ApplicationContext (org.springframework.context.ApplicationContext)15 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