Search in sources :

Example 31 with SchedulerException

use of org.quartz.SchedulerException in project openhab1-addons by openhab.

the class FHTBinding method unscheduleJob.

private void unscheduleJob(JobKey jobKey) {
    if (jobKey == null) {
        return;
    }
    try {
        Scheduler sched = StdSchedulerFactory.getDefaultScheduler();
        sched.deleteJob(jobKey);
    } catch (SchedulerException e) {
        logger.error("Error while unscheduling time update job", e);
    }
}
Also used : SchedulerException(org.quartz.SchedulerException) Scheduler(org.quartz.Scheduler)

Example 32 with SchedulerException

use of org.quartz.SchedulerException in project openhab1-addons by openhab.

the class MapDBPersistenceService method scheduleJob.

/**
     * Schedules new quartz scheduler jobs for committing transactions and
     * backing up the database
     */
private void scheduleJob() {
    try {
        Scheduler sched = StdSchedulerFactory.getDefaultScheduler();
        // schedule commit-job
        JobDetail job = newJob(CommitJob.class).withIdentity("Commit_Transaction", SCHEDULER_GROUP).build();
        SimpleTrigger trigger = newTrigger().withIdentity("Commit_Transaction", SCHEDULER_GROUP).withSchedule(repeatSecondlyForever(commitInterval)).build();
        sched.scheduleJob(job, trigger);
        logger.debug("Scheduled Commit-Job with interval {}sec.", commitInterval);
    } catch (SchedulerException e) {
        logger.warn("Could not create Job: {}", e.getMessage());
    }
}
Also used : JobDetail(org.quartz.JobDetail) SchedulerException(org.quartz.SchedulerException) Scheduler(org.quartz.Scheduler) SimpleTrigger(org.quartz.SimpleTrigger)

Example 33 with SchedulerException

use of org.quartz.SchedulerException in project openhab1-addons by openhab.

the class MapDBPersistenceService method cancelAllJobs.

/**
     * Delete all quartz scheduler jobs of the group <code>Dropbox</code>.
     */
private void cancelAllJobs() {
    try {
        Scheduler sched = StdSchedulerFactory.getDefaultScheduler();
        Set<JobKey> jobKeys = sched.getJobKeys(jobGroupEquals(SCHEDULER_GROUP));
        if (jobKeys.size() > 0) {
            sched.deleteJobs(new ArrayList<JobKey>(jobKeys));
            logger.debug("Found {} MapDB-Jobs to delete from DefaultScheduler (keys={})", jobKeys.size(), jobKeys);
        }
    } catch (SchedulerException e) {
        logger.warn("Couldn't remove Commit-Job: {}", e.getMessage());
    }
}
Also used : JobKey(org.quartz.JobKey) SchedulerException(org.quartz.SchedulerException) Scheduler(org.quartz.Scheduler)

Example 34 with SchedulerException

use of org.quartz.SchedulerException in project openhab1-addons by openhab.

the class GCalPersistenceService method scheduleUploadJob.

/**
     * Schedules new quartz scheduler job for uploading calendar entries to Google
     */
private void scheduleUploadJob() {
    try {
        scheduler = StdSchedulerFactory.getDefaultScheduler();
        JobDetail job = newJob(SynchronizationJob.class).withIdentity("Upload_GCal-Entries", GCAL_SCHEDULER_GROUP).build();
        SimpleTrigger trigger = newTrigger().withIdentity("Upload_GCal-Entries", GCAL_SCHEDULER_GROUP).withSchedule(repeatSecondlyForever(uploadInterval)).build();
        scheduler.scheduleJob(job, trigger);
        logger.debug("Scheduled Google Calendar Upload-Job with interval '{}'", uploadInterval);
    } catch (SchedulerException e) {
        logger.warn("Could not create Google Calendar Upload-Job: {}", e.getMessage());
    }
}
Also used : JobDetail(org.quartz.JobDetail) SchedulerException(org.quartz.SchedulerException) SimpleTrigger(org.quartz.SimpleTrigger)

Example 35 with SchedulerException

use of org.quartz.SchedulerException in project openhab1-addons by openhab.

the class Db4oPersistenceService method scheduleJob.

/**
     * Schedules new quartz scheduler jobs for committing transactions and
     * backing up the database
     */
private void scheduleJob() {
    try {
        Scheduler sched = StdSchedulerFactory.getDefaultScheduler();
        // schedule commit-job
        JobDetail job = newJob(CommitJob.class).withIdentity("Commit_Transaction", SCHEDULER_GROUP).build();
        SimpleTrigger trigger = newTrigger().withIdentity("Commit_Transaction", SCHEDULER_GROUP).withSchedule(repeatSecondlyForever(commitInterval)).build();
        sched.scheduleJob(job, trigger);
        logger.debug("Scheduled Commit-Job with interval {}sec.", commitInterval);
        // schedule backup-job
        JobDetail backupJob = newJob(BackupJob.class).withIdentity("Backup_DB", SCHEDULER_GROUP).build();
        CronTrigger backupTrigger = newTrigger().withIdentity("Backup_DB", SCHEDULER_GROUP).withSchedule(CronScheduleBuilder.cronSchedule(backupInterval)).build();
        sched.scheduleJob(backupJob, backupTrigger);
        logger.debug("Scheduled Backup-Job with cron expression '{}'", backupInterval);
    } catch (SchedulerException e) {
        logger.warn("Could not create Job: {}", e.getMessage());
    }
}
Also used : JobDetail(org.quartz.JobDetail) CronTrigger(org.quartz.CronTrigger) SchedulerException(org.quartz.SchedulerException) Scheduler(org.quartz.Scheduler) SimpleTrigger(org.quartz.SimpleTrigger)

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