Search in sources :

Example 81 with CronTrigger

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);
}
Also used : JobDetail(org.quartz.JobDetail) CronTrigger(org.quartz.CronTrigger)

Example 82 with CronTrigger

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);
}
Also used : CronTrigger(org.quartz.CronTrigger)

Example 83 with CronTrigger

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));
}
Also used : OperableTrigger(org.quartz.spi.OperableTrigger) TimeZone(java.util.TimeZone) CronTrigger(org.quartz.CronTrigger) Date(java.util.Date) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 84 with CronTrigger

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");
}
Also used : OperableTrigger(org.quartz.spi.OperableTrigger) JobDetail(org.quartz.JobDetail) CronTrigger(org.quartz.CronTrigger) QuartzJobDetails(org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzJobDetails) Date(java.util.Date) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 85 with CronTrigger

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));
}
Also used : OperableTrigger(org.quartz.spi.OperableTrigger) TimeZone(java.util.TimeZone) CronTrigger(org.quartz.CronTrigger) QuartzTriggerGroupSummary(org.springframework.boot.actuate.quartz.QuartzEndpoint.QuartzTriggerGroupSummary) Date(java.util.Date) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

CronTrigger (org.quartz.CronTrigger)103 JobDetail (org.quartz.JobDetail)42 Trigger (org.quartz.Trigger)36 SimpleTrigger (org.quartz.SimpleTrigger)29 SchedulerException (org.quartz.SchedulerException)28 Test (org.junit.Test)24 Scheduler (org.quartz.Scheduler)19 TriggerKey (org.quartz.TriggerKey)19 Date (java.util.Date)14 JobKey (org.quartz.JobKey)12 JobDataMap (org.quartz.JobDataMap)11 Test (org.junit.jupiter.api.Test)9 ArrayList (java.util.ArrayList)8 CronScheduleBuilder (org.quartz.CronScheduleBuilder)8 ParseException (java.text.ParseException)7 HashMap (java.util.HashMap)7 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 JobExecutionException (org.quartz.JobExecutionException)6 ComplexJobTrigger (org.pentaho.platform.api.scheduler2.ComplexJobTrigger)5 SimpleJobTrigger (org.pentaho.platform.api.scheduler2.SimpleJobTrigger)5