org.quartz.Scheduler.pauseTrigger()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(399)

本文整理了Java中org.quartz.Scheduler.pauseTrigger()方法的一些代码示例,展示了Scheduler.pauseTrigger()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Scheduler.pauseTrigger()方法的具体详情如下:
包路径:org.quartz.Scheduler
类名称:Scheduler
方法名:pauseTrigger

Scheduler.pauseTrigger介绍

[英]Pause the Trigger with the given name.
[中]暂停带有给定名称的Trigger

代码示例

代码示例来源:origin: Dreampie/Resty

/**
 * 暂停任务
 */
public void pause() {
 long id = quartzKey.getId();
 String name = quartzKey.getName();
 String group = quartzKey.getGroup();
 SchedulerFactory factory = Quartzer.getSchedulerFactory();
 try {
  if (factory != null) {
   Scheduler scheduler = factory.getScheduler();
   TriggerKey triggerKey = TriggerKey.triggerKey(TRIGGER_MARK + SEPARATOR + name + SEPARATOR + id, GROUP_MARK + SEPARATOR + group + SEPARATOR + id);
   Trigger trigger = scheduler.getTrigger(triggerKey);
   if (trigger != null) {
    scheduler.pauseTrigger(triggerKey);
   }
  }
 } catch (Exception e) {
  throw new QuartzException("Can't pause job.", e);
 }
}

代码示例来源:origin: Dreampie/Resty

/**
 * 停止任务
 */
public void stop() {
 long id = quartzKey.getId();
 String name = quartzKey.getName();
 String group = quartzKey.getGroup();
 SchedulerFactory factory = Quartzer.getSchedulerFactory();
 try {
  if (factory != null) {
   Scheduler scheduler = factory.getScheduler();
   TriggerKey triggerKey = TriggerKey.triggerKey(TRIGGER_MARK + SEPARATOR + name + SEPARATOR + id, GROUP_MARK + SEPARATOR + group + SEPARATOR + id);
   Trigger trigger = scheduler.getTrigger(triggerKey);
   if (trigger != null) {
    scheduler.pauseTrigger(triggerKey);
    scheduler.unscheduleJob(triggerKey);
    scheduler.deleteJob(trigger.getJobKey());
    Quartzer.removeQuartzJob(this);
   }
  }
 } catch (Exception e) {
  throw new QuartzException("Can't stop job.", e);
 }
}

代码示例来源:origin: Exrick/x-boot

/**
 * 删除定时任务
 * @param jobClassName
 */
public void delete(String jobClassName){
  try {
    scheduler.pauseTrigger(TriggerKey.triggerKey(jobClassName));
    scheduler.unscheduleJob(TriggerKey.triggerKey(jobClassName));
    scheduler.deleteJob(JobKey.jobKey(jobClassName));
  } catch (Exception e) {
    throw new XbootException("删除定时任务失败");
  }
}

代码示例来源:origin: io.antmedia/ant-media-server-common

public void pauseScheduledTrigger(String name) {
  try {
    scheduler.pauseTrigger(keyMap.get(name).tKey);
  } catch (SchedulerException ex) {
    throw new RuntimeException(ex);
  }
}

代码示例来源:origin: org.codelibs/elasticsearch-quartz

public void pauseTrigger(final TriggerKey triggerKey) {
  try {
    scheduler.pauseTrigger(triggerKey);
  } catch (final SchedulerException e) {
    throw new QuartzSchedulerException(e);
  }
}

代码示例来源:origin: myschedule/myschedule-quartz-extra

public void pauseTrigger(TriggerKey triggerKey) {
  try {
    scheduler.pauseTrigger(triggerKey);
  } catch (SchedulerException e) {
    throw new QuartzRuntimeException(e);
  }
}

代码示例来源:origin: org.jboss.seam/jboss-seam

public void pause() throws SchedulerException
{
 getScheduler().pauseTrigger(triggerName, null);  
}

代码示例来源:origin: bingoohuang/quartz-glass

@RequestMapping("/jobs/{group}/{name}/triggers/{triggerGroup}/{triggerName}/pause")
public String pause(@PathVariable String group, @PathVariable String name, @PathVariable String triggerGroup, @PathVariable String triggerName, @RequestParam(required = false) String redirect) throws SchedulerException {
  JobDetail job = quartzScheduler.getJobDetail(new JobKey(name, group));
  if (job == null) return "redirect:/glass/jobs";
  quartzScheduler.pauseTrigger(new TriggerKey(triggerName, triggerGroup));
  if (StringUtils.isNotEmpty(redirect)) return "redirect:" + redirect;
  return "redirect:/glass";
}

代码示例来源:origin: org.apache.camel/camel-quartz2

public void pauseRouteTrigger(Action action, String routeId) throws SchedulerException {
  TriggerKey triggerKey = retrieveTriggerKey(action, routeId);
  
  getScheduler().pauseTrigger(triggerKey);
  LOG.debug("Scheduled trigger: {} is paused", triggerKey);
}

代码示例来源:origin: pl.edu.icm.sedno/sedno-tools

public void pauseTrigger(String triggerName) {
  try {
    getScheduler().pauseTrigger(triggerName, getTrigger(triggerName).getGroup());
  }catch (SchedulerException e) {
    throw new RuntimeException(e);
  }    
}

代码示例来源:origin: com.soento/soento-cms

public void removeJob(Class<? extends Job> jobClass, String jobGroupName) {
  try {
    scheduler.pauseTrigger(TriggerKey.triggerKey(jobClass.getName(), jobGroupName));
    scheduler.unscheduleJob(TriggerKey.triggerKey(jobClass.getName(), jobGroupName));
    scheduler.deleteJob(JobKey.jobKey(jobClass.getName(), jobGroupName));
  } catch (Exception e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: org.apache.camel/camel-quartz

public void pauseRouteTrigger(Action action, String routeId) throws SchedulerException {
  String triggerName = retrieveTriggerName(action, routeId);
  String triggerGroup = retrieveTriggerGroup(action, routeId);
  
  getScheduler().pauseTrigger(triggerName, triggerGroup);
  LOG.debug("Scheduled trigger: {}.{} is paused", triggerGroup, triggerName);
}

代码示例来源:origin: org.apache.camel/camel-quartz2

public void pauseTrigger() throws Exception {
  Scheduler scheduler = getComponent().getScheduler();
  boolean isClustered = scheduler.getMetaData().isJobStoreClustered();
  if (jobPaused.get() || isClustered) {
    return;
  }
  
  jobPaused.set(true);
  if (!scheduler.isShutdown()) {
    LOG.info("Pausing trigger {}", triggerKey);
    scheduler.pauseTrigger(triggerKey);
  }
}

代码示例来源:origin: cdapio/cdap

public void suspendProgramSchedule(ProgramSchedule schedule) throws NotFoundException, SchedulerException {
 try {
  Collection<TriggerKey> triggerKeys = getGroupedTriggerKeys(schedule);
  // Must assert all trigger keys exist before processing each trigger key
  assertTriggerKeysExist(triggerKeys);
  for (TriggerKey triggerKey : triggerKeys) {
   scheduler.pauseTrigger(triggerKey);
  }
 } catch (org.quartz.SchedulerException e) {
  throw new SchedulerException(e);
 }
}

代码示例来源:origin: com.threewks.thundr/thundr-quartz

@Override
public void pauseTrigger(TriggerKey triggerKey) throws QuartzException {
  try {
    delegate.pauseTrigger(triggerKey);
  } catch (SchedulerException e) {
    Logger.error(e.getMessage());
    throw new QuartzException(e);
  }
}

代码示例来源:origin: co.cask.cdap/cdap-app-fabric

public void suspendProgramSchedule(ProgramSchedule schedule) throws NotFoundException, SchedulerException {
 try {
  Collection<TriggerKey> triggerKeys = getGroupedTriggerKeys(schedule);
  // Must assert all trigger keys exist before processing each trigger key
  assertTriggerKeysExist(triggerKeys);
  for (TriggerKey triggerKey : triggerKeys) {
   scheduler.pauseTrigger(triggerKey);
  }
 } catch (org.quartz.SchedulerException e) {
  throw new SchedulerException(e);
 }
}

代码示例来源:origin: com.threewks.thundr/thundr-contrib-quartz

@Override
public void pauseTrigger(TriggerKey triggerKey) throws QuartzException {
  try {
    delegate.pauseTrigger(triggerKey);
  } catch (SchedulerException e) {
    Logger.error(e.getMessage());
    throw new QuartzException(e);
  }
}

代码示例来源:origin: pl.edu.icm.sedno/sedno-tools

public void applyStartupPauseConfig() {
  for (Trigger trigger : getAllTriggers()) {
    if (shouldBePaused(trigger)) {
      try {
        getScheduler().pauseTrigger(trigger.getName(), trigger.getGroup());
        logger.info(" pausing trigger: "+ trigger.getName());
      }catch (SchedulerException e) {
        throw new RuntimeException(e);
      }                    
    }
  }
}

代码示例来源:origin: org.apache.camel/camel-quartz

public void pauseJob(Trigger trigger) throws SchedulerException {
  if (isClustered()) {
    // do not pause jobs which are clustered, as we want the jobs to continue running on the other nodes
    LOG.debug("Cannot pause job using trigger: {}/{} as the JobStore is clustered.", trigger.getGroup(), trigger.getName());
  } else {
    LOG.debug("Pausing job using trigger: {}/{}", trigger.getGroup(), trigger.getName());
    getScheduler().pauseTrigger(trigger.getName(), trigger.getGroup());
    getScheduler().pauseJob(trigger.getName(), trigger.getGroup());
  }
  // only decrement job counter if we are successful
  decrementJobCounter(getScheduler());
}

代码示例来源:origin: xkcoding/spring-boot-demo

/**
 * 删除定时任务
 *
 * @param form 表单参数 {@link JobForm}
 * @throws SchedulerException 异常
 */
@Override
public void deleteJob(JobForm form) throws SchedulerException {
  scheduler.pauseTrigger(TriggerKey.triggerKey(form.getJobClassName(), form.getJobGroupName()));
  scheduler.unscheduleJob(TriggerKey.triggerKey(form.getJobClassName(), form.getJobGroupName()));
  scheduler.deleteJob(JobKey.jobKey(form.getJobClassName(), form.getJobGroupName()));
}

相关文章