本文整理汇总了Java中org.quartz.TriggerUtils类的典型用法代码示例。如果您正苦于以下问题:Java TriggerUtils类的具体用法?Java TriggerUtils怎么用?Java TriggerUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TriggerUtils类属于org.quartz包,在下文中一共展示了TriggerUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.quartz.TriggerUtils; //导入依赖的package包/类
/**
* Check that all properties are properly set
*/
public void init() throws SchedulerException
{
PropertyCheck.mandatory(this, "scheduler", scheduler);
PropertyCheck.mandatory(this, "transactionService", transactionService);
PropertyCheck.mandatory(this, "repoUsageComponent", repoUsageComponent);
PropertyCheck.mandatory(this, "jobLockService", jobLockService);
// Trigger the scheduled updates
final JobDetail jobDetail = new JobDetail("rmj", Scheduler.DEFAULT_GROUP, RepoUsageMonitorJob.class);
jobDetail.getJobDataMap().put("RepoUsageMonitor", this);
final Trigger trigger = TriggerUtils.makeHourlyTrigger(12); // every 12 hours
trigger.setStartTime(new Date(System.currentTimeMillis() + 60L * 60L * 1000L)); // one hour from now
trigger.setName("rmt");
trigger.setGroup(Scheduler.DEFAULT_GROUP);
repoUsageComponent.observeRestrictions(this);
// Unschedule in case it was scheduled in an earlier retry of the transaction
scheduler.unscheduleJob("rmt", Scheduler.DEFAULT_GROUP);
scheduler.scheduleJob(jobDetail, trigger);
}
示例2: makeIntervalTrigger
import org.quartz.TriggerUtils; //导入依赖的package包/类
private static final Trigger makeIntervalTrigger(String type, String interval,
String repititions) throws ParseException {
try {
final int i = Integer.parseInt(interval);
int r = SimpleTrigger.REPEAT_INDEFINITELY;
if (!repititions.trim().equals("")) {
r = Integer.parseInt(repititions);
}
if (type.equals(FREQUENCY_SECONDLY)) {
return TriggerUtils.makeSecondlyTrigger(i, r);
} else if (type.equals(FREQUENCY_MINUTELY)) {
return TriggerUtils.makeMinutelyTrigger(i, r);
} else if (type.equals(FREQUENCY_HOURLY)) {
return TriggerUtils.makeHourlyTrigger(i, r);
}
return null;
} catch (final NumberFormatException e) {
throw new ParseException("Invalid interval or repitition value.", -1);
}
}
示例3: immediately
import org.quartz.TriggerUtils; //导入依赖的package包/类
@Override
public void immediately(Job job) {
logger.debug("Scheduling immediate job: " + job.getName());
String jobId = "Schedule-"
+ job.getName() + "-" + job.getId() + "-" + Calendar.getInstance().getTimeInMillis();
JobDetail jobDetail = new JobDetail( jobId, JobExecutor.class);
logger.debug("Configuring Scheduler Job with id: "+jobId);
//Trigger fires as quick as possible
//first argument 0 : no repeats
//second argument is the interval between repeats, but irrelevant here
Trigger trigger = TriggerUtils.makeImmediateTrigger(0, 1000);
trigger.setName("Immediate trigger - " + jobId);
trigger.setGroup("JobScheduleGroup");
JobDataMap jobData = createJobDataMap(job.getId());
trigger.setJobDataMap(jobData);
try {
scheduler.scheduleJob(jobDetail, trigger);
logger.debug("Trigger for immediate run fired!");
} catch (SchedulerException e) {
logger.error("Scheduling immediate job \"" + job.getName()
+ "\" failed");
e.printStackTrace();
}
}
示例4: execute
import org.quartz.TriggerUtils; //导入依赖的package包/类
public String execute() throws Exception
{
log.debug("re index users called");
//create the job detail
JobDetail jobDetail = new JobDetail("reIndexUsersJob", Scheduler.DEFAULT_GROUP,
edu.ur.ir.user.service.DefaultReIndexUsersJob.class);
jobDetail.getJobDataMap().put("batchSize", Integer.valueOf(batchSize));
//create a trigger that fires once right away
Trigger trigger = TriggerUtils.makeImmediateTrigger(0,0);
trigger.setName("SingleReIndexUsersJobFireNow");
quartzScheduler.scheduleJob(jobDetail, trigger);
return SUCCESS;
}
示例5: execute
import org.quartz.TriggerUtils; //导入依赖的package包/类
public String execute() throws Exception
{
log.debug("re index users called");
//create the job detail
JobDetail jobDetail = new JobDetail("reIndexUserGroupsJob", Scheduler.DEFAULT_GROUP,
edu.ur.ir.user.service.DefaultReIndexUserGroupsJob.class);
jobDetail.getJobDataMap().put("batchSize", Integer.valueOf(batchSize));
//create a trigger that fires once right away
Trigger trigger = TriggerUtils.makeImmediateTrigger(0,0);
trigger.setName("SingleReIndexUserGroupsJobFireNow");
quartzScheduler.scheduleJob(jobDetail, trigger);
return SUCCESS;
}
示例6: execute
import org.quartz.TriggerUtils; //导入依赖的package包/类
public String execute() throws Exception
{
log.debug("re index users called");
//create the job detail
JobDetail jobDetail = new JobDetail("reIndexResearchersJob", Scheduler.DEFAULT_GROUP,
edu.ur.ir.researcher.service.DefaultReIndexResearchersJob.class);
jobDetail.getJobDataMap().put("batchSize", Integer.valueOf(batchSize));
//create a trigger that fires once right away
Trigger trigger = TriggerUtils.makeImmediateTrigger(0,0);
trigger.setName("SingleReIndexResearchersJobFireNow");
quartzScheduler.scheduleJob(jobDetail, trigger);
return SUCCESS;
}
示例7: runFileDownloadUpdateProcessing
import org.quartz.TriggerUtils; //导入依赖的package包/类
/**
* Sets the re
* @return
* @throws SchedulerException
*/
public String runFileDownloadUpdateProcessing() throws SchedulerException
{
log.debug("Setting up job to be fired for updateing stats");
//create the job detail
JobDetail jobDetail = new JobDetail("reCountFileDownloadsJob", Scheduler.DEFAULT_GROUP,
edu.ur.ir.statistics.service.DefaultFileDownloadStatsUpdateJob.class);
jobDetail.getJobDataMap().put("batchSize", new Integer(1000));
//create a trigger that fires once right away
Trigger trigger = TriggerUtils.makeImmediateTrigger(0,0);
trigger.setName("singleReCountDownlodsJobFireNow");
quartzScheduler.scheduleJob(jobDetail, trigger);
return SUCCESS;
}
示例8: execute
import org.quartz.TriggerUtils; //导入依赖的package包/类
public String execute() throws Exception
{
log.debug("re index person names called");
//create the job detail
JobDetail jobDetail = new JobDetail("reIndexPersonNameAuthoritiesJob", Scheduler.DEFAULT_GROUP,
edu.ur.ir.person.service.DefaultReIndexPersonNameAuthoritiesJob.class);
jobDetail.getJobDataMap().put("batchSize", Integer.valueOf(batchSize));
//create a trigger that fires once right away
Trigger trigger = TriggerUtils.makeImmediateTrigger(0,0);
trigger.setName("SingleReIndexPersonNameAuthoritiesJobFireNow");
quartzScheduler.scheduleJob(jobDetail, trigger);
return SUCCESS;
}
示例9: getScheduledJobTimingsWithPrefix
import org.quartz.TriggerUtils; //导入依赖的package包/类
@Override
public List<DateTime> getScheduledJobTimingsWithPrefix(
String subject, String externalJobIdPrefix, DateTime startDate, DateTime endDate) {
JobId jobId = new CronJobId(subject, externalJobIdPrefix);
List<Date> messageTimings = new ArrayList<>();
try {
List<TriggerKey> triggerKeys = new ArrayList<TriggerKey>(
scheduler.getTriggerKeys(GroupMatcher.triggerGroupContains(JOB_GROUP_NAME)));
for (TriggerKey triggerKey : triggerKeys) {
if (StringUtils.isNotEmpty(externalJobIdPrefix) && triggerKey.getName().contains(jobId.value())) {
Trigger trigger = scheduler.getTrigger(triggerKey);
messageTimings.addAll(TriggerUtils.computeFireTimesBetween(
(OperableTrigger) trigger, new BaseCalendar(), DateUtil.toDate(startDate), DateUtil.toDate(endDate)));
}
}
} catch (SchedulerException e) {
throw new MotechSchedulerException(String.format(
"Can not get scheduled job timings given subject and externalJobIdPrefix for dates : %s %s %s %s %s",
subject, externalJobIdPrefix, startDate.toString(), endDate.toString(), e.getMessage()), e);
}
return DateUtil.datesToDateTimes(messageTimings);
}
示例10: runTaskNow
import org.quartz.TriggerUtils; //导入依赖的package包/类
/**
* Runs the passed Task immediately, regardless of any schedule settings.
*
* @param task Task to run.
*/
public void runTaskNow(Task task) {
JobDetail jobDetail = createJobDetail(task);
// modify group name otherwise this has potential to clash with other scheduled run of this job
jobDetail.setGroup(jobDetail.getGroup() + SUFFIX_IMMEDIATE);
Trigger trigger = TriggerUtils.makeImmediateTrigger(String.valueOf(task.getId()), 0, 1);
log.info("Scheduling task with id " + task.getId() + " to run now");
try {
scheduler.scheduleJob(jobDetail, trigger);
} catch (SchedulerException e) {
throw new ScheduleException("Error scheduling task with id " + task.getId(), e);
}
}
示例11: execute
import org.quartz.TriggerUtils; //导入依赖的package包/类
public String execute() throws Exception
{
log.debug("re index users called");
//create the job detail
JobDetail jobDetail = new JobDetail("fixPublisherInfoJob", Scheduler.DEFAULT_GROUP,
edu.ur.ir.util.service.PublisherToLocationCorrectorJob.class);
//create a trigger that fires once right away
Trigger trigger = TriggerUtils.makeImmediateTrigger(0,0);
trigger.setName("SingleFixPublisherInfoJobFireNow");
quartzScheduler.scheduleJob(jobDetail, trigger);
return SUCCESS;
}
示例12: execute
import org.quartz.TriggerUtils; //导入依赖的package包/类
public String execute() throws Exception
{
log.debug("re institutional collections called");
//create the job detail
JobDetail jobDetail = new JobDetail("reIndexInstitutionalCollectionsJob", Scheduler.DEFAULT_GROUP,
edu.ur.ir.institution.service.InstitutionalCollectionIndexProcessingJob.class);
//create a trigger that fires once right away
Trigger trigger = TriggerUtils.makeImmediateTrigger(0,0);
trigger.setName("SingleReIndexPersonNameAuthoritiesJobFireNow");
quartzScheduler.scheduleJob(jobDetail, trigger);
return SUCCESS;
}
示例13: getScheduledJobTimings
import org.quartz.TriggerUtils; //导入依赖的package包/类
@Override
public List<DateTime> getScheduledJobTimings(String subject, String externalJobId, DateTime startDate, DateTime endDate) {
JobId jobId = new CronJobId(subject, externalJobId);
Trigger trigger;
try {
trigger = scheduler.getTrigger(triggerKey(jobId.value(), JOB_GROUP_NAME));
return DateUtil.datesToDateTimes(TriggerUtils.computeFireTimesBetween(
(OperableTrigger) trigger, new BaseCalendar(), DateUtil.toDate(startDate), DateUtil.toDate(endDate)));
} catch (SchedulerException e) {
throw new MotechSchedulerException(String.format(
"Can not get scheduled job timings given subject and externalJobId for dates : %s %s %s %s %s",
subject, externalJobId, startDate.toString(), endDate.toString(), e.getMessage()), e);
}
}
示例14: buildJobDetail
import org.quartz.TriggerUtils; //导入依赖的package包/类
private Trigger buildJobDetail(SchedulableJob schedulableJob, Date jobStartTime, Date jobEndTime,
JobId jobId, JobDetail jobDetail, ScheduleBuilder scheduleBuilder) {
Trigger trigger = newTrigger()
.withIdentity(triggerKey(jobId.value(), JOB_GROUP_NAME))
.forJob(jobDetail)
.withSchedule(scheduleBuilder)
.startAt(jobStartTime)
.endAt(jobEndTime)
.build();
DateTime now = now();
if (schedulableJob.isIgnorePastFiresAtStart() && newDateTime(jobStartTime).isBefore(now)) {
List<Date> pastTriggers = TriggerUtils.computeFireTimesBetween((OperableTrigger) trigger, null, jobStartTime, now.toDate());
if (pastTriggers.size() > 0) {
if (scheduleBuilder instanceof SimpleScheduleBuilder && ((RepeatingSchedulableJob) schedulableJob).getRepeatCount() != null) {
((SimpleScheduleBuilder) scheduleBuilder)
.withRepeatCount(((RepeatingSchedulableJob) schedulableJob).getRepeatCount() - pastTriggers.size());
}
Date newStartTime = getFirstTriggerInFuture(trigger, now);
trigger = newTrigger()
.withIdentity(triggerKey(jobId.value(), JOB_GROUP_NAME))
.forJob(jobDetail)
.withSchedule(scheduleBuilder)
.startAt(newStartTime)
.endAt(jobEndTime)
.build();
}
}
return trigger;
}
示例15: getJobInfo
import org.quartz.TriggerUtils; //导入依赖的package包/类
private String getJobInfo(Trigger trigger, String jobType) throws SchedulerException {
if (jobType.equals(JobBasicInfo.JOBTYPE_REPEATING)) {
Integer timesTriggered = 0;
String repeatMaxCount = "-";
if (trigger instanceof CalendarIntervalTrigger) {
CalendarIntervalTrigger calendarIntervalTrigger = (CalendarIntervalTrigger) trigger;
timesTriggered = calendarIntervalTrigger.getTimesTriggered();
} else if (trigger instanceof SimpleTrigger) {
SimpleTrigger simpleTrigger = (SimpleTrigger) trigger;
timesTriggered = simpleTrigger.getTimesTriggered();
}
if (trigger.getEndTime() != null) {
repeatMaxCount = Integer.toString(TriggerUtils.computeFireTimesBetween(
(OperableTrigger) trigger, null, trigger.getStartTime(), trigger.getEndTime()
).size() + timesTriggered);
}
return String.format("%d/%s", timesTriggered, repeatMaxCount);
} else if (jobType.equals(JobBasicInfo.JOBTYPE_CRON)) {
CronScheduleBuilder cronScheduleBuilder = (CronScheduleBuilder) trigger.getScheduleBuilder();
CronTrigger cronTrigger = (CronTrigger) cronScheduleBuilder.build();
return cronTrigger.getCronExpression();
} else {
return "-";
}
}