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

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

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

Scheduler.getTriggerState介绍

[英]Get the current state of the identified Trigger.
[中]获取标识的Trigger的当前状态。

代码示例

代码示例来源:origin: javamelody/javamelody

boolean isTriggerPaused(Trigger trigger, Scheduler scheduler) throws SchedulerException {
  return scheduler.getTriggerState(trigger.getName(),
      trigger.getGroup()) == Trigger.STATE_PAUSED;
}

代码示例来源:origin: elasticjob/elastic-job-lite

/**
 * 判断作业是否暂停.
 * 
 * @return 作业是否暂停
 */
public synchronized boolean isPaused() {
  try {
    return !scheduler.isShutdown() && Trigger.TriggerState.PAUSED == scheduler.getTriggerState(new TriggerKey(triggerIdentity));
  } catch (final SchedulerException ex) {
    throw new JobSystemException(ex);
  }
}

代码示例来源:origin: xuxueli/xxl-job

/**
 * fill job info
 *
 * @param jobInfo
 */
public static void fillJobInfo(XxlJobInfo jobInfo) {
  String group = String.valueOf(jobInfo.getJobGroup());
  String name = String.valueOf(jobInfo.getId());
  // trigger key
  TriggerKey triggerKey = TriggerKey.triggerKey(name, group);
  try {
    // trigger cron
    Trigger trigger = scheduler.getTrigger(triggerKey);
    if (trigger!=null && trigger instanceof CronTriggerImpl) {
      String cronExpression = ((CronTriggerImpl) trigger).getCronExpression();
      jobInfo.setJobCron(cronExpression);
    }
    // trigger state
    TriggerState triggerState = scheduler.getTriggerState(triggerKey);
    if (triggerState!=null) {
      jobInfo.setJobStatus(triggerState.name());
    }
    //JobKey jobKey = new JobKey(jobInfo.getJobName(), String.valueOf(jobInfo.getJobGroup()));
    //JobDetail jobDetail = scheduler.getJobDetail(jobKey);
    //String jobClass = jobDetail.getJobClass().getName();
    
  } catch (SchedulerException e) {
    logger.error(e.getMessage(), e);
  }
}

代码示例来源:origin: azkaban/azkaban

public synchronized boolean isJobPaused(final String jobName, final String groupName)
  throws SchedulerException {
 final JobKey jobKey = new JobKey(jobName, groupName);
 final JobDetail jobDetail = this.scheduler.getJobDetail(jobKey);
 final List<? extends Trigger> triggers = this.scheduler.getTriggersOfJob(jobDetail.getKey());
 for (final Trigger trigger : triggers) {
  final TriggerState triggerState = this.scheduler.getTriggerState(trigger.getKey());
  if (TriggerState.PAUSED.equals(triggerState)) {
   return true;
  }
 }
 return false;
}

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

public Trigger.TriggerState getState() {
 long id = quartzKey.getId();
 String name = quartzKey.getName();
 String group = quartzKey.getGroup();
 SchedulerFactory factory = Quartzer.getSchedulerFactory();
 Trigger.TriggerState triggerState = null;
 try {
  if (factory != null) {
   Scheduler scheduler = factory.getScheduler();
   TriggerKey triggerKey = TriggerKey.triggerKey(TRIGGER_MARK + SEPARATOR + name + SEPARATOR + id, GROUP_MARK + SEPARATOR + group + SEPARATOR + id);
   triggerState = scheduler.getTriggerState(triggerKey);
  }
 } catch (Exception e) {
  throw new QuartzException("Can't get job state.", e);
 }
 return triggerState;
}

代码示例来源:origin: stackoverflow.com

// get the scheduler factory bean from the spring context
Scheduler scheduler = (Scheduler) getApplicationContext().getBean("schedulerFactoryBean");
// get the TriggerKey 
TriggerKey triggerKey = TriggerKey.triggerKey("serviceCronTrigger");
// get the state from the triggerKey
TriggerState triggerState = scheduler.getTriggerState(triggerKey);

代码示例来源:origin: stackoverflow.com

// get the scheduler factory bean from the spring context
Scheduler scheduler = (Scheduler)   getApplicationContext().getBean("schedulerFactoryBean");
// get the state 
int state = scheduler.getTriggerState(triggerName, triggerGroup);

代码示例来源:origin: org.molgenis/molgenis-data-idcard

@Override
public TriggerState getIndexRebuildStatus(TriggerKey triggerKey) throws SchedulerException
{
  return scheduler.getTriggerState(triggerKey);
}

代码示例来源:origin: bill1012/AdminEAP

/**
 * 获取运行中的任务
 */
public List<ScheduleJob> getRunningJobs() throws SchedulerException {
  Scheduler scheduler = schedulerFactoryBean.getScheduler();
  List<JobExecutionContext> executingJobs = scheduler.getCurrentlyExecutingJobs();
  List<ScheduleJob> jobList = new ArrayList<ScheduleJob>(executingJobs.size());
  for (JobExecutionContext executingJob : executingJobs) {
    ScheduleJob job = new ScheduleJob();
    JobDetail jobDetail = executingJob.getJobDetail();
    JobKey jobKey = jobDetail.getKey();
    Trigger trigger = executingJob.getTrigger();
    job.setJobId(jobKey.getGroup() + "_" + jobKey.getName());
    job.setJobName(jobKey.getName());
    job.setJobGroup(jobKey.getGroup());
    job.setDesc(trigger.getDescription());
    Trigger.TriggerState triggerState = scheduler.getTriggerState(trigger.getKey());
    job.setJobStatus(triggerState.name());
    if (trigger instanceof CronTrigger) {
      CronTrigger cronTrigger = (CronTrigger) trigger;
      String cronExpression = cronTrigger.getCronExpression();
      job.setCronExpression(cronExpression);
    }
    jobList.add(job);
  }
  return jobList;
}

代码示例来源:origin: bill1012/AdminEAP

Trigger.TriggerState triggerState = scheduler.getTriggerState(trigger.getKey());
job.setJobStatus(triggerState.name());

代码示例来源:origin: bill1012/AdminEAP

Trigger.TriggerState triggerState = scheduler.getTriggerState(trigger.getKey());
job.setJobStatus(triggerState.name());
if (trigger instanceof CronTrigger) {

代码示例来源:origin: com.blazebit/blaze-quartz-utils

public static Trigger.TriggerState getState(TriggerKey key)
    throws SchedulerException {
  Scheduler sched = StdSchedulerFactory.getDefaultScheduler();
  return sched.getTriggerState(key);
}

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

public TriggerState getTriggerState(TriggerKey triggerKey) {
  try {
    return scheduler.getTriggerState(triggerKey);
  } catch (SchedulerException e) {
    throw new QuartzRuntimeException(e);
  }
}

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

public TriggerState getTriggerState(final TriggerKey triggerKey) {
  try {
    return scheduler.getTriggerState(triggerKey);
  } catch (final SchedulerException e) {
    throw new QuartzSchedulerException(e);
  }
}

代码示例来源:origin: liveoak-io/liveoak

@Override
public Map<String, ?> properties(RequestContext ctx) throws Exception {
  Map<String, Object> result = new HashMap<>();
  result.put("cron", ((CronTrigger) this.trigger).getCronExpression());
  Trigger.TriggerState state = this.parent.scheduler().getTriggerState(this.trigger.getKey());
  result.put("state", state.toString().toLowerCase());
  return result;
}

代码示例来源:origin: org.exoplatform.kernel/exo.kernel.component.common

public TriggerState getTriggerState(String jobName, String groupName) throws Exception
{
 return scheduler_.getTriggerState(TriggerKey.triggerKey(jobName, getGroupName(groupName)));
}

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

private int getTriggerState(Trigger trigger) {
  try {
    return getScheduler().getTriggerState(trigger.getName(), trigger.getGroup());
  }catch (SchedulerException e) {
    throw new RuntimeException(e);
  }
}

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

@Override
public Trigger.TriggerState getTriggerState(TriggerKey triggerKey) throws QuartzException {
  try {
    return delegate.getTriggerState(triggerKey);
  } catch (SchedulerException e) {
    Logger.error(e.getMessage());
    throw new QuartzException(e);
  }
}

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

@Override
public Trigger.TriggerState getTriggerState(TriggerKey triggerKey) throws QuartzException {
  try {
    return delegate.getTriggerState(triggerKey);
  } catch (SchedulerException e) {
    Logger.error(e.getMessage());
    throw new QuartzException(e);
  }
}

代码示例来源:origin: robeio/robe

public boolean isPausedJob(String name, String group) throws SchedulerException {
  List<? extends Trigger> triggers = scheduler.getTriggersOfJob(JobKey.jobKey(name, group));
  for (Trigger t : triggers) {
    if (!scheduler.getTriggerState(t.getKey()).equals(Trigger.TriggerState.PAUSED)) {
      return false;
    }
  }
  return true;
}

相关文章