本文整理了Java中org.quartz.Trigger.getNextFireTime()
方法的一些代码示例,展示了Trigger.getNextFireTime()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Trigger.getNextFireTime()
方法的具体详情如下:
包路径:org.quartz.Trigger
类名称:Trigger
方法名:getNextFireTime
[英]Returns the next time at which the Trigger
is scheduled to fire. If the trigger will not fire again, null
will be returned. Note that the time returned can possibly be in the past, if the time that was computed for the trigger to next fire has already arrived, but the scheduler has not yet been able to fire the trigger (which would likely be due to lack of resources e.g. threads).
The value returned is not guaranteed to be valid until after the Trigger
has been added to the scheduler.
[中]返回Trigger
计划发射的下一次时间。如果触发器不会再次触发,将返回null
。请注意,如果为触发下一次触发计算的时间已经到达,但调度程序尚未能够触发触发(这可能是由于缺少资源,例如线程),则返回的时间可能是过去的。
在将Trigger
添加到计划程序之后,才能保证返回的值有效。
代码示例来源:origin: javamelody/javamelody
Date getTriggerNextFireTime(Trigger trigger) {
return trigger.getNextFireTime();
}
代码示例来源:origin: apache/incubator-gobblin
@Override
public Optional<Long> getNextRunTimeMillis() {
Date nextRuntime = this.quartzTrigger.getNextFireTime();
return null != nextRuntime ? Optional.<Long>of(nextRuntime.getTime()) : Optional.<Long>absent();
}
代码示例来源:origin: quartz-scheduler/quartz
public int compare(Trigger t1, Trigger t2) {
return compare(t1.getNextFireTime(), t1.getPriority(), t1.getKey(), t2.getNextFireTime(), t2.getPriority(), t2.getKey());
}
}
代码示例来源:origin: quartz-scheduler/quartz
public int compare(Trigger t1, Trigger t2) {
return compare(t1.getNextFireTime(), t1.getPriority(), t1.getKey(), t2.getNextFireTime(), t2.getPriority(), t2.getKey());
}
}
代码示例来源:origin: apache/incubator-gobblin
/** {@inheritDoc} */
@Override protected JobSpecSchedule doScheduleJob(JobSpec jobSpec, Runnable jobRunnable) {
// Build a data map that gets passed to the job
JobDataMap jobDataMap = new JobDataMap();
jobDataMap.put(JOB_SPEC_KEY, jobSpec);
jobDataMap.put(JOB_RUNNABLE_KEY, jobRunnable);
// Build a Quartz job
JobDetail job = JobBuilder.newJob(QuartzJob.class)
.withIdentity(jobSpec.getUri().toString())
.withDescription(Strings.nullToEmpty(jobSpec.getDescription()))
.usingJobData(jobDataMap)
.build();
Trigger jobTrigger = createTrigger(job.getKey(), jobSpec);
QuartzJobSchedule jobSchedule = new QuartzJobSchedule(jobSpec, jobRunnable, jobTrigger);
try {
_scheduler.getScheduler().scheduleJob(job, jobTrigger);
getLog().info(String.format("Scheduled job %s next two fire times: %s , %s.", jobSpec, jobTrigger.getNextFireTime(),
jobTrigger.getFireTimeAfter(jobTrigger.getNextFireTime())));
} catch (SchedulerException e) {
throw new RuntimeException("Scheduling failed for " + jobSpec + ":" + e, e);
}
return jobSchedule;
}
代码示例来源:origin: quartz-scheduler/quartz
public void triggerFired(Trigger trigger, JobExecutionContext context) {
if (!getLog().isInfoEnabled()) {
return;
}
Object[] args = {
trigger.getKey().getName(), trigger.getKey().getGroup(),
trigger.getPreviousFireTime(), trigger.getNextFireTime(),
new java.util.Date(), context.getJobDetail().getKey().getName(),
context.getJobDetail().getKey().getGroup(),
Integer.valueOf(context.getRefireCount())
};
getLog().info(MessageFormat.format(getTriggerFiredMessage(), args));
}
代码示例来源:origin: quartz-scheduler/quartz
public void triggerFired(Trigger trigger, JobExecutionContext context) {
if (!getLog().isInfoEnabled()) {
return;
}
Object[] args = {
trigger.getKey().getName(), trigger.getKey().getGroup(),
trigger.getPreviousFireTime(), trigger.getNextFireTime(),
new java.util.Date(), context.getJobDetail().getKey().getName(),
context.getJobDetail().getKey().getGroup(),
Integer.valueOf(context.getRefireCount())
};
getLog().info(MessageFormat.format(getTriggerFiredMessage(), args));
}
代码示例来源:origin: azkaban/azkaban
private void ajaxFetchTrigger(final int projectId, final String flowId, final Session session,
final HashMap<String,
Object> ret) {
final ScheduledFlowTrigger res = this.scheduler
.getScheduledFlowTriggerJobs().stream().filter(
scheduledFlowTrigger -> scheduledFlowTrigger.getFlowId().equals(flowId)
&& scheduledFlowTrigger.getProjectId
() == projectId).findFirst().orElse(null);
if (res != null) {
final Map<String, Object> jsonObj = new HashMap<>();
jsonObj.put("cronExpression", res.getFlowTrigger().getSchedule().getCronExpression());
jsonObj.put("submitUser", res.getSubmitUser());
jsonObj.put("firstSchedTime",
utils.formatDateTime(res.getQuartzTrigger().getStartTime().getTime()));
jsonObj.put("nextExecTime",
utils.formatDateTime(res.getQuartzTrigger().getNextFireTime().getTime()));
Long maxWaitMin = null;
if (res.getFlowTrigger().getMaxWaitDuration().isPresent()) {
maxWaitMin = res.getFlowTrigger().getMaxWaitDuration().get().toMinutes();
}
jsonObj.put("maxWaitMin", maxWaitMin);
if (!res.getFlowTrigger().getDependencies().isEmpty()) {
jsonObj.put("dependencies", res.getDependencyListJson());
}
ret.put("flowTrigger", jsonObj);
}
}
代码示例来源: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
/**
* @see org.quartz.JobListener#jobExecutionVetoed(org.quartz.JobExecutionContext)
*/
public void jobExecutionVetoed(JobExecutionContext context) {
if (!getLog().isInfoEnabled()) {
return;
}
Trigger trigger = context.getTrigger();
Object[] args = {
context.getJobDetail().getKey().getName(),
context.getJobDetail().getKey().getGroup(), new java.util.Date(),
trigger.getKey().getName(), trigger.getKey().getGroup(),
trigger.getPreviousFireTime(), trigger.getNextFireTime(),
Integer.valueOf(context.getRefireCount())
};
getLog().info(MessageFormat.format(getJobWasVetoedMessage(), args));
}
代码示例来源:origin: quartz-scheduler/quartz
/**
* @see org.quartz.JobListener#jobToBeExecuted(JobExecutionContext)
*/
public void jobToBeExecuted(JobExecutionContext context) {
if (!getLog().isInfoEnabled()) {
return;
}
Trigger trigger = context.getTrigger();
Object[] args = {
context.getJobDetail().getKey().getName(),
context.getJobDetail().getKey().getGroup(), new java.util.Date(),
trigger.getKey().getName(), trigger.getKey().getGroup(),
trigger.getPreviousFireTime(), trigger.getNextFireTime(),
Integer.valueOf(context.getRefireCount())
};
getLog().info(MessageFormat.format(getJobToBeFiredMessage(), 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
/**
* @see org.quartz.JobListener#jobExecutionVetoed(org.quartz.JobExecutionContext)
*/
public void jobExecutionVetoed(JobExecutionContext context) {
if (!getLog().isInfoEnabled()) {
return;
}
Trigger trigger = context.getTrigger();
Object[] args = {
context.getJobDetail().getKey().getName(),
context.getJobDetail().getKey().getGroup(), new java.util.Date(),
trigger.getKey().getName(), trigger.getKey().getGroup(),
trigger.getPreviousFireTime(), trigger.getNextFireTime(),
Integer.valueOf(context.getRefireCount())
};
getLog().info(MessageFormat.format(getJobWasVetoedMessage(), args));
}
代码示例来源:origin: quartz-scheduler/quartz
/**
* @see org.quartz.JobListener#jobToBeExecuted(JobExecutionContext)
*/
public void jobToBeExecuted(JobExecutionContext context) {
if (!getLog().isInfoEnabled()) {
return;
}
Trigger trigger = context.getTrigger();
Object[] args = {
context.getJobDetail().getKey().getName(),
context.getJobDetail().getKey().getGroup(), new java.util.Date(),
trigger.getKey().getName(), trigger.getKey().getGroup(),
trigger.getPreviousFireTime(), trigger.getNextFireTime(),
Integer.valueOf(context.getRefireCount())
};
getLog().info(MessageFormat.format(getJobToBeFiredMessage(), args));
}
代码示例来源:origin: kairosdb/kairosdb
private void updateScheduledTask(RollupTask task)
{
try {
scheduler.cancel(getJobKey(task.getId()));
}
catch (KairosDBException e) {
logger.error("Could not cancel roll up task job " + task, e);
return;
}
try {
logger.info("Updating schedule for rollup " + task.getName());
JobDetailImpl jobDetail = createJobDetail(task, dataStore, hostName, eventBus, statusStore);
Trigger trigger = createTrigger(task);
scheduler.schedule(jobDetail, trigger);
logger.info("Roll-up task " + task.getName() + " with id " + jobDetail.getKey() + " scheduled. Next execution time " + trigger.getNextFireTime());
}
catch (KairosDBException e) {
logger.error("Could not schedule roll up task job " + task, e);
}
}
代码示例来源:origin: quartz-scheduler/quartz
public void triggerComplete(Trigger trigger, JobExecutionContext context,
CompletedExecutionInstruction triggerInstructionCode) {
if (!getLog().isInfoEnabled()) {
return;
}
String instrCode = "UNKNOWN";
if (triggerInstructionCode == CompletedExecutionInstruction.DELETE_TRIGGER) {
instrCode = "DELETE TRIGGER";
} else if (triggerInstructionCode == CompletedExecutionInstruction.NOOP) {
instrCode = "DO NOTHING";
} else if (triggerInstructionCode == CompletedExecutionInstruction.RE_EXECUTE_JOB) {
instrCode = "RE-EXECUTE JOB";
} else if (triggerInstructionCode == CompletedExecutionInstruction.SET_ALL_JOB_TRIGGERS_COMPLETE) {
instrCode = "SET ALL OF JOB'S TRIGGERS COMPLETE";
} else if (triggerInstructionCode == CompletedExecutionInstruction.SET_TRIGGER_COMPLETE) {
instrCode = "SET THIS TRIGGER COMPLETE";
}
Object[] args = {
trigger.getKey().getName(), trigger.getKey().getGroup(),
trigger.getPreviousFireTime(), trigger.getNextFireTime(),
new java.util.Date(), context.getJobDetail().getKey().getName(),
context.getJobDetail().getKey().getGroup(),
Integer.valueOf(context.getRefireCount()),
triggerInstructionCode.toString(), instrCode
};
getLog().info(MessageFormat.format(getTriggerCompleteMessage(), args));
}
代码示例来源:origin: quartz-scheduler/quartz
public void triggerComplete(Trigger trigger, JobExecutionContext context,
CompletedExecutionInstruction triggerInstructionCode) {
if (!getLog().isInfoEnabled()) {
return;
}
String instrCode = "UNKNOWN";
if (triggerInstructionCode == CompletedExecutionInstruction.DELETE_TRIGGER) {
instrCode = "DELETE TRIGGER";
} else if (triggerInstructionCode == CompletedExecutionInstruction.NOOP) {
instrCode = "DO NOTHING";
} else if (triggerInstructionCode == CompletedExecutionInstruction.RE_EXECUTE_JOB) {
instrCode = "RE-EXECUTE JOB";
} else if (triggerInstructionCode == CompletedExecutionInstruction.SET_ALL_JOB_TRIGGERS_COMPLETE) {
instrCode = "SET ALL OF JOB'S TRIGGERS COMPLETE";
} else if (triggerInstructionCode == CompletedExecutionInstruction.SET_TRIGGER_COMPLETE) {
instrCode = "SET THIS TRIGGER COMPLETE";
}
Object[] args = {
trigger.getKey().getName(), trigger.getKey().getGroup(),
trigger.getPreviousFireTime(), trigger.getNextFireTime(),
new java.util.Date(), context.getJobDetail().getKey().getName(),
context.getJobDetail().getKey().getGroup(),
Integer.valueOf(context.getRefireCount()),
triggerInstructionCode.toString(), instrCode
};
getLog().info(MessageFormat.format(getTriggerCompleteMessage(), args));
}
代码示例来源:origin: quartz-scheduler/quartz
private boolean notifyTriggerListenersComplete(JobExecutionContext jobExCtxt, CompletedExecutionInstruction instCode) {
try {
qs.notifyTriggerListenersComplete(jobExCtxt, instCode);
} catch (SchedulerException se) {
qs.notifySchedulerListenersError(
"Unable to notify TriggerListener(s) of Job that was executed: "
+ "(error will be ignored). trigger= "
+ jobExCtxt.getTrigger().getKey() + " job= "
+ jobExCtxt.getJobDetail().getKey(), se);
return false;
}
if (jobExCtxt.getTrigger().getNextFireTime() == null) {
qs.notifySchedulerListenersFinalized(jobExCtxt.getTrigger());
}
return true;
}
代码示例来源:origin: quartz-scheduler/quartz
private boolean notifyTriggerListenersComplete(JobExecutionContext jobExCtxt, CompletedExecutionInstruction instCode) {
try {
qs.notifyTriggerListenersComplete(jobExCtxt, instCode);
} catch (SchedulerException se) {
qs.notifySchedulerListenersError(
"Unable to notify TriggerListener(s) of Job that was executed: "
+ "(error will be ignored). trigger= "
+ jobExCtxt.getTrigger().getKey() + " job= "
+ jobExCtxt.getJobDetail().getKey(), se);
return false;
}
if (jobExCtxt.getTrigger().getNextFireTime() == null) {
qs.notifySchedulerListenersFinalized(jobExCtxt.getTrigger());
}
return true;
}
代码示例来源: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);
}
}
内容来源于网络,如有侵权,请联系作者删除!