org.quartz.spi.MutableTrigger Java Examples
The following examples show how to use
org.quartz.spi.MutableTrigger.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ScheduleManager.java From uyuni with GNU General Public License v2.0 | 6 votes |
private Trigger createTrigger(String name, String group, int mode, long interval) { SimpleTrigger trigger = newTrigger() .withIdentity(name, "default") .forJob(name, group) .startAt(new Date()) .endAt(null) .withSchedule(simpleSchedule() .withRepeatCount(mode) .withIntervalInMilliseconds(interval)) .build(); if (trigger instanceof MutableTrigger) { MutableTrigger mtrigger = (MutableTrigger) trigger; mtrigger.setMisfireInstruction(SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT); return mtrigger; } else { log.error("Cannot set MisfireInstruction since trigger is not instance of MutableTrigger: " + trigger); } return trigger; }
Example #2
Source File: TriggerBuilder.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Produce the <code>Trigger</code>. * * @return a Trigger that meets the specifications of the builder. */ @SuppressWarnings("unchecked") public T build() { if(scheduleBuilder == null) scheduleBuilder = SimpleScheduleBuilder.simpleSchedule(); MutableTrigger trig = scheduleBuilder.build(); trig.setCalendarName(calendarName); trig.setDescription(description); trig.setStartTime(startTime); trig.setEndTime(endTime); if(key == null) key = new TriggerKey(Key.createUniqueName(null), null); trig.setKey(key); if(jobKey != null) trig.setJobKey(jobKey); trig.setPriority(priority); if(!jobDataMap.isEmpty()) trig.setJobDataMap(jobDataMap); return (T) trig; }
Example #3
Source File: SimpleScheduleJobService.java From hsweb-framework with Apache License 2.0 | 6 votes |
protected void startJob(ScheduleJobEntity jobEntity) { try { if (scheduler.checkExists(createJobKey(jobEntity))) { return; } JobDetail jobDetail = JobBuilder .newJob(DynamicJob.class) .withIdentity(createJobKey(jobEntity)) .setJobData(createJobDataMap(jobEntity.getParameters())) .usingJobData(DynamicJobFactory.JOB_ID_KEY, jobEntity.getId()) .withDescription(jobEntity.getName() + (jobEntity.getRemark() == null ? "" : jobEntity.getRemark())) .build(); MutableTrigger trigger = scheduleTriggerBuilder.buildTrigger(jobEntity.getQuartzConfig()); trigger.setKey(createTriggerKey(jobEntity)); scheduler.scheduleJob(jobDetail, trigger); } catch (SchedulerException e) { throw new BusinessException("启动定时调度失败", e); } }
Example #4
Source File: SnifferJobManager.java From logsniffer with GNU Lesser General Public License v3.0 | 6 votes |
@Override @Transactional(rollbackFor = { SchedulerException.class, ParseException.class }) public void startSniffing(final long snifferId) throws SchedulerException { logger.debug("Starting cron job for sniffer: {}", snifferId); final Sniffer sniffer = snifferPersistence.getSniffer(snifferId); if (sniffer == null) { throw new SchedulerException("Sniffer not found: " + snifferId); } stopAndDeleteAllSnifferJobs(sniffer.getId()); MutableTrigger trigger; try { trigger = CronScheduleBuilder.cronScheduleNonvalidatedExpression(sniffer.getScheduleCronExpression()) .withMisfireHandlingInstructionDoNothing().build(); } catch (final ParseException e) { throw new SchedulerException("Failed to parse cron expression", e); } trigger.setKey(getKey(sniffer, sniffer.getLogSourceId())); final JobDetail jobDetail = JobBuilder.newJob(SnifferJob.class).requestRecovery() .withIdentity(getJobKey(sniffer, sniffer.getLogSourceId())).build(); scheduler.scheduleJob(jobDetail, trigger); final ScheduleInfo scheduleInfo = scheduleInfoAccess.getScheduleInfo(snifferId); scheduleInfo.setScheduled(true); scheduleInfoAccess.updateScheduleInfo(snifferId, scheduleInfo); logger.info("Scheduled cron job for sniffer {} and log source {} with trigger {}", sniffer, sniffer.getLogSourceId(), trigger); }
Example #5
Source File: SimpleScheduleBuilder.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Build the actual Trigger -- NOT intended to be invoked by end users, * but will rather be invoked by a TriggerBuilder which this * ScheduleBuilder is given to. * * @see TriggerBuilder#withSchedule(ScheduleBuilder) */ @Override public MutableTrigger build() { SimpleTriggerImpl st = new SimpleTriggerImpl(); st.setRepeatInterval(interval); st.setRepeatCount(repeatCount); st.setMisfireInstruction(misfireInstruction); return st; }
Example #6
Source File: XMLSchedulingDataProcessor.java From lams with GNU General Public License v2.0 | 5 votes |
private Map<JobKey, List<MutableTrigger>> buildTriggersByFQJobNameMap(List<MutableTrigger> triggers) { Map<JobKey, List<MutableTrigger>> triggersByFQJobName = new HashMap<JobKey, List<MutableTrigger>>(); for(MutableTrigger trigger: triggers) { List<MutableTrigger> triggersOfJob = triggersByFQJobName.get(trigger.getJobKey()); if(triggersOfJob == null) { triggersOfJob = new LinkedList<MutableTrigger>(); triggersByFQJobName.put(trigger.getJobKey(), triggersOfJob); } triggersOfJob.add(trigger); } return triggersByFQJobName; }
Example #7
Source File: CronScheduleBuilder.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Build the actual Trigger -- NOT intended to be invoked by end users, but * will rather be invoked by a TriggerBuilder which this ScheduleBuilder is * given to. * * @see TriggerBuilder#withSchedule(ScheduleBuilder) */ @Override public MutableTrigger build() { CronTriggerImpl ct = new CronTriggerImpl(); ct.setCronExpression(cronExpression); ct.setTimeZone(cronExpression.getTimeZone()); ct.setMisfireInstruction(misfireInstruction); return ct; }
Example #8
Source File: DailyTimeIntervalScheduleBuilder.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Build the actual Trigger -- NOT intended to be invoked by end users, * but will rather be invoked by a TriggerBuilder which this * ScheduleBuilder is given to. * * @see TriggerBuilder#withSchedule(ScheduleBuilder) */ @Override public MutableTrigger build() { DailyTimeIntervalTriggerImpl st = new DailyTimeIntervalTriggerImpl(); st.setRepeatInterval(interval); st.setRepeatIntervalUnit(intervalUnit); st.setMisfireInstruction(misfireInstruction); st.setRepeatCount(repeatCount); if(daysOfWeek != null) st.setDaysOfWeek(daysOfWeek); else st.setDaysOfWeek(ALL_DAYS_OF_THE_WEEK); if(startTimeOfDay != null) st.setStartTimeOfDay(startTimeOfDay); else st.setStartTimeOfDay(TimeOfDay.hourAndMinuteOfDay(0, 0)); if(endTimeOfDay != null) st.setEndTimeOfDay(endTimeOfDay); else st.setEndTimeOfDay(TimeOfDay.hourMinuteAndSecondOfDay(23, 59, 59)); return st; }
Example #9
Source File: CalendarIntervalScheduleBuilder.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Build the actual Trigger -- NOT intended to be invoked by end users, * but will rather be invoked by a TriggerBuilder which this * ScheduleBuilder is given to. * * @see TriggerBuilder#withSchedule(ScheduleBuilder) */ @Override public MutableTrigger build() { CalendarIntervalTriggerImpl st = new CalendarIntervalTriggerImpl(); st.setRepeatInterval(interval); st.setRepeatIntervalUnit(intervalUnit); st.setMisfireInstruction(misfireInstruction); st.setTimeZone(timeZone); st.setPreserveHourOfDayAcrossDaylightSavings(preserveHourOfDayAcrossDaylightSavings); st.setSkipDayIfHourDoesNotExist(skipDayIfHourDoesNotExist); return st; }
Example #10
Source File: SmartScheduleTriggerBuilder.java From hsweb-framework with Apache License 2.0 | 5 votes |
@Override public MutableTrigger buildTrigger(String config) { JSONObject configObj = JSON.parseObject(config); switch (configObj.getString("type")) { case "cron": String cron = configObj.getString("config"); return CronScheduleBuilder.cronSchedule(cron) .build(); default: throw new UnsupportedOperationException(config); } }
Example #11
Source File: XMLSchedulingDataProcessor.java From lams with GNU General Public License v2.0 | 4 votes |
protected void addTriggerToSchedule(MutableTrigger trigger) { loadedTriggers.add(trigger); }
Example #12
Source File: XMLSchedulingDataProcessor.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Returns a <code>List</code> of triggers loaded from the xml file. * <p/> * * @return a <code>List</code> of triggers. */ protected List<MutableTrigger> getLoadedTriggers() { return Collections.unmodifiableList(loadedTriggers); }
Example #13
Source File: ScheduleBuilder.java From lams with GNU General Public License v2.0 | votes |
protected abstract MutableTrigger build();
Example #14
Source File: ScheduleTriggerBuilder.java From hsweb-framework with Apache License 2.0 | votes |
MutableTrigger buildTrigger(String config);