Search in sources :

Example 96 with Trigger

use of org.quartz.Trigger in project cdap by caskdata.

the class DatasetBasedTimeScheduleStoreTest method testStoreJobsAndTriggers.

@Test
public void testStoreJobsAndTriggers() throws SchedulerException {
    schedulerSetup(true);
    Map<JobDetail, Set<? extends Trigger>> multiJobsTriggers = new HashMap<>();
    JobDetail job1 = getJobDetail("mapreduce1");
    multiJobsTriggers.put(job1, Sets.newHashSet(getTrigger("p1"), getTrigger("p2")));
    JobDetail job2 = getJobDetail("mapreduce2");
    multiJobsTriggers.put(job2, Sets.newHashSet(getTrigger("p3")));
    scheduler.scheduleJobs(multiJobsTriggers, true);
    verifyJobAndTriggers(job1.getKey(), 2, Trigger.TriggerState.NORMAL);
    verifyJobAndTriggers(job2.getKey(), 1, Trigger.TriggerState.NORMAL);
    // verify across restart that the jobs and triggers gets retrieved from the store
    //Shutdown scheduler.
    schedulerTearDown();
    //restart scheduler.
    schedulerSetup(true);
    verifyJobAndTriggers(job1.getKey(), 2, Trigger.TriggerState.NORMAL);
    verifyJobAndTriggers(job2.getKey(), 1, Trigger.TriggerState.NORMAL);
    schedulerTearDown();
}
Also used : JobDetail(org.quartz.JobDetail) Set(java.util.Set) Trigger(org.quartz.Trigger) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 97 with Trigger

use of org.quartz.Trigger in project simba-os by cegeka.

the class JobSchedulerConfiguration method schedulerFactory.

@Bean(destroyMethod = "destroy")
public SchedulerFactoryBean schedulerFactory() {
    Properties quartzProperties = new Properties();
    quartzProperties.put("org.quartz.threadPool.threadCount", "2");
    quartzProperties.put("org.quartz.jobStore.driverDelegateClass", quartzJobstoreDelegate);
    Trigger[] triggers = new Trigger[] { verifyAuditLogIntegrityTrigger, cleanUpAuditLogTrigger, purgeExpiredLoginMappingsTrigger, purgeExpiredSessionsTrigger, markUsersForPasswordChangeTrigger };
    SchedulerFactoryBean bean = new SchedulerFactoryBean();
    bean.setDataSource(dataSource);
    bean.setWaitForJobsToCompleteOnShutdown(false);
    bean.setApplicationContextSchedulerContextKey("applicationContext");
    bean.setQuartzProperties(quartzProperties);
    bean.setTriggers(triggers);
    return bean;
}
Also used : Trigger(org.quartz.Trigger) SchedulerFactoryBean(org.springframework.scheduling.quartz.SchedulerFactoryBean) Properties(java.util.Properties) Bean(org.springframework.context.annotation.Bean) SchedulerFactoryBean(org.springframework.scheduling.quartz.SchedulerFactoryBean)

Example 98 with Trigger

use of org.quartz.Trigger in project ddf by codice.

the class ScheduledCommandTask method updateTask.

@Override
public void updateTask(Map<String, Object> properties) {
    if (MapUtils.isEmpty(properties)) {
        LOGGER.info("Empty or null properties map. No action taken.");
        return;
    }
    Object commandValue = properties.get(CommandJob.COMMAND_KEY);
    if (commandValue != null) {
        this.command = commandValue.toString();
    }
    Object intervalString = properties.get(INTERVAL_STRING);
    if (intervalString != null) {
        LOGGER.debug("Updating intervalString : {}", intervalString);
        this.intervalString = (String) intervalString;
    }
    Object intervalType = properties.get(INTERVAL_TYPE);
    if (intervalType != null) {
        LOGGER.debug("Updating intervalType : {}", intervalType);
        this.intervalType = (String) intervalType;
    }
    JobDetail newJob = createJob();
    Trigger newTrigger = createTrigger();
    if (newTrigger == null) {
        return;
    }
    try {
        scheduler.addJob(newJob, true);
        scheduler.rescheduleJob(triggerKey, newTrigger);
    } catch (SchedulerException e) {
        LOGGER.info("Error with rescheduling of task.", e);
    }
}
Also used : JobDetail(org.quartz.JobDetail) TriggerBuilder.newTrigger(org.quartz.TriggerBuilder.newTrigger) Trigger(org.quartz.Trigger) SchedulerException(org.quartz.SchedulerException)

Aggregations

Trigger (org.quartz.Trigger)98 JobDetail (org.quartz.JobDetail)47 SchedulerException (org.quartz.SchedulerException)37 CronTrigger (org.quartz.CronTrigger)28 Test (org.junit.Test)23 JobDataMap (org.quartz.JobDataMap)21 Scheduler (org.quartz.Scheduler)21 TriggerKey (org.quartz.TriggerKey)20 SimpleTrigger (org.quartz.SimpleTrigger)19 TriggerBuilder.newTrigger (org.quartz.TriggerBuilder.newTrigger)18 JobKey (org.quartz.JobKey)16 ArrayList (java.util.ArrayList)13 Date (java.util.Date)12 List (java.util.List)5 Command (org.openhab.core.types.Command)5 IOException (java.io.IOException)4 InetSocketAddress (java.net.InetSocketAddress)4 SocketChannel (java.nio.channels.SocketChannel)4 ParseException (java.text.ParseException)4 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)4