本文整理汇总了Java中org.quartz.spi.OperableTrigger类的典型用法代码示例。如果您正苦于以下问题:Java OperableTrigger类的具体用法?Java OperableTrigger怎么用?Java OperableTrigger使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OperableTrigger类属于org.quartz.spi包,在下文中一共展示了OperableTrigger类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTriggerProperties
import org.quartz.spi.OperableTrigger; //导入依赖的package包/类
@Override
protected SimplePropertiesTriggerProperties getTriggerProperties(OperableTrigger trigger) {
CalendarIntervalTriggerImpl calTrig = (CalendarIntervalTriggerImpl)trigger;
SimplePropertiesTriggerProperties props = new SimplePropertiesTriggerProperties();
props.setInt1(calTrig.getRepeatInterval());
props.setString1(calTrig.getRepeatIntervalUnit().name());
props.setInt2(calTrig.getTimesTriggered());
props.setString2(calTrig.getTimeZone().getID());
props.setBoolean1(calTrig.isPreserveHourOfDayAcrossDaylightSavings());
props.setBoolean2(calTrig.isSkipDayIfHourDoesNotExist());
return props;
}
示例2: pauseJobs
import org.quartz.spi.OperableTrigger; //导入依赖的package包/类
/**
* <p>
* Pause all of the <code>{@link org.quartz.JobDetail}s</code> in the given group - by pausing all of their
* <code>Trigger</code>s.
* </p>
* <p>
* The JobStore should "remember" that the group is paused, and impose the pause on any new jobs that are added to the
* group while the group is paused.
* </p>
*/
@Override
public Collection<String> pauseJobs(GroupMatcher<JobKey> matcher) throws JobPersistenceException {
Collection<String> pausedGroups = new HashSet<String>();
lock();
try {
Set<JobKey> jobKeys = getJobKeys(matcher);
for (JobKey jobKey : jobKeys) {
for (OperableTrigger trigger : getTriggersForJob(jobKey)) {
pauseTrigger(trigger.getKey());
}
pausedGroups.add(jobKey.getGroup());
}
// make sure to account for an exact group match for a group that doesn't yet exist
StringMatcher.StringOperatorName operator = matcher.getCompareWithOperator();
if (operator.equals(StringOperatorName.EQUALS)) {
jobFacade.addPausedGroup(matcher.getCompareToValue());
pausedGroups.add(matcher.getCompareToValue());
}
} finally {
unlock();
}
return pausedGroups;
}
示例3: insertExtendedTriggerProperties
import org.quartz.spi.OperableTrigger; //导入依赖的package包/类
public int insertExtendedTriggerProperties(Connection conn, OperableTrigger trigger, String state, JobDetail jobDetail) throws SQLException, IOException {
SimpleTrigger simpleTrigger = (SimpleTrigger)trigger;
PreparedStatement ps = null;
try {
ps = conn.prepareStatement(Util.rtp(INSERT_SIMPLE_TRIGGER, tablePrefix, schedNameLiteral));
ps.setString(1, trigger.getKey().getName());
ps.setString(2, trigger.getKey().getGroup());
ps.setInt(3, simpleTrigger.getRepeatCount());
ps.setBigDecimal(4, new BigDecimal(String.valueOf(simpleTrigger.getRepeatInterval())));
ps.setInt(5, simpleTrigger.getTimesTriggered());
return ps.executeUpdate();
} finally {
Util.closeStatement(ps);
}
}
示例4: resumeJobs
import org.quartz.spi.OperableTrigger; //导入依赖的package包/类
/**
* <p>
* Resume (un-pause) all of the <code>{@link org.quartz.JobDetail}s</code> in the given group.
* </p>
* <p>
* If any of the <code>Job</code> s had <code>Trigger</code> s that missed one or more fire-times, then the
* <code>Trigger</code>'s misfire instruction will be applied.
* </p>
*/
@Override
public Collection<String> resumeJobs(GroupMatcher<JobKey> matcher) throws JobPersistenceException {
Collection<String> groups = new HashSet<String>();
lock();
try {
Set<JobKey> jobKeys = getJobKeys(matcher);
for (JobKey jobKey : jobKeys) {
if (groups.add(jobKey.getGroup())) {
jobFacade.removePausedJobGroup(jobKey.getGroup());
}
for (OperableTrigger trigger : getTriggersForJob(jobKey)) {
resumeTrigger(trigger.getKey());
}
}
} finally {
unlock();
}
return groups;
}
示例5: acquireNextTriggers
import org.quartz.spi.OperableTrigger; //导入依赖的package包/类
@Override
public List<OperableTrigger> acquireNextTriggers(long noLaterThan, int maxCount, long timeWindow)
throws JobPersistenceException {
List<OperableTrigger> result = new ArrayList<OperableTrigger>();;
lock();
try {
for (TriggerWrapper tw : getNextTriggerWrappers(timeTriggers, noLaterThan, maxCount, timeWindow)) {
result.add(markAndCloneTrigger(tw));
}
return result;
} finally {
try {
unlock();
} catch (RejoinException e) {
if (!validateAcquired(result)) {
throw e;
}
}
}
}
示例6: triggerJob
import org.quartz.spi.OperableTrigger; //导入依赖的package包/类
/**
* <p>
* Trigger the identified <code>{@link org.quartz.Job}</code> (execute it
* now) - with a non-volatile trigger.
* </p>
*/
@SuppressWarnings("deprecation")
public void triggerJob(JobKey jobKey, JobDataMap data) throws SchedulerException {
validateState();
OperableTrigger trig = (OperableTrigger) newTrigger().withIdentity(newTriggerId(), Scheduler.DEFAULT_GROUP).forJob(jobKey).build();
trig.computeFirstFireTime(null);
if(data != null) {
trig.setJobDataMap(data);
}
boolean collision = true;
while (collision) {
try {
resources.getJobStore().storeTrigger(trig, false);
collision = false;
} catch (ObjectAlreadyExistsException oaee) {
trig.setKey(new TriggerKey(newTriggerId(), Scheduler.DEFAULT_GROUP));
}
}
notifySchedulerThread(trig.getNextFireTime().getTime());
notifySchedulerListenersSchduled(trig);
}
示例7: scheduleJob
import org.quartz.spi.OperableTrigger; //导入依赖的package包/类
/**
* <p>
* Schedule the given <code>{@link org.quartz.Trigger}</code> with the
* <code>Job</code> identified by the <code>Trigger</code>'s settings.
* </p>
*
* @throws SchedulerException
* if the indicated Job does not exist, or the Trigger cannot be
* added to the Scheduler, or there is an internal Scheduler
* error.
*/
public Date scheduleJob(Trigger trigger)
throws SchedulerException {
validateState();
if (trigger == null) {
throw new SchedulerException("Trigger cannot be null");
}
OperableTrigger trig = (OperableTrigger)trigger;
trig.validate();
Calendar cal = null;
if (trigger.getCalendarName() != null) {
cal = resources.getJobStore().retrieveCalendar(trigger.getCalendarName());
if(cal == null) {
throw new SchedulerException(
"Calendar not found: " + trigger.getCalendarName());
}
}
Date ft = trig.computeFirstFireTime(cal);
if (ft == null) {
throw new SchedulerException(
"Based on configured schedule, the given trigger '" + trigger.getKey() + "' will never fire.");
}
resources.getJobStore().storeTrigger(trig, false);
notifySchedulerThread(trigger.getNextFireTime().getTime());
notifySchedulerListenersSchduled(trigger);
return ft;
}
示例8: 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);
}
示例9: removeCalendar
import org.quartz.spi.OperableTrigger; //导入依赖的package包/类
/**
* <p>
* Remove (delete) the <code>{@link org.quartz.Calendar}</code> with the
* given name.
* </p>
*
* <p>
* If removal of the <code>Calendar</code> would result in
* <code>Trigger</code>s pointing to non-existent calendars, then a
* <code>JobPersistenceException</code> will be thrown.</p>
* *
* @param calName The name of the <code>Calendar</code> to be removed.
* @return <code>true</code> if a <code>Calendar</code> with the given name
* was found and removed from the store.
*/
public boolean removeCalendar(String calName)
throws JobPersistenceException {
int numRefs = 0;
synchronized (lock) {
for (TriggerWrapper trigger : triggers) {
OperableTrigger trigg = trigger.trigger;
if (trigg.getCalendarName() != null
&& trigg.getCalendarName().equals(calName)) {
numRefs++;
}
}
}
if (numRefs > 0) {
throw new JobPersistenceException(
"Calender cannot be removed if it referenced by a Trigger!");
}
return (calendarsByName.remove(calName) != null);
}
示例10: toCompositeData
import org.quartz.spi.OperableTrigger; //导入依赖的package包/类
public static CompositeData toCompositeData(SimpleTrigger trigger) {
try {
return new CompositeDataSupport(COMPOSITE_TYPE, ITEM_NAMES,
new Object[] {
trigger.getRepeatCount(),
trigger.getRepeatInterval(),
trigger.getTimesTriggered(),
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);
}
}
示例11: updateMisfiredTrigger
import org.quartz.spi.OperableTrigger; //导入依赖的package包/类
protected boolean updateMisfiredTrigger(Connection conn,
TriggerKey triggerKey, String newStateIfNotComplete, boolean forceState)
throws JobPersistenceException {
try {
OperableTrigger trig = retrieveTrigger(conn, triggerKey);
long misfireTime = System.currentTimeMillis();
if (getMisfireThreshold() > 0) {
misfireTime -= getMisfireThreshold();
}
if (trig.getNextFireTime().getTime() > misfireTime) {
return false;
}
doUpdateOfMisfiredTrigger(conn, trig, forceState, newStateIfNotComplete, false);
return true;
} catch (Exception e) {
throw new JobPersistenceException(
"Couldn't update misfired trigger '" + triggerKey + "': " + e.getMessage(), e);
}
}
示例12: 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);
}
}
示例13: storeJobsAndTriggers
import org.quartz.spi.OperableTrigger; //导入依赖的package包/类
public void storeJobsAndTriggers(
final Map<JobDetail, Set<? extends Trigger>> triggersAndJobs, final boolean replace)
throws JobPersistenceException {
executeInLock(
(isLockOnInsert() || replace) ? LOCK_TRIGGER_ACCESS : null,
new VoidTransactionCallback() {
public void executeVoid(Connection conn) throws JobPersistenceException {
// FUTURE_TODO: make this more efficient with a true bulk operation...
for(JobDetail job: triggersAndJobs.keySet()) {
storeJob(conn, job, replace);
for(Trigger trigger: triggersAndJobs.get(job)) {
storeTrigger(conn, (OperableTrigger) trigger, job, replace,
Constants.STATE_WAITING, false, false);
}
}
}
});
}
示例14: pauseJobs
import org.quartz.spi.OperableTrigger; //导入依赖的package包/类
/**
* <p>
* Pause all of the <code>{@link org.quartz.Job}s</code> matching the given
* groupMatcher - by pausing all of their <code>Trigger</code>s.
* </p>
*
* @see #resumeJobs(org.quartz.impl.matchers.GroupMatcher)
*/
@SuppressWarnings("unchecked")
public Set<String> pauseJobs(final GroupMatcher<JobKey> matcher)
throws JobPersistenceException {
return (Set<String>) executeInLock(
LOCK_TRIGGER_ACCESS,
new TransactionCallback() {
public Set<String> execute(final Connection conn) throws JobPersistenceException {
Set<String> groupNames = new HashSet<String>();
Set<JobKey> jobNames = getJobNames(conn, matcher);
for (JobKey jobKey : jobNames) {
List<OperableTrigger> triggers = getTriggersForJob(conn, jobKey);
for (OperableTrigger trigger : triggers) {
pauseTrigger(conn, trigger.getKey());
}
groupNames.add(jobKey.getGroup());
}
return groupNames;
}
}
);
}
示例15: resumeJobs
import org.quartz.spi.OperableTrigger; //导入依赖的package包/类
/**
* <p>
* Resume (un-pause) all of the <code>{@link org.quartz.Job}s</code> in
* the given group.
* </p>
*
* <p>
* If any of the <code>Job</code> s had <code>Trigger</code> s that
* missed one or more fire-times, then the <code>Trigger</code>'s
* misfire instruction will be applied.
* </p>
*
* @see #pauseJobs(org.quartz.impl.matchers.GroupMatcher)
*/
@SuppressWarnings("unchecked")
public Set<String> resumeJobs(final GroupMatcher<JobKey> matcher)
throws JobPersistenceException {
return (Set<String>) executeInLock(
LOCK_TRIGGER_ACCESS,
new TransactionCallback() {
public Set<String> execute(Connection conn) throws JobPersistenceException {
Set<JobKey> jobKeys = getJobNames(conn, matcher);
Set<String> groupNames = new HashSet<String>();
for (JobKey jobKey: jobKeys) {
List<OperableTrigger> triggers = getTriggersForJob(conn, jobKey);
for (OperableTrigger trigger: triggers) {
resumeTrigger(conn, trigger.getKey());
}
groupNames.add(jobKey.getGroup());
}
return groupNames;
}
});
}