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

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

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

Trigger.getJobKey介绍

暂无

代码示例

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

@Override
protected void executeInternal(JobExecutionContext context)
    throws JobExecutionException {
  // load jobId
  JobKey jobKey = context.getTrigger().getJobKey();
  Integer jobId = Integer.valueOf(jobKey.getName());
  // trigger
  JobTriggerPoolHelper.trigger(jobId, TriggerTypeEnum.CRON, -1, null, null);
}

代码示例来源:origin: apache/incubator-gobblin

/** {@inheritDoc} */
@Override protected void doUnschedule(JobSpecSchedule existingSchedule) {
 Preconditions.checkNotNull(existingSchedule);
 Preconditions.checkArgument(existingSchedule instanceof QuartzJobSchedule);
 QuartzJobSchedule quartzSchedule = (QuartzJobSchedule)existingSchedule;
 try {
  _scheduler.getScheduler().deleteJob(quartzSchedule.getQuartzTrigger().getJobKey());
 } catch (SchedulerException e) {
  throw new RuntimeException("Unscheduling failed for " + existingSchedule.getJobSpec()
                + ":" + e, e);
 }
}

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

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

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

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

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

public static CompositeData toCompositeData(Trigger trigger) {
  try {
    return new CompositeDataSupport(COMPOSITE_TYPE, ITEM_NAMES,
        new Object[] {
            trigger.getKey().getName(),
            trigger.getKey().getGroup(),
            trigger.getJobKey().getName(),
            trigger.getJobKey().getGroup(),
            trigger.getDescription(),
            JobDataMapSupport.toTabularData(trigger
                .getJobDataMap()),
            trigger.getCalendarName(),
            ((OperableTrigger)trigger).getFireInstanceId(),
            trigger.getMisfireInstruction(),
            trigger.getPriority(), trigger.getStartTime(),
            trigger.getEndTime(), trigger.getNextFireTime(),
            trigger.getPreviousFireTime(),
            trigger.getFinalFireTime() });
  } catch (OpenDataException e) {
    throw new RuntimeException(e);
  }
}

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

if (!dupeT.getJobKey().equals(trigger.getJobKey())) {
      log.warn("Possibly duplicately named ({}) triggers in jobs xml file! ", trigger.getKey());
if(!dupeT.getJobKey().equals(trigger.getJobKey())) {
  log.warn("Possibly duplicately named ({}) triggers in jobs xml file! ", trigger.getKey());

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

if (!dupeT.getJobKey().equals(trigger.getJobKey())) {
      log.warn("Possibly duplicately named ({}) triggers in jobs xml file! ", trigger.getKey());
if(!dupeT.getJobKey().equals(trigger.getJobKey())) {
  log.warn("Possibly duplicately named ({}) triggers in jobs xml file! ", trigger.getKey());

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

return null;
} else {
  trig.setJobKey(oldTrigger.getJobKey());

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

/**
 * 恢复任务
 */
public void resume() {
 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.resumeJob(trigger.getJobKey());
   }
  }
 } catch (Exception e) {
  throw new QuartzException("Can't resume job.", e);
 }
}

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

return null;
} else {
  trig.setJobKey(oldTrigger.getJobKey());

代码示例来源:origin: apache/incubator-gobblin

Assert.assertTrue(jss1 instanceof QuartzJobSchedule);
QuartzJobSchedule qjss1 = (QuartzJobSchedule)jss1;
Assert.assertNotNull(scheduler._scheduler.getScheduler().getJobDetail(qjss1.getQuartzTrigger().getJobKey()));
Assert.assertNotNull(scheduler._scheduler.getScheduler().getTrigger(qjss1.getQuartzTrigger().getKey()));
Assert.assertTrue(qjss1.getQuartzTrigger().mayFireAgain());
Assert.assertFalse(scheduler._scheduler.getScheduler().checkExists(qjss1_2.getQuartzTrigger().getJobKey()));

代码示例来源: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: quartz-scheduler/quartz

if (trigger.getJobKey() == null) {
  trig.setJobKey(jobDetail.getKey());
} else if (!trigger.getJobKey().equals(jobDetail.getKey())) {
  throw new SchedulerException(
    "Trigger does not reference given job!");

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

if (trigger.getJobKey() == null) {
  trig.setJobKey(jobDetail.getKey());
} else if (!trigger.getJobKey().equals(jobDetail.getKey())) {
  throw new SchedulerException(
    "Trigger does not reference given job!");

代码示例来源:origin: net.sf.ehcache/ehcache

private void process(JobExecutionContext context, Ehcache underlyingCache, ScheduledRefreshConfiguration config,
          List<Serializable> batch) throws SchedulerException {
 JobDataMap map = new JobDataMap(context.getJobDetail().getJobDataMap());
 map.put(ScheduledRefreshCacheExtension.PROP_KEYS_TO_PROCESS, batch);
 Scheduler scheduler = context.getScheduler();
 JobDetail job = JobBuilder
   .newJob(RefreshBatchJob.class)
   .withIdentity("RefreshBatch-" + INSTANCE_ID_GENERATOR.incrementAndGet(),
     context.getTrigger().getJobKey().getGroup()).usingJobData(map).build();
 try {
   waitForOutstandingJobCount(context, config, scheduler, config.getParallelJobCount());
   if (!scheduler.isShutdown()) {
    Trigger trigger = TriggerBuilder.newTrigger().startNow().forJob(job).build();
    scheduler.scheduleJob(job, trigger);
   }
 } catch (SchedulerException e) {
   if (!scheduler.isShutdown()) {
    throw e;
   }
 }
}

代码示例来源:origin: xautlx/s2jh4net

public static boolean isTriggerLogRunHist(Trigger trigger) {
    Boolean hist = TRIGGER_HIST_MAPPING.get(trigger.getJobKey().getName());
    return hist == null ? true : hist;
  }
}

代码示例来源:origin: org.ikasan/ikasan-scheduler

@Override public void triggerFired(Trigger trigger, JobExecutionContext context)
{
  if(logger.isDebugEnabled())
  {
    logger.debug(getName() + " Trigger fired for [" + trigger.getKey() + "] at " + trigger.getStartTime()
        + " for job [" + trigger.getJobKey());
  }
}

代码示例来源:origin: com.linkedin.gobblin/gobblin-runtime

/** {@inheritDoc} */
@Override protected void doUnschedule(JobSpecSchedule existingSchedule) {
 Preconditions.checkNotNull(existingSchedule);
 Preconditions.checkArgument(existingSchedule instanceof QuartzJobSchedule);
 QuartzJobSchedule quartzSchedule = (QuartzJobSchedule)existingSchedule;
 try {
  _scheduler.getScheduler().deleteJob(quartzSchedule.getQuartzTrigger().getJobKey());
 } catch (SchedulerException e) {
  throw new RuntimeException("Unscheduling failed for " + existingSchedule.getJobSpec()
                + ":" + e, e);
 }
}

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

@Override
 public void triggerMisfired(Trigger trigger) {
  getLog().warn("Trigger {}.{} misfired job {}.{}  at: {}. Should have fired at: {}.",
         trigger.getKey().getGroup(), trigger.getKey().getName(),
         trigger.getJobKey().getGroup(), trigger.getJobKey().getName(), new java.util.Date(),
         trigger.getNextFireTime());
 }
}

代码示例来源:origin: metatron-app/metatron-discovery

public SchedulingJob(Trigger trigger, Trigger.TriggerState status) {
 this.name = trigger.getKey().getName();
 this.jobName = trigger.getJobKey().getName();
 this.group = trigger.getKey().getGroup();
 this.nextFireTime = new DateTime(trigger.getNextFireTime());
 this.status = status;
}

相关文章