use of org.quartz.TriggerBuilder.newTrigger in project kylo by Teradata.
the class QuartzScheduler method scheduleWithCronExpressionInTimeZone.
public void scheduleWithCronExpressionInTimeZone(JobIdentifier jobIdentifier, Object task, String runMethod, String cronExpression, TimeZone timeZone) throws JobSchedulerException {
try {
JobDetail jobDetail = getJobDetail(jobIdentifier, task, runMethod);
if (timeZone == null) {
timeZone = TimeZone.getDefault();
}
Trigger trigger = TriggerBuilder.newTrigger().withIdentity(new TriggerKey("trigger_" + jobIdentifier.getUniqueName(), jobIdentifier.getGroup())).forJob(jobDetail).withSchedule(CronScheduleBuilder.cronSchedule(cronExpression).inTimeZone(timeZone).withMisfireHandlingInstructionFireAndProceed()).build();
scheduleJob(jobDetail, trigger);
} catch (Exception e) {
throw new JobSchedulerException();
}
}
use of org.quartz.TriggerBuilder.newTrigger in project kylo by Teradata.
the class QuartzScheduler method scheduleAtFixedRateWithDelay.
public void scheduleAtFixedRateWithDelay(JobIdentifier jobIdentifier, Object task, String runMethod, Date startTime, long period, long startDelay) throws JobSchedulerException {
JobDetail jobDetail = null;
try {
jobDetail = getJobDetail(jobIdentifier, task, runMethod);
Date triggerStartTime = startTime;
if (startDelay > 0L || startTime == null) {
triggerStartTime = new Date(System.currentTimeMillis() + startDelay);
}
Trigger trigger = TriggerBuilder.newTrigger().withIdentity(new TriggerKey(jobIdentifier.getName(), jobIdentifier.getGroup())).forJob(jobDetail).startAt(triggerStartTime).withSchedule(SimpleScheduleBuilder.simpleSchedule().withIntervalInMilliseconds(period).repeatForever()).build();
getScheduler().scheduleJob(jobDetail, trigger);
triggerListeners(JobSchedulerEvent.scheduledJobEvent(jobIdentifier));
} catch (NoSuchMethodException | ClassNotFoundException | SchedulerException e) {
throw new JobSchedulerException("Error calling scheduleAtFixedRateWithDelay", e);
}
}
Aggregations