Search in sources :

Example 41 with Trigger

use of org.quartz.Trigger in project cachecloud by sohutv.

the class MachineCenterImpl method unDeployMachineMonitor.

@Override
public boolean unDeployMachineMonitor(long hostId, String ip) {
    Assert.isTrue(hostId > 0);
    Assert.hasText(ip);
    TriggerKey monitorTriggerKey = TriggerKey.triggerKey(ip, ConstUtils.MACHINE_MONITOR_TRIGGER_GROUP + hostId);
    Trigger trigger = schedulerCenter.getTrigger(monitorTriggerKey);
    if (trigger == null) {
        return true;
    }
    return schedulerCenter.unscheduleJob(monitorTriggerKey);
}
Also used : TriggerKey(org.quartz.TriggerKey) Trigger(org.quartz.Trigger)

Example 42 with Trigger

use of org.quartz.Trigger in project cachecloud by sohutv.

the class RedisSlowLogJob method action.

@Override
public void action(JobExecutionContext context) {
    try {
        SchedulerContext schedulerContext = context.getScheduler().getContext();
        ApplicationContext applicationContext = (ApplicationContext) schedulerContext.get(APPLICATION_CONTEXT_KEY);
        RedisCenter redisCenter = (RedisCenter) applicationContext.getBean("redisCenter");
        JobDataMap dataMap = context.getMergedJobDataMap();
        String host = dataMap.getString(ConstUtils.HOST_KEY);
        int port = dataMap.getInt(ConstUtils.PORT_KEY);
        long appId = dataMap.getLong(ConstUtils.APP_KEY);
        Trigger trigger = context.getTrigger();
        long collectTime = ScheduleUtil.getCollectTime(trigger.getPreviousFireTime());
        redisCenter.collectRedisSlowLog(appId, collectTime, host, port);
    } catch (SchedulerException e) {
        logger.error(e.getMessage(), e);
    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) JobDataMap(org.quartz.JobDataMap) Trigger(org.quartz.Trigger) SchedulerException(org.quartz.SchedulerException) RedisCenter(com.sohu.cache.redis.RedisCenter) SchedulerContext(org.quartz.SchedulerContext) SchedulerException(org.quartz.SchedulerException)

Example 43 with Trigger

use of org.quartz.Trigger in project cachecloud by sohutv.

the class RedisCenterImpl method unDeployRedisSlowLogCollection.

@Override
public boolean unDeployRedisSlowLogCollection(long appId, String host, int port) {
    Assert.isTrue(appId > 0);
    Assert.hasText(host);
    Assert.isTrue(port > 0);
    TriggerKey triggerKey = TriggerKey.triggerKey(ObjectConvert.linkIpAndPort(host, port), ConstUtils.REDIS_SLOWLOG_TRIGGER_GROUP + appId);
    Trigger trigger = schedulerCenter.getTrigger(triggerKey);
    if (trigger == null) {
        return true;
    }
    return schedulerCenter.unscheduleJob(triggerKey);
}
Also used : TriggerKey(org.quartz.TriggerKey) Trigger(org.quartz.Trigger)

Example 44 with Trigger

use of org.quartz.Trigger in project engine by craftercms.

the class SchedulingUtils method createJobContext.

public static JobContext createJobContext(SiteContext siteContext, String scriptUrl, String cronExpression, ServletContext servletContext) {
    String jobName = siteContext.getSiteName() + ":" + scriptUrl;
    JobDetail detail = SchedulingUtils.createScriptJob(siteContext, jobName, scriptUrl, servletContext);
    Trigger trigger = SchedulingUtils.createCronTrigger("trigger for " + jobName, cronExpression);
    String description = "Job{url='" + scriptUrl + "', cron='" + cronExpression + "'}";
    return new JobContext(detail, trigger, description);
}
Also used : JobDetail(org.quartz.JobDetail) TriggerBuilder.newTrigger(org.quartz.TriggerBuilder.newTrigger) Trigger(org.quartz.Trigger) JobContext(org.craftercms.engine.util.quartz.JobContext)

Example 45 with Trigger

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

the class ScheduledCommandTask method newTask.

@Override
public void newTask() {
    LOGGER.trace("Creating new Task.");
    long identifier = System.currentTimeMillis();
    this.jobKey = new JobKey("job" + identifier, jobClass.getSimpleName());
    this.triggerKey = new TriggerKey("trigger" + identifier, jobClass.getSimpleName());
    JobDetail jobDetail = createJob();
    Trigger trigger = createTrigger();
    if (trigger == null) {
        return;
    }
    try {
        scheduler.scheduleJob(jobDetail, trigger);
    } catch (SchedulerException e) {
        LOGGER.info("Error with scheduling of task.", e);
    }
}
Also used : TriggerKey(org.quartz.TriggerKey) JobKey(org.quartz.JobKey) JobDetail(org.quartz.JobDetail) TriggerBuilder.newTrigger(org.quartz.TriggerBuilder.newTrigger) Trigger(org.quartz.Trigger) SchedulerException(org.quartz.SchedulerException)

Aggregations

Trigger (org.quartz.Trigger)104 JobDetail (org.quartz.JobDetail)51 SchedulerException (org.quartz.SchedulerException)40 CronTrigger (org.quartz.CronTrigger)29 Test (org.junit.Test)23 Scheduler (org.quartz.Scheduler)22 JobDataMap (org.quartz.JobDataMap)21 SimpleTrigger (org.quartz.SimpleTrigger)20 TriggerKey (org.quartz.TriggerKey)20 TriggerBuilder.newTrigger (org.quartz.TriggerBuilder.newTrigger)19 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 InetSocketAddress (java.net.InetSocketAddress)4 SocketChannel (java.nio.channels.SocketChannel)4 ParseException (java.text.ParseException)4 FormProcessor (org.akaza.openclinica.control.form.FormProcessor)4 ProtoTrigger (co.cask.cdap.proto.ProtoTrigger)3