public TriggerPropertyBundle loadExtendedTriggerProperties(Connection conn, TriggerKey triggerKey) throws SQLException { PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(Util.rtp(SELECT_CRON_TRIGGER, tablePrefix, schedNameLiteral)); ps.setString(1, triggerKey.getName()); ps.setString(2, triggerKey.getGroup()); rs = ps.executeQuery(); if (rs.next()) { String cronExpr = rs.getString(COL_CRON_EXPRESSION); String timeZoneId = rs.getString(COL_TIME_ZONE_ID); CronScheduleBuilder cb = CronScheduleBuilder.cronSchedule(cronExpr); if (timeZoneId != null) cb.inTimeZone(TimeZone.getTimeZone(timeZoneId)); return new TriggerPropertyBundle(cb, null, null); } throw new IllegalStateException("No record found for selection of Trigger with key: '" + triggerKey + "' and statement: " + Util.rtp(SELECT_CRON_TRIGGER, tablePrefix, schedNameLiteral)); } finally { Util.closeResultSet(rs); Util.closeStatement(ps); } }
public TriggerPropertyBundle loadExtendedTriggerProperties(Connection conn, TriggerKey triggerKey) throws SQLException { PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(Util.rtp(SELECT_CRON_TRIGGER, tablePrefix, schedNameLiteral)); ps.setString(1, triggerKey.getName()); ps.setString(2, triggerKey.getGroup()); rs = ps.executeQuery(); if (rs.next()) { String cronExpr = rs.getString(COL_CRON_EXPRESSION); String timeZoneId = rs.getString(COL_TIME_ZONE_ID); CronScheduleBuilder cb = CronScheduleBuilder.cronSchedule(cronExpr); if (timeZoneId != null) cb.inTimeZone(TimeZone.getTimeZone(timeZoneId)); return new TriggerPropertyBundle(cb, null, null); } throw new IllegalStateException("No record found for selection of Trigger with key: '" + triggerKey + "' and statement: " + Util.rtp(SELECT_CRON_TRIGGER, tablePrefix, schedNameLiteral)); } finally { Util.closeResultSet(rs); Util.closeStatement(ps); } }
/** * Get a {@link ScheduleBuilder} that is configured to produce a * schedule identical to this trigger's schedule. * * @see #getTriggerBuilder() */ @Override public ScheduleBuilder<CronTrigger> getScheduleBuilder() { CronScheduleBuilder cb = CronScheduleBuilder.cronSchedule(getCronExpression()) .inTimeZone(getTimeZone()); switch(getMisfireInstruction()) { case MISFIRE_INSTRUCTION_DO_NOTHING : cb.withMisfireHandlingInstructionDoNothing(); break; case MISFIRE_INSTRUCTION_FIRE_ONCE_NOW : cb.withMisfireHandlingInstructionFireAndProceed(); break; } return cb; }
/** * Get a {@link ScheduleBuilder} that is configured to produce a * schedule identical to this trigger's schedule. * * @see #getTriggerBuilder() */ @Override public ScheduleBuilder<CronTrigger> getScheduleBuilder() { CronScheduleBuilder cb = CronScheduleBuilder.cronSchedule(getCronExpression()) .inTimeZone(getTimeZone()); switch(getMisfireInstruction()) { case MISFIRE_INSTRUCTION_DO_NOTHING : cb.withMisfireHandlingInstructionDoNothing(); break; case MISFIRE_INSTRUCTION_FIRE_ONCE_NOW : cb.withMisfireHandlingInstructionFireAndProceed(); break; } return cb; }
Trigger getTrigger() { return (trigger == null) ? newTrigger() .withIdentity(getTriggerKey()) .withSchedule(cronSchedule(cronExpression) .inTimeZone(timeZone)) .withPriority(priority) .build() : trigger; }
@Override public ScheduleBuilder<?> buildSchedule(Schedule schedule) { CronScheduleBuilder builder = CronScheduleBuilder.cronSchedule(schedule.getCronExpression()); if (schedule.getTimeZone() != null) { builder.inTimeZone(TimeZone.getTimeZone(schedule.getTimeZone())); } return builder; }
private Trigger genTriggerInstance(TriggerKey tk, JobDetail jd, AbstractJob job, ProcessType type) { TriggerBuilder builder = newTrigger().withIdentity(tk).forJob(jd); if (type == BATCH) { TimeZone timeZone = getTimeZone(job.getTimeZone()); return builder.withSchedule(cronSchedule(job.getCronExpression()) .inTimeZone(timeZone)).build(); } else if (type == STREAMING) { return builder.startNow().withSchedule(simpleSchedule() .withRepeatCount(0)).build(); } throw new GriffinException.BadRequestException (JOB_TYPE_DOES_NOT_SUPPORT); }
public Trigger buildTrigger(Scheduled ann) { TriggerBuilder<Trigger> trigger = newTrigger(); if (ann.cron() != null && ann.cron().trim().length() > 0) { trigger.withSchedule(CronScheduleBuilder.cronSchedule(ann.cron()).inTimeZone(config.getTimezone())); } else if (ann.interval() != -1) { trigger.withSchedule(simpleSchedule() .withIntervalInMilliseconds( TimeUnit.MILLISECONDS.convert(ann.interval(), ann.unit())) .repeatForever()) .startAt(new Date(System.currentTimeMillis() + ann.delayInMillis())); } else { throw new IllegalArgumentException("One of 'cron', 'interval' is required for the @Scheduled annotation"); } return trigger.build(); }
/** * Method factory for creating a cron trigger * * @return jobDetail * @throws java.text.ParseException */ protected Trigger getBusinessTrigger(TriggerBuilder triggerBuilder) throws ParseException { CronScheduleBuilder cronScheduleBuilder = cronSchedule(this.consumerConfiguration.getCronExpression()); if (this.consumerConfiguration.isIgnoreMisfire()) { cronScheduleBuilder.withMisfireHandlingInstructionDoNothing(); } if (this.consumerConfiguration.getTimezone() != null && this.consumerConfiguration.getTimezone().length() > 0) { cronScheduleBuilder.inTimeZone(TimeZone.getTimeZone(this.consumerConfiguration.getTimezone())); } // start the business schedule 1 second in the future to ensure we // do not immediately callback on submission to quartz triggerBuilder.withSchedule(cronScheduleBuilder) .startAt(new Date(System.currentTimeMillis() + 1000)); return triggerBuilder.build(); }
.withIdentity(triggerKey) .withSchedule(cronSchedule(cronExpression) .inTimeZone(timeZone)) .withPriority(priority) .build()
scheduleBuilder.inTimeZone(timeZone);
.withSchedule(cronSchedule(cron) .withMisfireHandlingInstructionFireAndProceed() .inTimeZone(TimeZone.getTimeZone(systemDefault()))) .usingJobData("cron", cron) .build();
.withIdentity(triggerKey) .withSchedule(cronSchedule(cronExpression) .inTimeZone(timeZone)) .withPriority(priority) .build()
boolean storeDurably = onAnnotation.storeDurably(); CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(cron).inTimeZone(timeZone); if (misfirePolicy == On.MisfirePolicy.IGNORE_MISFIRES) scheduleBuilder.withMisfireHandlingInstructionIgnoreMisfires();
@Override public void start() throws MuleException { try { if (quartzScheduler.isStarted()) { if (quartzScheduler.getTrigger(TriggerKey.triggerKey(getName(), groupName)) == null) { CronTrigger cronTrigger = newTrigger() .withIdentity(getName(), groupName) .forJob(jobName, groupName) .withSchedule(cronSchedule(cronExpression).inTimeZone(timeZone)) .build(); quartzScheduler.scheduleJob(cronTrigger); } else { quartzScheduler.resumeAll(); } } } catch (SchedulerException e) { throw new DefaultMuleException(couldNotScheduleJob(), e); } }
/** * Persist the trigger in the Quartz scheduler. */ private VmSchedule persistTrigger(final VmSchedule schedule) throws SchedulerException { // The trigger for the common VM Job will the following convention : // schedule.id-subscription.id final String id = VmJob.format(schedule); final JobDetailImpl object = (JobDetailImpl) vmJobDetailFactoryBean.getObject(); object.getJobDataMap().put("vmServicePlugin", this); final Trigger trigger = TriggerBuilder.newTrigger().withIdentity(id, SCHEDULE_TRIGGER_GROUP) .withSchedule(CronScheduleBuilder.cronSchedule(schedule.getCron()) .inTimeZone(DateUtils.getApplicationTimeZone())) .forJob(object).usingJobData("subscription", schedule.getSubscription().getId()) .usingJobData("operation", schedule.getOperation().name()).usingJobData("schedule", schedule.getId()) .build(); // Add this trigger vmSchedulerFactoryBean.getObject().scheduleJob(trigger); return schedule; }
.withSchedule(CronScheduleBuilder.cronSchedule(getCron()).inTimeZone(getTimeZone())) .build(); .withSchedule(CronScheduleBuilder.cronSchedule(getCron()).inTimeZone(getTimeZone())) .build();
triggerBuilder.withSchedule(SimpleScheduleBuilder.repeatSecondlyForever(trigger.getRetryInterval().intValue())); } else { triggerBuilder.withSchedule(CronScheduleBuilder.cronSchedule(trigger.getCronScheduling()).inTimeZone(TimeZone.getTimeZone("UTC")));