org.quartz.Trigger.getJobGroup()方法的使用及代码示例

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

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

Trigger.getJobGroup介绍

[英]Get the name of the associated org.quartz.JobDetail's group.
[中]获取关联的org.quartz.JobDetail组的名称。

代码示例

代码示例来源:origin: com.opensymphony.quartz/com.springsource.org.quartz

public void triggerMisfired(Trigger trigger) {
  if (!getLog().isInfoEnabled()) {
    return;
  } 
  
  Object[] args = {
    trigger.getName(), trigger.getGroup(),
    trigger.getPreviousFireTime(), trigger.getNextFireTime(),
    new java.util.Date(), trigger.getJobGroup(),
    trigger.getJobGroup()
  };
  getLog().info(MessageFormat.format(getTriggerMisfiredMessage(), args));
}

代码示例来源:origin: com.opensymphony.quartz/com.springsource.org.quartz

TriggerWrapper(Trigger trigger) {
  this.trigger = trigger;
  key = getTriggerNameKey(trigger);
  this.jobKey = JobWrapper.getJobNameKey(trigger.getJobName(), trigger
      .getJobGroup());
}

代码示例来源:origin: quartz/quartz-all

JobWrapper jw = (JobWrapper) jobsByFQN.get(JobWrapper
    .getJobNameKey(tw.trigger.getJobName(), tw.trigger
        .getJobGroup()));
Trigger[] trigs = getTriggersForJob(ctxt, tw.trigger
    .getJobName(), tw.trigger.getJobGroup());
if ((trigs == null || trigs.length == 0) && !jw.jobDetail.isDurable()) {
  removeJob(ctxt, tw.trigger.getJobName(), tw.trigger
      .getJobGroup());

代码示例来源:origin: com.opensymphony.quartz/com.springsource.org.quartz

JobWrapper jw = (JobWrapper) jobsByFQN.get(JobWrapper
    .getJobNameKey(tw.trigger.getJobName(), tw.trigger
        .getJobGroup()));
Trigger[] trigs = getTriggersForJob(ctxt, tw.trigger
    .getJobName(), tw.trigger.getJobGroup());
if ((trigs == null || trigs.length == 0) && !jw.jobDetail.isDurable()) {
  removeJob(ctxt, tw.trigger.getJobName(), tw.trigger
      .getJobGroup());

代码示例来源:origin: quartz/quartz-all

TriggerWrapper(Trigger trigger) {
  this.trigger = trigger;
  key = getTriggerNameKey(trigger);
  this.jobKey = JobWrapper.getJobNameKey(trigger.getJobName(), trigger
      .getJobGroup());
}

代码示例来源:origin: com.opensymphony.quartz/com.springsource.org.quartz

/**
 * <p>
 * Resume (un-pause) all of the <code>{@link Trigger}s</code> in the
 * given group.
 * </p>
 *
 * <p>
 * If any <code>Trigger</code> missed one or more fire-times, then the
 * <code>Trigger</code>'s misfire instruction will be applied.
 * </p>
 *
 */
public void resumeTriggerGroup(SchedulingContext ctxt, String groupName) {
  synchronized (triggerLock) {
    String[] names = getTriggerNames(ctxt, groupName);
    for (int i = 0; i < names.length; i++) {
      String key = TriggerWrapper.getTriggerNameKey(names[i], groupName);
      if(triggersByFQN.get(key) != null) {
        String jobGroup = ((TriggerWrapper) triggersByFQN.get(key)).getTrigger().getJobGroup();
        if(pausedJobGroups.contains(jobGroup)) {
          continue;
        }
      }
      resumeTrigger(ctxt, names[i], groupName);
    }
    pausedTriggerGroups.remove(groupName);
  }
}

代码示例来源:origin: quartz/quartz-all

/**
 * <p>
 * Resume (un-pause) all of the <code>{@link Trigger}s</code> in the
 * given group.
 * </p>
 *
 * <p>
 * If any <code>Trigger</code> missed one or more fire-times, then the
 * <code>Trigger</code>'s misfire instruction will be applied.
 * </p>
 *
 */
public void resumeTriggerGroup(SchedulingContext ctxt, String groupName) {
  synchronized (triggerLock) {
    String[] names = getTriggerNames(ctxt, groupName);
    for (int i = 0; i < names.length; i++) {
      String key = TriggerWrapper.getTriggerNameKey(names[i], groupName);
      if(triggersByFQN.get(key) != null) {
        String jobGroup = ((TriggerWrapper) triggersByFQN.get(key)).getTrigger().getJobGroup();
        if(pausedJobGroups.contains(jobGroup)) {
          continue;
        }
      }
      resumeTrigger(ctxt, names[i], groupName);
    }
    pausedTriggerGroups.remove(groupName);
  }
}

代码示例来源:origin: quartz/quartz-all

public void triggerMisfired(Trigger trigger) {
  if (!getLog().isInfoEnabled()) {
    return;
  } 
  
  Object[] args = {
    trigger.getName(), trigger.getGroup(),
    trigger.getPreviousFireTime(), trigger.getNextFireTime(),
    new java.util.Date(), trigger.getJobName(),
    trigger.getJobGroup()
  };
  getLog().info(MessageFormat.format(getTriggerMisfiredMessage(), args));
}

代码示例来源:origin: com.opensymphony.quartz/com.springsource.org.quartz

!tw.getTrigger().getJobGroup().equals(newTrigger.getJobGroup())) {
throw new JobPersistenceException("New trigger is not related to the same job as the old trigger.");

代码示例来源:origin: quartz/quartz-all

!tw.getTrigger().getJobGroup().equals(newTrigger.getJobGroup())) {
throw new JobPersistenceException("New trigger is not related to the same job as the old trigger.");

代码示例来源:origin: com.opensymphony.quartz/com.springsource.org.quartz

if(blockedJobs.contains( JobWrapper.getJobNameKey(trig.getJobName(), trig.getJobGroup()) )) {
  tw.state = TriggerWrapper.STATE_BLOCKED;
} else {

代码示例来源:origin: quartz/quartz-all

if(blockedJobs.contains( JobWrapper.getJobNameKey(trig.getJobName(), trig.getJobGroup()) )) {
  tw.state = TriggerWrapper.STATE_BLOCKED;
} else {

代码示例来源:origin: com.opensymphony.quartz/com.springsource.org.quartz

if (job != null) {
  ps.setString(8, trigger.getJobName());
  ps.setString(9, trigger.getJobGroup());
  setBoolean(ps, 10, job.isStateful());
  setBoolean(ps, 11, job.requestsRecovery());

代码示例来源:origin: quartz/quartz-all

if (job != null) {
  ps.setString(8, trigger.getJobName());
  ps.setString(9, trigger.getJobGroup());
  setBoolean(ps, 10, job.isStateful());
  setBoolean(ps, 11, job.requestsRecovery());

代码示例来源:origin: org.kuali.kpme/kpme-tk-lm-impl

private void rescheduleJob(JobExecutionContext context) throws JobExecutionException {
    try {
      Scheduler scheduler = context.getScheduler();
      Trigger oldTrigger = context.getTrigger();
      
      DateTime newStartTime = new DateTime().plusMinutes(5);
      String newTriggerName = BatchJobUtil.getTriggerName(SupervisorApprovalJob.class, newStartTime);
      Trigger newTrigger = new SimpleTrigger(newTriggerName, oldTrigger.getGroup(), newStartTime.toDate());
      newTrigger.setJobName(oldTrigger.getJobName());
      newTrigger.setJobGroup(oldTrigger.getJobGroup());
      
      LOG.info("Rescheduing " + newTrigger.getFullJobName() + " to be run on " + newTrigger.getStartTime());
      
      scheduler.rescheduleJob(oldTrigger.getName(), oldTrigger.getGroup(), newTrigger);
    } catch (SchedulerException se) {
      LOG.error("Failure to execute job due to SchedulerException", se);
//            throw new JobExecutionException(se);
    }
  }

代码示例来源:origin: org.kuali.kpme/kpme-tk-lm-impl

private void rescheduleJob(JobExecutionContext context) throws JobExecutionException {
    try {
      Scheduler scheduler = context.getScheduler();
      Trigger oldTrigger = context.getTrigger();
      
      DateTime newStartTime = new DateTime().plusMinutes(5);
      String newTriggerName = BatchJobUtil.getTriggerName(PayrollApprovalJob.class, newStartTime);
      Trigger newTrigger = new SimpleTrigger(newTriggerName, oldTrigger.getGroup(), newStartTime.toDate());
      newTrigger.setJobName(oldTrigger.getJobName());
      newTrigger.setJobGroup(oldTrigger.getJobGroup());
      
      LOG.info("Rescheduing " + newTrigger.getFullJobName() + " to be run on " + newTrigger.getStartTime());
      
      scheduler.rescheduleJob(oldTrigger.getName(), oldTrigger.getGroup(), newTrigger);
    } catch (SchedulerException se) {
      LOG.error("Failure to execute job due to SchedulerException", se);
//            throw new JobExecutionException(se);
    }
  }

代码示例来源:origin: com.opensymphony.quartz/com.springsource.org.quartz

protected boolean replaceTrigger(Connection conn, SchedulingContext ctxt,
    String triggerName, String groupName, Trigger newTrigger)
  throws JobPersistenceException {
  try {
    // this must be called before we delete the trigger, obviously
    JobDetail job = getDelegate().selectJobForTrigger(conn,
        triggerName, groupName, getClassLoadHelper());
    if (job == null) {
      return false;
    }
    
    if (!newTrigger.getJobName().equals(job.getName()) || 
      !newTrigger.getJobGroup().equals(job.getGroup())) {
      throw new JobPersistenceException("New trigger is not related to the same job as the old trigger.");
    }
    
    boolean removedTrigger = 
      deleteTriggerAndChildren(conn, triggerName, groupName);
    
    storeTrigger(conn, ctxt, newTrigger, job, false, STATE_WAITING, false, false);
    return removedTrigger;
  } catch (ClassNotFoundException e) {
    throw new JobPersistenceException("Couldn't remove trigger: "
        + e.getMessage(), e);
  } catch (SQLException e) {
    throw new JobPersistenceException("Couldn't remove trigger: "
        + e.getMessage(), e);
  }
}

代码示例来源:origin: quartz/quartz-all

protected boolean replaceTrigger(Connection conn, SchedulingContext ctxt,
    String triggerName, String groupName, Trigger newTrigger)
  throws JobPersistenceException {
  try {
    // this must be called before we delete the trigger, obviously
    JobDetail job = getDelegate().selectJobForTrigger(conn,
        triggerName, groupName, getClassLoadHelper());
    if (job == null) {
      return false;
    }
    
    if (!newTrigger.getJobName().equals(job.getName()) || 
      !newTrigger.getJobGroup().equals(job.getGroup())) {
      throw new JobPersistenceException("New trigger is not related to the same job as the old trigger.");
    }
    
    boolean removedTrigger = 
      deleteTriggerAndChildren(conn, triggerName, groupName);
    
    storeTrigger(conn, ctxt, newTrigger, job, false, STATE_WAITING, false, false);
    return removedTrigger;
  } catch (ClassNotFoundException e) {
    throw new JobPersistenceException("Couldn't remove trigger: "
        + e.getMessage(), e);
  } catch (SQLException e) {
    throw new JobPersistenceException("Couldn't remove trigger: "
        + e.getMessage(), e);
  }
}

代码示例来源:origin: net.sourceforge.kivu4j.job/kivu4j-job-services

/**
 * 检查trigger,是否需要取消或者重新注册
 * 
 * @param trigger
 */
private void check(Trigger trigger) {
  Assert.notNull(trigger, "'trigger' must not be null");
  
  Timetable tt_in_trigger = (Timetable)trigger.getJobDataMap().get(Consts.TIMETABLE);
  
  if (tt_in_trigger == null){
    // 非法的trigger,取消
    this.scheduleManager.unscheduleJob(trigger.getName(), trigger.getGroup());
    return;
  }
  
  Timetable tt_in_database = this.timetableRepository.findById(tt_in_trigger.getID());
  if (tt_in_database == null || ! tt_in_database.isActive()){
    // Timetable在数据库中不存在,或者不活动
    this.scheduleManager.unscheduleJob(trigger.getName(), trigger.getGroup());
    return;
  }        
  
  // 重新发布
  Trigger newTrigger = this.createTrigger(trigger.getJobName(), trigger.getJobGroup(), tt_in_database);
  this.rescheduleJob(trigger, newTrigger);
}

代码示例来源:origin: net.sourceforge.kivu4j.job/kivu4j-job-services

public TriggerDto make(Trigger trigger) {
    int state = this.scheduleManager.getTriggerState(trigger.getName(),
        trigger.getGroup());
    TriggerDto dto = new TriggerDto(trigger.getJobName(),
        trigger.getJobGroup(),
        trigger.getName(),
        trigger.getGroup(),
        trigger.getFullName(),
        trigger.getDescription(), 
        ConvertUtil.convert(trigger.getNextFireTime(), String.class),
        state);    
    dto.setID(ConvertUtil.convert(trigger.getFullName().hashCode(), Long.class));
    return dto;
  }
}

相关文章