Search in sources :

Example 51 with TriggerKey

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

the class TriggerController method pauseTrigger.

@RequestMapping(value = "/pause/{appId}/{type}/{host}/{port}")
public void pauseTrigger(@PathVariable long appId, @PathVariable int type, @PathVariable String host, @PathVariable int port) {
    Assert.isTrue(appId > 0);
    Assert.isTrue(type > 0);
    Assert.hasText(host);
    Assert.isTrue(port > 0);
    String triggerName = ObjectConvert.linkIpAndPort(host, port);
    String triggerGroup = "";
    if (type == ConstUtils.CACHE_TYPE_REDIS_CLUSTER) {
        triggerGroup = ConstUtils.REDIS_TRIGGER_GROUP + appId;
    }
    TriggerKey triggerKey = TriggerKey.triggerKey(triggerName, triggerGroup);
    try {
        scheduler.pauseTrigger(triggerKey);
    } catch (SchedulerException e) {
        logger.error(e.getMessage(), e);
    }
    logger.info("trigger with name: {}, group: {} is paused", port, host);
}
Also used : TriggerKey(org.quartz.TriggerKey) SchedulerException(org.quartz.SchedulerException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 52 with TriggerKey

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

the class SchedulerCenterTest method testSchedule.

@Test
public void testSchedule() {
    TriggerKey key = TriggerKey.triggerKey("appInfoAlertTrigger", "appAlert");
    Trigger trigger = schedulerCenter.getTrigger(key);
    if (trigger != null) {
        boolean isSchedule = schedulerCenter.unscheduleJob(key);
        logger.warn("isSchedule={}", isSchedule);
    }
// try {
// TimeUnit.SECONDS.sleep(5);
// } catch (InterruptedException e) {
// logger.error("{}", e);
// }
}
Also used : TriggerKey(org.quartz.TriggerKey) Trigger(org.quartz.Trigger) BaseTest(com.sohu.test.BaseTest) Test(org.junit.Test)

Example 53 with TriggerKey

use of org.quartz.TriggerKey in project new-cloud by xie-summer.

the class QuartzManageController method remove.

@RequestMapping(value = "/remove")
public String remove(HttpServletRequest request, HttpServletResponse response, Model model) {
    String name = request.getParameter("name");
    String group = request.getParameter("group");
    if (StringUtils.isNotBlank(name) || StringUtils.isNotBlank(group)) {
        schedulerCenter.unscheduleJob(new TriggerKey(name, group));
    }
    return "redirect:/manage/quartz/list";
}
Also used : TriggerKey(org.quartz.TriggerKey) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 54 with TriggerKey

use of org.quartz.TriggerKey in project new-cloud by xie-summer.

the class QuartzManageController method pause.

@RequestMapping(value = "/pause")
public String pause(HttpServletRequest request, HttpServletResponse response, Model model) {
    String name = request.getParameter("name");
    String group = request.getParameter("group");
    if (StringUtils.isNotBlank(name) || StringUtils.isNotBlank(group)) {
        schedulerCenter.pauseTrigger(new TriggerKey(name, group));
    }
    return "redirect:/manage/quartz/list";
}
Also used : TriggerKey(org.quartz.TriggerKey) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 55 with TriggerKey

use of org.quartz.TriggerKey in project new-cloud by xie-summer.

the class QuartzManageController method resume.

@RequestMapping(value = "/resume")
public String resume(HttpServletRequest request, HttpServletResponse response, Model model) {
    String name = request.getParameter("name");
    String group = request.getParameter("group");
    if (StringUtils.isNotBlank(name) || StringUtils.isNotBlank(group)) {
        schedulerCenter.resumeTrigger(new TriggerKey(name, group));
    }
    return "redirect:/manage/quartz/list";
}
Also used : TriggerKey(org.quartz.TriggerKey) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

TriggerKey (org.quartz.TriggerKey)112 Trigger (org.quartz.Trigger)49 JobKey (org.quartz.JobKey)30 SchedulerException (org.quartz.SchedulerException)30 CronTrigger (org.quartz.CronTrigger)25 JobDetail (org.quartz.JobDetail)22 Test (org.junit.Test)18 Scheduler (org.quartz.Scheduler)18 SimpleTrigger (org.quartz.SimpleTrigger)15 TriggerBuilder.newTrigger (org.quartz.TriggerBuilder.newTrigger)11 ArrayList (java.util.ArrayList)10 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)10 HashMap (java.util.HashMap)9 Date (java.util.Date)6 List (java.util.List)5 CronScheduleBuilder (org.quartz.CronScheduleBuilder)5 BigDecimal (java.math.BigDecimal)4 PreparedStatement (java.sql.PreparedStatement)4 ResultSet (java.sql.ResultSet)4 ParseException (java.text.ParseException)4