use of org.quartz.CronTrigger in project kylo by Teradata.
the class QuartzScheduler method scheduleJob.
public void scheduleJob(MethodInvokingJobDetailFactoryBean methodInvokingJobDetailFactoryBean, CronTriggerFactoryBean cronTriggerFactoryBean) throws SchedulerException {
JobDetail job = methodInvokingJobDetailFactoryBean.getObject();
CronTrigger trigger = cronTriggerFactoryBean.getObject();
scheduleJob(job, trigger);
}
use of org.quartz.CronTrigger in project kylo by Teradata.
the class QuartzScheduler method scheduleJob.
public void scheduleJob(JobDetail job, CronTriggerFactoryBean cronTriggerFactoryBean) throws SchedulerException {
CronTrigger trigger = cronTriggerFactoryBean.getObject();
scheduleJob(job, trigger);
}
use of org.quartz.CronTrigger in project spring-boot by spring-projects.
the class QuartzEndpointTests method quartzTriggerWithCronTrigger.
@Test
void quartzTriggerWithCronTrigger() throws SchedulerException {
Date previousFireTime = Date.from(Instant.parse("2020-11-30T03:00:00Z"));
Date nextFireTime = Date.from(Instant.parse("2020-12-01T03:00:00Z"));
TimeZone timeZone = TimeZone.getTimeZone("Europe/Paris");
CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity("3am-every-day", "samples").withPriority(3).withDescription("Sample description").withSchedule(CronScheduleBuilder.dailyAtHourAndMinute(3, 0).inTimeZone(timeZone)).build();
((OperableTrigger) trigger).setPreviousFireTime(previousFireTime);
((OperableTrigger) trigger).setNextFireTime(nextFireTime);
mockTriggers(trigger);
given(this.scheduler.getTriggerState(TriggerKey.triggerKey("3am-every-day", "samples"))).willReturn(TriggerState.NORMAL);
Map<String, Object> triggerDetails = this.endpoint.quartzTrigger("samples", "3am-every-day");
assertThat(triggerDetails).contains(entry("group", "samples"), entry("name", "3am-every-day"), entry("description", "Sample description"), entry("type", "cron"), entry("state", TriggerState.NORMAL), entry("priority", 3));
assertThat(triggerDetails).contains(entry("previousFireTime", previousFireTime), entry("nextFireTime", nextFireTime));
assertThat(triggerDetails).doesNotContainKeys("simple", "dailyTimeInterval", "calendarInterval", "custom");
assertThat(triggerDetails).extractingByKey("cron", nestedMap()).containsOnly(entry("expression", "0 0 3 ? * *"), entry("timeZone", timeZone));
}
use of org.quartz.CronTrigger in project spring-boot by spring-projects.
the class QuartzEndpointTests method quartzJobOrdersTriggersAccordingToNextFireTime.
@Test
void quartzJobOrdersTriggersAccordingToNextFireTime() throws SchedulerException {
JobDetail job = JobBuilder.newJob(Job.class).withIdentity("hello", "samples").build();
mockJobs(job);
Date triggerOneNextFireTime = Date.from(Instant.parse("2020-12-01T03:00:00Z"));
CronTrigger triggerOne = TriggerBuilder.newTrigger().withIdentity("one", "samples").withPriority(5).withSchedule(CronScheduleBuilder.dailyAtHourAndMinute(3, 0)).build();
((OperableTrigger) triggerOne).setNextFireTime(triggerOneNextFireTime);
Date triggerTwoNextFireTime = Date.from(Instant.parse("2020-12-01T02:00:00Z"));
CronTrigger triggerTwo = TriggerBuilder.newTrigger().withIdentity("two", "samples").withPriority(10).withSchedule(CronScheduleBuilder.dailyAtHourAndMinute(2, 0)).build();
((OperableTrigger) triggerTwo).setNextFireTime(triggerTwoNextFireTime);
mockTriggers(triggerOne, triggerTwo);
given(this.scheduler.getTriggersOfJob(JobKey.jobKey("hello", "samples"))).willAnswer((invocation) -> Arrays.asList(triggerOne, triggerTwo));
QuartzJobDetails jobDetails = this.endpoint.quartzJob("samples", "hello");
assertThat(jobDetails.getTriggers()).hasSize(2);
assertThat(jobDetails.getTriggers().get(0)).containsEntry("name", "two");
assertThat(jobDetails.getTriggers().get(1)).containsEntry("name", "one");
}
use of org.quartz.CronTrigger in project spring-boot by spring-projects.
the class QuartzEndpointTests method quartzTriggerGroupSummaryWithCronTriggerDetails.
@Test
void quartzTriggerGroupSummaryWithCronTriggerDetails() throws SchedulerException {
Date previousFireTime = Date.from(Instant.parse("2020-11-30T03:00:00Z"));
Date nextFireTime = Date.from(Instant.parse("2020-12-01T03:00:00Z"));
TimeZone timeZone = TimeZone.getTimeZone("Europe/Paris");
CronTrigger cronTrigger = TriggerBuilder.newTrigger().withIdentity("3am-every-day", "samples").withPriority(3).withSchedule(CronScheduleBuilder.dailyAtHourAndMinute(3, 0).inTimeZone(timeZone)).build();
((OperableTrigger) cronTrigger).setPreviousFireTime(previousFireTime);
((OperableTrigger) cronTrigger).setNextFireTime(nextFireTime);
mockTriggers(cronTrigger);
QuartzTriggerGroupSummary summary = this.endpoint.quartzTriggerGroupSummary("samples");
Map<String, Object> triggers = summary.getTriggers().getCron();
assertThat(triggers).containsOnlyKeys("3am-every-day");
assertThat(triggers).extractingByKey("3am-every-day", nestedMap()).containsOnly(entry("previousFireTime", previousFireTime), entry("nextFireTime", nextFireTime), entry("priority", 3), entry("expression", "0 0 3 ? * *"), entry("timeZone", timeZone));
}
Aggregations