本文整理汇总了Java中org.quartz.spi.OperableTrigger.getNextFireTime方法的典型用法代码示例。如果您正苦于以下问题:Java OperableTrigger.getNextFireTime方法的具体用法?Java OperableTrigger.getNextFireTime怎么用?Java OperableTrigger.getNextFireTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.quartz.spi.OperableTrigger
的用法示例。
在下文中一共展示了OperableTrigger.getNextFireTime方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeFireTimes
import org.quartz.spi.OperableTrigger; //导入方法依赖的package包/类
/**
* Returns a list of Dates that are the next fire times of a
* <code>Trigger</code>.
* The input trigger will be cloned before any work is done, so you need
* not worry about its state being altered by this method.
*
* @param trigg
* The trigger upon which to do the work
* @param cal
* The calendar to apply to the trigger's schedule
* @param numTimes
* The number of next fire times to produce
* @return List of java.util.Date objects
*/
public static List<Date> computeFireTimes(OperableTrigger trigg, org.quartz.Calendar cal,
int numTimes) {
LinkedList<Date> lst = new LinkedList<Date>();
OperableTrigger t = (OperableTrigger) trigg.clone();
if (t.getNextFireTime() == null) {
t.computeFirstFireTime(cal);
}
for (int i = 0; i < numTimes; i++) {
Date d = t.getNextFireTime();
if (d != null) {
lst.add(d);
t.triggered(cal);
} else {
break;
}
}
return java.util.Collections.unmodifiableList(lst);
}
示例2: doUpdateOfMisfiredTrigger
import org.quartz.spi.OperableTrigger; //导入方法依赖的package包/类
private void doUpdateOfMisfiredTrigger(Connection conn, OperableTrigger trig, boolean forceState, String newStateIfNotComplete, boolean recovering) throws JobPersistenceException {
Calendar cal = null;
if (trig.getCalendarName() != null) {
cal = retrieveCalendar(conn, trig.getCalendarName());
}
schedSignaler.notifyTriggerListenersMisfired(trig);
trig.updateAfterMisfire(cal);
if (trig.getNextFireTime() == null) {
storeTrigger(conn, trig,
null, true, STATE_COMPLETE, forceState, recovering);
schedSignaler.notifySchedulerListenersFinalized(trig);
} else {
storeTrigger(conn, trig, null, true, newStateIfNotComplete,
forceState, false);
}
}
示例3: computeFireTimesBetween
import org.quartz.spi.OperableTrigger; //导入方法依赖的package包/类
/**
* Returns a list of Dates that are the next fire times of a
* <code>Trigger</code>
* that fall within the given date range. The input trigger will be cloned
* before any work is done, so you need not worry about its state being
* altered by this method.
*
* <p>
* NOTE: if this is a trigger that has previously fired within the given
* date range, then firings which have already occurred will not be listed
* in the output List.
* </p>
*
* @param trigg
* The trigger upon which to do the work
* @param cal
* The calendar to apply to the trigger's schedule
* @param from
* The starting date at which to find fire times
* @param to
* The ending date at which to stop finding fire times
* @return List of java.util.Date objects
*/
public static List<Date> computeFireTimesBetween(OperableTrigger trigg,
org.quartz.Calendar cal, Date from, Date to) {
LinkedList<Date> lst = new LinkedList<Date>();
OperableTrigger t = (OperableTrigger) trigg.clone();
if (t.getNextFireTime() == null) {
t.setStartTime(from);
t.setEndTime(to);
t.computeFirstFireTime(cal);
}
while (true) {
Date d = t.getNextFireTime();
if (d != null) {
if (d.before(from)) {
t.triggered(cal);
continue;
}
if (d.after(to)) {
break;
}
lst.add(d);
t.triggered(cal);
} else {
break;
}
}
return java.util.Collections.unmodifiableList(lst);
}
示例4: computeFireTimesWithStart
import org.quartz.spi.OperableTrigger; //导入方法依赖的package包/类
public static Date computeFireTimesWithStart(OperableTrigger trigg,org.quartz.Calendar cal, Date from) {
OperableTrigger t = (OperableTrigger) trigg.clone();
if (t.getNextFireTime() == null) {
t.setStartTime(from);
t.computeFirstFireTime(cal);
}
return t.getNextFireTime();
}
示例5: triggersFired
import org.quartz.spi.OperableTrigger; //导入方法依赖的package包/类
/**
* <p>
* Inform the <code>JobStore</code> that the scheduler is now firing the
* given <code>Trigger</code> (executing its associated <code>Job</code>),
* that it had previously acquired (reserved).
* </p>
*/
public List<TriggerFiredResult> triggersFired(List<OperableTrigger> firedTriggers) {
synchronized (lock) {
List<TriggerFiredResult> results = new ArrayList<TriggerFiredResult>();
for (OperableTrigger trigger : firedTriggers) {
TriggerWrapper tw = triggersByKey.get(trigger.getKey());
// was the trigger deleted since being acquired?
if (tw == null || tw.trigger == null) {
continue;
}
// was the trigger completed, paused, blocked, etc. since being acquired?
if (tw.state != TriggerWrapper.STATE_ACQUIRED) {
continue;
}
Calendar cal = null;
if (tw.trigger.getCalendarName() != null) {
cal = retrieveCalendar(tw.trigger.getCalendarName());
if(cal == null)
continue;
}
Date prevFireTime = trigger.getPreviousFireTime();
// in case trigger was replaced between acquiring and firing
timeTriggers.remove(tw);
// call triggered on our copy, and the scheduler's copy
tw.trigger.triggered(cal);
trigger.triggered(cal);
//tw.state = TriggerWrapper.STATE_EXECUTING;
tw.state = TriggerWrapper.STATE_WAITING;
TriggerFiredBundle bndle = new TriggerFiredBundle(retrieveJob(
tw.jobKey), trigger, cal,
false, new Date(), trigger.getPreviousFireTime(), prevFireTime,
trigger.getNextFireTime());
JobDetail job = bndle.getJobDetail();
if (job.isConcurrentExectionDisallowed()) {
ArrayList<TriggerWrapper> trigs = getTriggerWrappersForJob(job.getKey());
for (TriggerWrapper ttw : trigs) {
if (ttw.state == TriggerWrapper.STATE_WAITING) {
ttw.state = TriggerWrapper.STATE_BLOCKED;
}
if (ttw.state == TriggerWrapper.STATE_PAUSED) {
ttw.state = TriggerWrapper.STATE_PAUSED_BLOCKED;
}
timeTriggers.remove(ttw);
}
blockedJobs.add(job.getKey());
} else if (tw.trigger.getNextFireTime() != null) {
synchronized (lock) {
timeTriggers.add(tw);
}
}
results.add(new TriggerFiredResult(bndle));
}
return results;
}
}
示例6: recoverMisfiredJobs
import org.quartz.spi.OperableTrigger; //导入方法依赖的package包/类
protected RecoverMisfiredJobsResult recoverMisfiredJobs(
Connection conn, boolean recovering)
throws JobPersistenceException, SQLException {
// If recovering, we want to handle all of the misfired
// triggers right away.
int maxMisfiresToHandleAtATime =
(recovering) ? -1 : getMaxMisfiresToHandleAtATime();
List<TriggerKey> misfiredTriggers = new LinkedList<TriggerKey>();
long earliestNewTime = Long.MAX_VALUE;
// We must still look for the MISFIRED state in case triggers were left
// in this state when upgrading to this version that does not support it.
boolean hasMoreMisfiredTriggers =
getDelegate().hasMisfiredTriggersInState(
conn, STATE_WAITING, getMisfireTime(),
maxMisfiresToHandleAtATime, misfiredTriggers);
if (hasMoreMisfiredTriggers) {
getLog().info(
"Handling the first " + misfiredTriggers.size() +
" triggers that missed their scheduled fire-time. " +
"More misfired triggers remain to be processed.");
} else if (misfiredTriggers.size() > 0) {
getLog().info(
"Handling " + misfiredTriggers.size() +
" trigger(s) that missed their scheduled fire-time.");
} else {
getLog().debug(
"Found 0 triggers that missed their scheduled fire-time.");
return RecoverMisfiredJobsResult.NO_OP;
}
for (TriggerKey triggerKey: misfiredTriggers) {
OperableTrigger trig =
retrieveTrigger(conn, triggerKey);
if (trig == null) {
continue;
}
doUpdateOfMisfiredTrigger(conn, trig, false, STATE_WAITING, recovering);
if(trig.getNextFireTime() != null && trig.getNextFireTime().getTime() < earliestNewTime)
earliestNewTime = trig.getNextFireTime().getTime();
}
return new RecoverMisfiredJobsResult(
hasMoreMisfiredTriggers, misfiredTriggers.size(), earliestNewTime);
}
示例7: updateTrigger
import org.quartz.spi.OperableTrigger; //导入方法依赖的package包/类
@Override
public int updateTrigger(Connection conn, OperableTrigger trigger, String state,
JobDetail jobDetail) throws SQLException, IOException {
ByteArrayOutputStream baos = serializeJobData(trigger.getJobDataMap());
int len = baos.toByteArray().length;
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
PreparedStatement ps = null;
int insertResult = 0;
try {
ps = conn.prepareStatement(rtp(UPDATE_TRIGGER));
ps.setString(1, trigger.getJobKey().getName());
ps.setString(2, trigger.getJobKey().getGroup());
ps.setString(3, trigger.getDescription());
long nextFireTime = -1;
if (trigger.getNextFireTime() != null) {
nextFireTime = trigger.getNextFireTime().getTime();
}
ps.setBigDecimal(4, new BigDecimal(String.valueOf(nextFireTime)));
long prevFireTime = -1;
if (trigger.getPreviousFireTime() != null) {
prevFireTime = trigger.getPreviousFireTime().getTime();
}
ps.setBigDecimal(5, new BigDecimal(String.valueOf(prevFireTime)));
ps.setString(6, state);
TriggerPersistenceDelegate tDel = findTriggerPersistenceDelegate(trigger);
String type = TTYPE_BLOB;
if(tDel != null)
type = tDel.getHandledTriggerTypeDiscriminator();
ps.setString(7, type);
ps.setBigDecimal(8, new BigDecimal(String.valueOf(trigger
.getStartTime().getTime())));
long endTime = 0;
if (trigger.getEndTime() != null) {
endTime = trigger.getEndTime().getTime();
}
ps.setBigDecimal(9, new BigDecimal(String.valueOf(endTime)));
ps.setString(10, trigger.getCalendarName());
ps.setInt(11, trigger.getMisfireInstruction());
ps.setInt(12, trigger.getPriority());
ps.setBinaryStream(13, bais, len);
ps.setString(14, trigger.getKey().getName());
ps.setString(15, trigger.getKey().getGroup());
insertResult = ps.executeUpdate();
if(tDel == null)
updateBlobTrigger(conn, trigger);
else
tDel.updateExtendedTriggerProperties(conn, trigger, state, jobDetail);
} finally {
closeStatement(ps);
}
return insertResult;
}
示例8: insertTrigger
import org.quartz.spi.OperableTrigger; //导入方法依赖的package包/类
/**
* <p>
* Insert the base trigger data.
* </p>
*
* @param conn
* the DB Connection
* @param trigger
* the trigger to insert
* @param state
* the state that the trigger should be stored in
* @return the number of rows inserted
*/
public int insertTrigger(Connection conn, OperableTrigger trigger, String state,
JobDetail jobDetail) throws SQLException, IOException {
ByteArrayOutputStream baos = null;
if(trigger.getJobDataMap().size() > 0) {
baos = serializeJobData(trigger.getJobDataMap());
}
PreparedStatement ps = null;
int insertResult = 0;
try {
ps = conn.prepareStatement(rtp(INSERT_TRIGGER));
ps.setString(1, trigger.getKey().getName());
ps.setString(2, trigger.getKey().getGroup());
ps.setString(3, trigger.getJobKey().getName());
ps.setString(4, trigger.getJobKey().getGroup());
ps.setString(5, trigger.getDescription());
if(trigger.getNextFireTime() != null)
ps.setBigDecimal(6, new BigDecimal(String.valueOf(trigger
.getNextFireTime().getTime())));
else
ps.setBigDecimal(6, null);
long prevFireTime = -1;
if (trigger.getPreviousFireTime() != null) {
prevFireTime = trigger.getPreviousFireTime().getTime();
}
ps.setBigDecimal(7, new BigDecimal(String.valueOf(prevFireTime)));
ps.setString(8, state);
TriggerPersistenceDelegate tDel = findTriggerPersistenceDelegate(trigger);
String type = TTYPE_BLOB;
if(tDel != null)
type = tDel.getHandledTriggerTypeDiscriminator();
ps.setString(9, type);
ps.setBigDecimal(10, new BigDecimal(String.valueOf(trigger
.getStartTime().getTime())));
long endTime = 0;
if (trigger.getEndTime() != null) {
endTime = trigger.getEndTime().getTime();
}
ps.setBigDecimal(11, new BigDecimal(String.valueOf(endTime)));
ps.setString(12, trigger.getCalendarName());
ps.setInt(13, trigger.getMisfireInstruction());
setBytes(ps, 14, baos);
ps.setInt(15, trigger.getPriority());
insertResult = ps.executeUpdate();
if(tDel == null)
insertBlobTrigger(conn, trigger);
else
tDel.insertExtendedTriggerProperties(conn, trigger, state, jobDetail);
} finally {
closeStatement(ps);
}
return insertResult;
}