本文整理汇总了Java中org.quartz.impl.triggers.CronTriggerImpl类的典型用法代码示例。如果您正苦于以下问题:Java CronTriggerImpl类的具体用法?Java CronTriggerImpl怎么用?Java CronTriggerImpl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CronTriggerImpl类属于org.quartz.impl.triggers包,在下文中一共展示了CronTriggerImpl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initScanReminderJob
import org.quartz.impl.triggers.CronTriggerImpl; //导入依赖的package包/类
private void initScanReminderJob(){
CronTriggerImpl trigger=new CronTriggerImpl();
trigger.setName("UfloScanReminderTrigger");
trigger.setKey(new TriggerKey("UfloScanReminderTrigger"));
try {
trigger.setCronExpression(SCAN_REMINDER_CRON);
ScanReminderJob job=new ScanReminderJob();
ScanReminderJobDetail detail=new ScanReminderJobDetail();
detail.setSchedulerService(this);
detail.setTaskService(taskService);
detail.setReminderTaskList(reminderTaskList);
detail.setJobClass(job.getClass());
detail.setKey(new JobKey("UfloScanReminderJob"));
scheduler.scheduleJob(detail, trigger);
} catch (Exception e1) {
throw new RuntimeException(e1);
}
}
示例2: setValue
import org.quartz.impl.triggers.CronTriggerImpl; //导入依赖的package包/类
@Override
@SuppressWarnings({"unchecked"})
public void setValue(Object value) {
List<Object> nativeQuartzTriggers = new ArrayList<Object>();
if (value != null && value instanceof Collection) {
Collection<Trigger> triggers = (Collection<Trigger>) value;
List<QuartzCronJob> quartzCronJobs = new ArrayList<QuartzCronJob>(triggers.size());
for (Trigger trigger : triggers) {
if (trigger instanceof CronTriggerImpl) {
quartzCronJobs.add(buildQuartzCronJob((CronTriggerImpl) trigger));
} else {
LOGGER.warn("Can't Proxy " + trigger.getClass().getName() + " Then Use Quartz Scheduler");
nativeQuartzTriggers.add(trigger);
}
}
context.getAgent().startProxy(quartzCronJobs);
}
super.setValue(nativeQuartzTriggers);
}
示例3: scheduleDayOfWeekJob
import org.quartz.impl.triggers.CronTriggerImpl; //导入依赖的package包/类
private void scheduleDayOfWeekJob(DayOfWeekSchedulableJob job, boolean update) {
logObjectIfNotNull(job);
validateDayOfWeekSchedulableJob(job);
MotechEvent motechEvent = job.getMotechEvent();
Time time = job.getTime();
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.atHourAndMinuteOnGivenDaysOfWeek(time.getHour(),
time.getMinute(), job.getCronDays()
.toArray(new Integer[job.getCronDays().size()]));
CronTriggerImpl cronTrigger = (CronTriggerImpl) cronScheduleBuilder.build();
CronSchedulableJob cronSchedulableJob = new CronSchedulableJob(motechEvent, cronTrigger.getCronExpression(),
job.getStartDate(), job.getEndDate(), job.isIgnorePastFiresAtStart(), job.isUiDefined());
scheduleCronJob(cronSchedulableJob, true, update);
}
示例4: storeTrigger
import org.quartz.impl.triggers.CronTriggerImpl; //导入依赖的package包/类
@Test
public void storeTrigger() throws Exception {
CronTriggerImpl trigger = getCronTrigger();
trigger.getJobDataMap().put("foo", "bar");
jobStore.storeTrigger(trigger, false);
final String triggerHashKey = schema.triggerHashKey(trigger.getKey());
Map<String, String> triggerMap = jedis.hgetAll(triggerHashKey);
assertThat(triggerMap, hasKey("description"));
assertEquals(trigger.getDescription(), triggerMap.get("description"));
assertThat(triggerMap, hasKey("trigger_class"));
assertEquals(trigger.getClass().getName(), triggerMap.get("trigger_class"));
assertTrue("The trigger hash key is not a member of the triggers set.", jedis.sismember(schema.triggersSet(), triggerHashKey));
assertTrue("The trigger group set key is not a member of the trigger group set.", jedis.sismember(schema.triggerGroupsSet(), schema.triggerGroupSetKey(trigger.getKey())));
assertTrue(jedis.sismember(schema.triggerGroupSetKey(trigger.getKey()), triggerHashKey));
assertTrue(jedis.sismember(schema.jobTriggersSetKey(trigger.getJobKey()), triggerHashKey));
String triggerDataMapHashKey = schema.triggerDataMapHashKey(trigger.getKey());
MatcherAssert.assertThat(jedis.exists(triggerDataMapHashKey), equalTo(true));
MatcherAssert.assertThat(jedis.hget(triggerDataMapHashKey, "foo"), equalTo("bar"));
}
示例5: removeTrigger
import org.quartz.impl.triggers.CronTriggerImpl; //导入依赖的package包/类
@Test
public void removeTrigger() throws Exception {
JobDetail job = getJobDetail();
CronTriggerImpl trigger1 = getCronTrigger("trigger1", "triggerGroup", job.getKey());
trigger1.getJobDataMap().put("foo", "bar");
CronTriggerImpl trigger2 = getCronTrigger("trigger2", "triggerGroup", job.getKey());
jobStore.storeJob(job, false);
jobStore.storeTrigger(trigger1, false);
jobStore.storeTrigger(trigger2, false);
jobStore.removeTrigger(trigger1.getKey());
// ensure that the trigger was removed, but the job was not
assertThat(jobStore.retrieveTrigger(trigger1.getKey()), nullValue());
assertThat(jobStore.retrieveJob(job.getKey()), not(nullValue()));
// remove the second trigger
jobStore.removeTrigger(trigger2.getKey());
// ensure that both the trigger and job were removed
assertThat(jobStore.retrieveTrigger(trigger2.getKey()), nullValue());
assertThat(jobStore.retrieveJob(job.getKey()), nullValue());
MatcherAssert.assertThat(jedis.exists(schema.triggerDataMapHashKey(trigger1.getKey())), equalTo(false));
}
示例6: getTriggerState
import org.quartz.impl.triggers.CronTriggerImpl; //导入依赖的package包/类
@Test
public void getTriggerState() throws Exception {
SchedulerSignaler signaler = mock(SchedulerSignaler.class);
AbstractRedisStorage storageDriver = new RedisStorage(new RedisJobStoreSchema(), new ObjectMapper(), signaler, "scheduler1", 2000);
// attempt to retrieve the state of a non-existent trigger
Trigger.TriggerState state = jobStore.getTriggerState(new TriggerKey("foobar"));
assertEquals(Trigger.TriggerState.NONE, state);
// store a trigger
JobDetail job = getJobDetail();
CronTriggerImpl cronTrigger = getCronTrigger("trigger1", "group1", job.getKey());
jobStore.storeTrigger(cronTrigger, false);
// the newly-stored trigger's state should be NONE
state = jobStore.getTriggerState(cronTrigger.getKey());
assertEquals(Trigger.TriggerState.NORMAL, state);
// set the trigger's state
storageDriver.setTriggerState(RedisTriggerState.WAITING, 500, schema.triggerHashKey(cronTrigger.getKey()), jedis);
// the trigger's state should now be NORMAL
state = jobStore.getTriggerState(cronTrigger.getKey());
assertEquals(Trigger.TriggerState.NORMAL, state);
}
示例7: pauseTriggersStartsWith
import org.quartz.impl.triggers.CronTriggerImpl; //导入依赖的package包/类
@Test
public void pauseTriggersStartsWith() throws Exception {
JobDetail job = getJobDetail();
CronTriggerImpl trigger1 = getCronTrigger("trigger1", "group1", job.getKey());
CronTriggerImpl trigger2 = getCronTrigger("trigger1", "group2", job.getKey());
CronTriggerImpl trigger3 = getCronTrigger("trigger1", "foogroup1", job.getKey());
storeJobAndTriggers(job, trigger1, trigger2, trigger3);
Collection<String> pausedTriggerGroups = jobStore.pauseTriggers(GroupMatcher.triggerGroupStartsWith("group"));
assertThat(pausedTriggerGroups, hasSize(2));
assertThat(pausedTriggerGroups, containsInAnyOrder("group1", "group2"));
assertEquals(Trigger.TriggerState.PAUSED, jobStore.getTriggerState(trigger1.getKey()));
assertEquals(Trigger.TriggerState.PAUSED, jobStore.getTriggerState(trigger2.getKey()));
assertEquals(Trigger.TriggerState.NORMAL, jobStore.getTriggerState(trigger3.getKey()));
}
示例8: pauseTriggersEndsWith
import org.quartz.impl.triggers.CronTriggerImpl; //导入依赖的package包/类
@Test
public void pauseTriggersEndsWith() throws Exception {
JobDetail job = getJobDetail();
CronTriggerImpl trigger1 = getCronTrigger("trigger1", "group1", job.getKey());
CronTriggerImpl trigger2 = getCronTrigger("trigger1", "group2", job.getKey());
CronTriggerImpl trigger3 = getCronTrigger("trigger1", "foogroup1", job.getKey());
storeJobAndTriggers(job, trigger1, trigger2, trigger3);
Collection<String> pausedGroups = jobStore.pauseTriggers(GroupMatcher.triggerGroupEndsWith("oup1"));
assertThat(pausedGroups, hasSize(2));
assertThat(pausedGroups, containsInAnyOrder("group1", "foogroup1"));
assertEquals(Trigger.TriggerState.PAUSED, jobStore.getTriggerState(trigger1.getKey()));
assertEquals(Trigger.TriggerState.NORMAL, jobStore.getTriggerState(trigger2.getKey()));
assertEquals(Trigger.TriggerState.PAUSED, jobStore.getTriggerState(trigger3.getKey()));
}
示例9: resumeTrigger
import org.quartz.impl.triggers.CronTriggerImpl; //导入依赖的package包/类
@Test
public void resumeTrigger() throws Exception {
// create and store a job and trigger
JobDetail job = getJobDetail();
jobStore.storeJob(job, false);
CronTriggerImpl trigger = getCronTrigger("trigger1", "group1", job.getKey());
trigger.computeFirstFireTime(new WeeklyCalendar());
jobStore.storeTrigger(trigger, false);
// pause the trigger
jobStore.pauseTrigger(trigger.getKey());
assertEquals(Trigger.TriggerState.PAUSED, jobStore.getTriggerState(trigger.getKey()));
// resume the trigger
jobStore.resumeTrigger(trigger.getKey());
// the trigger state should now be NORMAL
assertEquals(Trigger.TriggerState.NORMAL, jobStore.getTriggerState(trigger.getKey()));
// attempt to resume the trigger, again
jobStore.resumeTrigger(trigger.getKey());
// the trigger state should not have changed
assertEquals(Trigger.TriggerState.NORMAL, jobStore.getTriggerState(trigger.getKey()));
}
示例10: resumeTriggersStartsWith
import org.quartz.impl.triggers.CronTriggerImpl; //导入依赖的package包/类
@Test
public void resumeTriggersStartsWith() throws Exception {
JobDetail job = getJobDetail();
CronTriggerImpl trigger1 = getCronTrigger("trigger1", "mygroup1", job.getKey());
CronTriggerImpl trigger2 = getCronTrigger("trigger2", "group1", job.getKey());
CronTriggerImpl trigger3 = getCronTrigger("trigger3", "group2", job.getKey());
CronTriggerImpl trigger4 = getCronTrigger("trigger4", "group3", job.getKey());
storeJobAndTriggers(job, trigger1, trigger2, trigger3, trigger4);
Collection<String> pausedGroups = jobStore.pauseTriggers(GroupMatcher.triggerGroupStartsWith("my"));
assertThat(pausedGroups, hasSize(1));
assertThat(pausedGroups, containsInAnyOrder("mygroup1"));
// ensure that the triggers were actually paused
assertEquals(Trigger.TriggerState.PAUSED, jobStore.getTriggerState(trigger1.getKey()));
// resume triggers
Collection<String> resumedGroups = jobStore.resumeTriggers(GroupMatcher.triggerGroupStartsWith("my"));
assertThat(resumedGroups, hasSize(1));
assertThat(resumedGroups, containsInAnyOrder("mygroup1"));
// ensure that the triggers were actually resumed
assertEquals(Trigger.TriggerState.NORMAL, jobStore.getTriggerState(trigger1.getKey()));
}
示例11: replaceTriggerSingleTriggerNonDurableJob
import org.quartz.impl.triggers.CronTriggerImpl; //导入依赖的package包/类
@Test
public void replaceTriggerSingleTriggerNonDurableJob() throws Exception {
// store trigger and job
JobDetail job = getJobDetail();
CronTriggerImpl trigger1 = getCronTrigger("trigger1", "group1", job.getKey());
storeJobAndTriggers(job, trigger1);
CronTriggerImpl newTrigger = getCronTrigger("newTrigger", "group1", job.getKey());
assertTrue(jobStore.replaceTrigger(trigger1.getKey(), newTrigger));
// ensure that the proper trigger was replaced
assertThat(jobStore.retrieveTrigger(trigger1.getKey()), nullValue());
List<OperableTrigger> jobTriggers = jobStore.getTriggersForJob(job.getKey());
assertThat(jobTriggers, hasSize(1));
// ensure that the job still exists
assertThat(jobStore.retrieveJob(job.getKey()), not(nullValue()));
}
示例12: removeJob
import org.quartz.impl.triggers.CronTriggerImpl; //导入依赖的package包/类
@Test
public void removeJob() throws Exception {
// attempt to remove a non-existent job
assertFalse(jobStore.removeJob(JobKey.jobKey("foo", "bar")));
// create and store a job with multiple triggers
JobDetail job = getJobDetail("job1", "jobGroup1");
CronTriggerImpl trigger1 = getCronTrigger("trigger1", "triggerGroup1", job.getKey());
CronTriggerImpl trigger2 = getCronTrigger("trigger2", "triggerGroup1", job.getKey());
Set<Trigger> triggersSet = new HashSet<>();
triggersSet.add(trigger1);
triggersSet.add(trigger2);
Map<JobDetail, Set<? extends Trigger>> jobsAndTriggers = new HashMap<>();
jobsAndTriggers.put(job, triggersSet);
jobStore.storeJobsAndTriggers(jobsAndTriggers, false);
assertTrue(jobStore.removeJob(job.getKey()));
// ensure that the job and all of its triggers were removed
assertThat(jobStore.retrieveJob(job.getKey()), nullValue());
assertThat(jobStore.retrieveTrigger(trigger1.getKey()), nullValue());
assertThat(jobStore.retrieveTrigger(trigger2.getKey()), nullValue());
assertThat(jedis.get(schema.triggerHashKey(trigger1.getKey())), nullValue());
}
示例13: pauseJob
import org.quartz.impl.triggers.CronTriggerImpl; //导入依赖的package包/类
@Test
public void pauseJob() throws Exception {
// create and store a job with multiple triggers
JobDetail job = getJobDetail("job1", "jobGroup1");
CronTriggerImpl trigger1 = getCronTrigger("trigger1", "triggerGroup1", job.getKey());
CronTriggerImpl trigger2 = getCronTrigger("trigger2", "triggerGroup1", job.getKey());
Set<Trigger> triggersSet = new HashSet<>();
triggersSet.add(trigger1);
triggersSet.add(trigger2);
Map<JobDetail, Set<? extends Trigger>> jobsAndTriggers = new HashMap<>();
jobsAndTriggers.put(job, triggersSet);
jobStore.storeJobsAndTriggers(jobsAndTriggers, false);
// pause the job
jobStore.pauseJob(job.getKey());
// ensure that the job's triggers were paused
assertEquals(Trigger.TriggerState.PAUSED, jobStore.getTriggerState(trigger1.getKey()));
assertEquals(Trigger.TriggerState.PAUSED, jobStore.getTriggerState(trigger2.getKey()));
}
示例14: pauseJobsStartsWith
import org.quartz.impl.triggers.CronTriggerImpl; //导入依赖的package包/类
@Test
public void pauseJobsStartsWith() throws Exception {
JobDetail job1 = getJobDetail("job1", "jobGroup1");
storeJobAndTriggers(job1, getCronTrigger("trigger1", "triggerGroup1", job1.getKey()), getCronTrigger("trigger2", "triggerGroup1", job1.getKey()));
JobDetail job2 = getJobDetail("job2", "yobGroup1");
CronTriggerImpl trigger3 = getCronTrigger("trigger3", "triggerGroup3", job2.getKey());
CronTriggerImpl trigger4 = getCronTrigger("trigger4", "triggerGroup4", job2.getKey());
storeJobAndTriggers(job2, trigger3, trigger4);
// pause jobs with groups beginning with "yob"
Collection<String> pausedJobs = jobStore.pauseJobs(GroupMatcher.jobGroupStartsWith("yob"));
assertThat(pausedJobs, hasSize(1));
assertThat(pausedJobs, containsInAnyOrder("yobGroup1"));
// ensure that the job was added to the paused jobs set
assertTrue(jedis.sismember(schema.pausedJobGroupsSet(), schema.jobGroupSetKey(job2.getKey())));
// ensure that the job's triggers have been paused
assertEquals(Trigger.TriggerState.PAUSED, jobStore.getTriggerState(trigger3.getKey()));
assertEquals(Trigger.TriggerState.PAUSED, jobStore.getTriggerState(trigger4.getKey()));
}
示例15: pauseJobsEndsWith
import org.quartz.impl.triggers.CronTriggerImpl; //导入依赖的package包/类
@Test
public void pauseJobsEndsWith() throws Exception {
JobDetail job1 = getJobDetail("job1", "jobGroup1");
CronTriggerImpl trigger1 = getCronTrigger("trigger1", "triggerGroup1", job1.getKey());
CronTriggerImpl trigger2 = getCronTrigger("trigger2", "triggerGroup1", job1.getKey());
storeJobAndTriggers(job1, trigger1, trigger2);
JobDetail job2 = getJobDetail("job2", "yobGroup2");
CronTriggerImpl trigger3 = getCronTrigger("trigger3", "triggerGroup3", job2.getKey());
CronTriggerImpl trigger4 = getCronTrigger("trigger4", "triggerGroup4", job2.getKey());
storeJobAndTriggers(job2, trigger3, trigger4);
// pause job groups ending with "1"
Collection<String> pausedJobs = jobStore.pauseJobs(GroupMatcher.jobGroupEndsWith("1"));
assertThat(pausedJobs, hasSize(1));
assertThat(pausedJobs, containsInAnyOrder("jobGroup1"));
// ensure that the job was added to the paused jobs set
assertTrue(jedis.sismember(schema.pausedJobGroupsSet(), schema.jobGroupSetKey(job1.getKey())));
// ensure that the job's triggers have been paused
assertEquals(Trigger.TriggerState.PAUSED, jobStore.getTriggerState(trigger1.getKey()));
assertEquals(Trigger.TriggerState.PAUSED, jobStore.getTriggerState(trigger2.getKey()));
}