org.quartz.impl.triggers.SimpleTriggerImpl Java Examples
The following examples show how to use
org.quartz.impl.triggers.SimpleTriggerImpl.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TaskManager.java From GOAi with GNU Affero General Public License v3.0 | 6 votes |
/** * 添加任务 */ private ScheduleJob checkJob(ScheduledMethod mt, int number) { Method method = mt.getMethod(); Trigger trigger = mt.getScheduledInfo().getTrigger(); String description = this.id + "-" + method.getName() + "-" + number; this.log.info("{} {}", description, mt.getScheduledInfo().getTip()); JobDetail jobDetail = JobBuilder.newJob(ScheduledJob.class) .withDescription(description) .withIdentity(this.taskClass.getSimpleName(), description) .build(); if (trigger instanceof CronTriggerImpl) { ((CronTriggerImpl) trigger).setName(description); } if (trigger instanceof SimpleTriggerImpl) { ((SimpleTriggerImpl) trigger).setName(description); } return new ScheduleJob(jobDetail, trigger); }
Example #2
Source File: DefaultExceptionServiceImpl.java From rice with Educational Community License v2.0 | 6 votes |
public void scheduleExecution(Throwable throwable, PersistedMessageBO message, String description) throws Exception { KSBServiceLocator.getMessageQueueService().delete(message); PersistedMessageBO messageCopy = message.copy(); Scheduler scheduler = KSBServiceLocator.getScheduler(); JobDataMap jobData = new JobDataMap(); jobData.put(MessageServiceExecutorJob.MESSAGE_KEY, messageCopy); JobDetailImpl jobDetail = new JobDetailImpl("Exception_Message_Job " + Math.random(), "Exception Messaging", MessageServiceExecutorJob.class); jobDetail.setJobDataMap(jobData); if (!StringUtils.isBlank(description)) { jobDetail.setDescription(description); } scheduler.getListenerManager().addJobListener( new MessageServiceExecutorJobListener()); SimpleTriggerImpl trigger = new SimpleTriggerImpl("Exception_Message_Trigger " + Math.random(), "Exception Messaging", messageCopy .getQueueDate()); trigger.setJobDataMap(jobData);// 1.6 bug required or derby will choke scheduler.scheduleJob(jobDetail, trigger); }
Example #3
Source File: DelayedAsynchronousServiceCallProxy.java From rice with Educational Community License v2.0 | 6 votes |
protected void scheduleMessage(PersistedMessageBO message) throws SchedulerException { LOG.debug("Scheduling execution of a delayed asynchronous message."); Scheduler scheduler = KSBServiceLocator.getScheduler(); JobDataMap jobData = new JobDataMap(); jobData.put(MessageServiceExecutorJob.MESSAGE_KEY, message); JobDetailImpl jobDetail = new JobDetailImpl("Delayed_Asynchronous_Call-" + Math.random(), "Delayed_Asynchronous_Call", MessageServiceExecutorJob.class); jobDetail.setJobDataMap(jobData); scheduler.getListenerManager().addJobListener( new MessageServiceExecutorJobListener()); SimpleTriggerImpl trigger = new SimpleTriggerImpl("Delayed_Asynchronous_Call_Trigger-" + Math.random(), "Delayed_Asynchronous_Call", message.getQueueDate()); trigger.setJobDataMap(jobData);// 1.6 bug required or derby will choke scheduler.scheduleJob(jobDetail, trigger); }
Example #4
Source File: QuartzSchedulerBeanTargetEditor.java From light-task-scheduler with Apache License 2.0 | 6 votes |
@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<QuartzJobContext> quartzJobContexts = new ArrayList<QuartzJobContext>(triggers.size()); for (Trigger trigger : triggers) { if (trigger instanceof CronTriggerImpl) { quartzJobContexts.add(buildQuartzCronJob((CronTriggerImpl) trigger)); } else if (trigger instanceof SimpleTriggerImpl) { quartzJobContexts.add(buildQuartzSimpleJob((SimpleTriggerImpl) trigger)); } else { LOGGER.warn("Can't Proxy " + trigger.getClass().getName() + " Then Use Quartz Scheduler"); nativeQuartzTriggers.add(trigger); } } context.getAgent().startProxy(quartzJobContexts); } super.setValue(nativeQuartzTriggers); }
Example #5
Source File: SimpleTriggerMixinTest.java From quartz-redis-jobstore with Apache License 2.0 | 6 votes |
@Test public void serialization(){ SimpleTrigger trigger = TriggerBuilder.newTrigger() .forJob("testJob", "testGroup") .withIdentity("testTrigger", "testTriggerGroup") .usingJobData("timeout", 5) .withDescription("A description!") .withSchedule(SimpleScheduleBuilder.repeatHourlyForever()) .build(); Map<String, String> triggerMap = mapper.convertValue(trigger, new TypeReference<HashMap<String, String>>() {}); assertThat(triggerMap, hasKey("name")); assertEquals("testTrigger", triggerMap.get("name")); assertThat(triggerMap, hasKey("group")); assertEquals("testTriggerGroup", triggerMap.get("group")); assertThat(triggerMap, hasKey("jobName")); assertEquals("testJob", triggerMap.get("jobName")); SimpleTriggerImpl simpleTrigger = mapper.convertValue(triggerMap, SimpleTriggerImpl.class); assertEquals(trigger.getKey().getName(), simpleTrigger.getKey().getName()); assertEquals(trigger.getKey().getGroup(), simpleTrigger.getKey().getGroup()); assertEquals(trigger.getStartTime(), simpleTrigger.getStartTime()); assertEquals(trigger.getRepeatInterval(), simpleTrigger.getRepeatInterval()); }
Example #6
Source File: SchedulerController.java From quartz-manager with Apache License 2.0 | 6 votes |
@GetMapping("/progress") public TriggerStatus getProgressInfo() throws SchedulerException { log.trace("SCHEDULER - GET PROGRESS INFO"); TriggerStatus progress = new TriggerStatus(); SimpleTriggerImpl jobTrigger = (SimpleTriggerImpl) scheduler.getTrigger(triggerMonitor.getTrigger().getKey()); if (jobTrigger != null && jobTrigger.getJobKey() != null) { progress.setJobKey(jobTrigger.getJobKey().getName()); progress.setJobClass(jobTrigger.getClass().getSimpleName()); progress.setTimesTriggered(jobTrigger.getTimesTriggered()); progress.setRepeatCount(jobTrigger.getRepeatCount()); progress.setFinalFireTime(jobTrigger.getFinalFireTime()); progress.setNextFireTime(jobTrigger.getNextFireTime()); progress.setPreviousFireTime(jobTrigger.getPreviousFireTime()); } return progress; }
Example #7
Source File: MessagingServiceImpl.java From rice with Educational Community License v2.0 | 5 votes |
private void scheduleJob() { LOG.debug("Queueing processing job"); try { Scheduler scheduler = KSBServiceLocator.getScheduler(); if (synchronous) { LOG.debug("Invoking job synchronously in Thread " + Thread.currentThread()); MessageProcessingJob job = new MessageProcessingJob(messageId, mode, user, cause); job.run(); } else { String uniqueTriggerName = jobName + "-Trigger-" + System.currentTimeMillis() + Math.random(); SimpleTriggerImpl trigger = new SimpleTriggerImpl(uniqueTriggerName, jobGroup + "-Trigger"); LOG.debug("Scheduling trigger: " + trigger); JobDataMap data = new JobDataMap(); data.put("mode", mode.name()); data.put("user", user); data.put("cause", cause); data.put("messageId", messageId); trigger.setJobName(jobName); trigger.setJobGroup(jobGroup); trigger.setJobDataMap(data); scheduler.scheduleJob(trigger); } } catch (SchedulerException se) { throw new RuntimeException(se); } }
Example #8
Source File: ScheduledInfo.java From GOAi with GNU Affero General Public License v3.0 | 5 votes |
/** * 设置触发器 */ private void initSimpleTrigger() { if (this.fixedRate <= 0 || this.delay < 0) { return; } SimpleTriggerImpl simpleTrigger = new SimpleTriggerImpl(); simpleTrigger.setRepeatInterval(this.fixedRate); this.tip = "fixedRate: " + this.fixedRate + " ms delay: " + this.delay + " ms"; // 无限次 simpleTrigger.setRepeatCount(-1); simpleTrigger.setStartTime(new Date(System.currentTimeMillis() + this.delay)); this.trigger = simpleTrigger; this.cron = ""; }
Example #9
Source File: QuartzSchedulerBeanTargetEditor.java From light-task-scheduler with Apache License 2.0 | 5 votes |
private QuartzJobContext buildQuartzSimpleJob(SimpleTriggerImpl simpleTrigger) { QuartzJobContext quartzJobContext = new QuartzJobContext(); quartzJobContext.setTrigger(simpleTrigger); quartzJobContext.setName(simpleTrigger.getName()); quartzJobContext.setType(QuartzJobType.SIMPLE_REPEAT); buildQuartzJobContext(quartzJobContext, simpleTrigger); return quartzJobContext; }
Example #10
Source File: QuartzLTSProxyAgent.java From light-task-scheduler with Apache License 2.0 | 5 votes |
private Job buildSimpleJob(QuartzJobContext quartzJobContext) { SimpleTriggerImpl simpleTrigger = (SimpleTriggerImpl) quartzJobContext.getTrigger(); String description = simpleTrigger.getDescription(); int priority = simpleTrigger.getPriority(); String name = quartzJobContext.getName(); int repeatCount = simpleTrigger.getRepeatCount(); long repeatInterval = simpleTrigger.getRepeatInterval(); Job job = new Job(); job.setTaskId(name); job.setTriggerDate(simpleTrigger.getNextFireTime()); job.setRepeatCount(repeatCount); if (repeatCount != 0) { job.setRepeatInterval(repeatInterval); } job.setPriority(priority); job.setSubmitNodeGroup(quartzLTSConfig.getJobClientProperties().getNodeGroup()); job.setTaskTrackerNodeGroup(quartzLTSConfig.getTaskTrackerProperties().getNodeGroup()); job.setParam("description", description); setJobProp(job); return job; }
Example #11
Source File: RedisJobStore.java From redis-quartz with MIT License | 5 votes |
private OperableTrigger toOperableTrigger(TriggerKey triggerKey, Map<String, String> trigger) { if (TRIGGER_TYPE_SIMPLE.equals(trigger.get(TRIGGER_TYPE))) { SimpleTriggerImpl simpleTrigger = new SimpleTriggerImpl(); setOperableTriggerFields(triggerKey, trigger, simpleTrigger); if (trigger.get(REPEAT_COUNT) != null && !trigger.get(REPEAT_COUNT).isEmpty()) simpleTrigger.setRepeatCount(Integer.parseInt(trigger.get(REPEAT_COUNT))); if (trigger.get(REPEAT_INTERVAL) != null && !trigger.get(REPEAT_INTERVAL).isEmpty()) simpleTrigger.setRepeatInterval(Long.parseLong(trigger.get(REPEAT_INTERVAL))); if (trigger.get(TIMES_TRIGGERED) != null && !trigger.get(TIMES_TRIGGERED).isEmpty()) simpleTrigger.setTimesTriggered(Integer.parseInt(trigger.get(TIMES_TRIGGERED))); return simpleTrigger; } else if (TRIGGER_TYPE_CRON.equals(trigger.get(TRIGGER_TYPE))) { CronTriggerImpl cronTrigger = new CronTriggerImpl(); setOperableTriggerFields(triggerKey, trigger, cronTrigger); if (trigger.get(TIME_ZONE_ID) != null && !trigger.get(TIME_ZONE_ID).isEmpty()) cronTrigger.getTimeZone().setID(trigger.get(TIME_ZONE_ID).isEmpty() ? null : trigger.get(TIME_ZONE_ID)); try { if (trigger.get(CRON_EXPRESSION) != null && !trigger.get(CRON_EXPRESSION).isEmpty()) cronTrigger.setCronExpression(trigger.get(CRON_EXPRESSION).isEmpty() ? null : trigger.get(CRON_EXPRESSION)); } catch (ParseException ex) { log.warn("could not parse cron_expression: " + trigger.get(CRON_EXPRESSION) + " for trigger: " + createTriggerHashKey(triggerKey.getGroup(), triggerKey.getName())); } return cronTrigger; } else { // other trigger types are not supported throw new UnsupportedOperationException(); } }
Example #12
Source File: AbstractJobStoreTest.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Test public void testResetErrorTrigger() throws Exception { Date baseFireTimeDate = DateBuilder.evenMinuteDateAfterNow(); long baseFireTime = baseFireTimeDate.getTime(); // create and store a trigger OperableTrigger trigger1 = new SimpleTriggerImpl("trigger1", "triggerGroup1", this.fJobDetail.getName(), this.fJobDetail.getGroup(), new Date(baseFireTime + 200000), new Date(baseFireTime + 200000), 2, 2000); trigger1.computeFirstFireTime(null); this.fJobStore.storeTrigger(trigger1, false); long firstFireTime = new Date(trigger1.getNextFireTime().getTime()).getTime(); // pretend to fire it List<OperableTrigger> aqTs = this.fJobStore.acquireNextTriggers( firstFireTime + 10000, 1, 0L); assertEquals(trigger1.getKey(), aqTs.get(0).getKey()); List<TriggerFiredResult> fTs = this.fJobStore.triggersFired(aqTs); TriggerFiredResult ft = fTs.get(0); // get the trigger into error state this.fJobStore.triggeredJobComplete(ft.getTriggerFiredBundle().getTrigger(), ft.getTriggerFiredBundle().getJobDetail(), Trigger.CompletedExecutionInstruction.SET_TRIGGER_ERROR); TriggerState state = this.fJobStore.getTriggerState(trigger1.getKey()); assertEquals(TriggerState.ERROR, state); // test reset this.fJobStore.resetTriggerFromErrorState(trigger1.getKey()); state = this.fJobStore.getTriggerState(trigger1.getKey()); assertEquals(TriggerState.NORMAL, state); }
Example #13
Source File: AbstractJobStoreTest.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Test @SuppressWarnings("deprecation") public void testStoreTriggerReplacesTrigger() throws Exception { String jobName = "StoreTriggerReplacesTrigger"; String jobGroup = "StoreTriggerReplacesTriggerGroup"; JobDetailImpl detail = new JobDetailImpl(jobName, jobGroup, MyJob.class); fJobStore.storeJob(detail, false); String trName = "StoreTriggerReplacesTrigger"; String trGroup = "StoreTriggerReplacesTriggerGroup"; OperableTrigger tr = new SimpleTriggerImpl(trName ,trGroup, new Date()); tr.setJobKey(new JobKey(jobName, jobGroup)); tr.setCalendarName(null); fJobStore.storeTrigger(tr, false); assertEquals(tr,fJobStore.retrieveTrigger(tr.getKey())); try { fJobStore.storeTrigger(tr, false); fail("an attempt to store duplicate trigger succeeded"); } catch(ObjectAlreadyExistsException oaee) { // expected } tr.setCalendarName("QQ"); fJobStore.storeTrigger(tr, true); //fails here assertEquals(tr, fJobStore.retrieveTrigger(tr.getKey())); assertEquals( "StoreJob doesn't replace triggers", "QQ", fJobStore.retrieveTrigger(tr.getKey()).getCalendarName()); }
Example #14
Source File: AbstractJobStoreTest.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Test @SuppressWarnings("deprecation") public void testTriggerStates() throws Exception { OperableTrigger trigger = new SimpleTriggerImpl("trigger1", "triggerGroup1", this.fJobDetail.getName(), this.fJobDetail.getGroup(), new Date(System.currentTimeMillis() + 100000), new Date(System.currentTimeMillis() + 200000), 2, 2000); trigger.computeFirstFireTime(null); assertEquals(TriggerState.NONE, this.fJobStore.getTriggerState(trigger.getKey())); this.fJobStore.storeTrigger(trigger, false); assertEquals(TriggerState.NORMAL, this.fJobStore.getTriggerState(trigger.getKey())); this.fJobStore.pauseTrigger(trigger.getKey()); assertEquals(TriggerState.PAUSED, this.fJobStore.getTriggerState(trigger.getKey())); this.fJobStore.resumeTrigger(trigger.getKey()); assertEquals(TriggerState.NORMAL, this.fJobStore.getTriggerState(trigger.getKey())); trigger = this.fJobStore.acquireNextTriggers( new Date(trigger.getNextFireTime().getTime()).getTime() + 10000, 1, 1L).get(0); assertNotNull(trigger); this.fJobStore.releaseAcquiredTrigger(trigger); trigger=this.fJobStore.acquireNextTriggers( new Date(trigger.getNextFireTime().getTime()).getTime() + 10000, 1, 1L).get(0); assertNotNull(trigger); assertTrue(this.fJobStore.acquireNextTriggers( new Date(trigger.getNextFireTime().getTime()).getTime() + 10000, 1, 1L).isEmpty()); }
Example #15
Source File: JobStoreImplTest.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Test public void testResetErrorTrigger() throws Exception { JobDetail jobDetail = JobBuilder.newJob(MyJob.class).withIdentity("job1", "jobGroup1").storeDurably(true).build(); this.jobStore.storeJob(jobDetail, false); Date baseFireTimeDate = DateBuilder.evenMinuteDateAfterNow(); long baseFireTime = baseFireTimeDate.getTime(); // create and store a trigger OperableTrigger trigger1 = new SimpleTriggerImpl("trigger1", "triggerGroup1", jobDetail.getKey().getName(), jobDetail.getKey().getGroup(), new Date(baseFireTime + 200000), new Date(baseFireTime + 200000), 2, 2000); trigger1.computeFirstFireTime(null); jobStore.storeTrigger(trigger1, false); long firstFireTime = new Date(trigger1.getNextFireTime().getTime()).getTime(); // pretend to fire it List<OperableTrigger> aqTs = jobStore.acquireNextTriggers( firstFireTime + 10000, 1, 0L); assertEquals(trigger1.getKey(), aqTs.get(0).getKey()); List<TriggerFiredResult> fTs = jobStore.triggersFired(aqTs); TriggerFiredResult ft = fTs.get(0); // get the trigger into error state jobStore.triggeredJobComplete(ft.getTriggerFiredBundle().getTrigger(), ft.getTriggerFiredBundle().getJobDetail(), Trigger.CompletedExecutionInstruction.SET_TRIGGER_ERROR); TriggerState state = jobStore.getTriggerState(trigger1.getKey()); assertEquals(TriggerState.ERROR, state); // test reset jobStore.resetTriggerFromErrorState(trigger1.getKey()); state = jobStore.getTriggerState(trigger1.getKey()); assertEquals(TriggerState.NORMAL, state); }
Example #16
Source File: JobStoreImplTest.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Test public void testStoreTriggerReplacesTrigger() throws Exception { String jobName = "StoreTriggerReplacesTrigger"; String jobGroup = "StoreTriggerReplacesTriggerGroup"; JobDetailImpl detail = new JobDetailImpl(jobName, jobGroup, MyJob.class); jobStore.storeJob(detail, false); String trName = "StoreTriggerReplacesTrigger"; String trGroup = "StoreTriggerReplacesTriggerGroup"; OperableTrigger tr = new SimpleTriggerImpl(trName, trGroup, new Date()); tr.setJobKey(new JobKey(jobName, jobGroup)); tr.setCalendarName(null); jobStore.storeTrigger(tr, false); assertEquals(tr, jobStore.retrieveTrigger(tr.getKey())); try { jobStore.storeTrigger(tr, false); fail("an attempt to store duplicate trigger succeeded"); } catch (ObjectAlreadyExistsException oaee) { // expected } tr.setCalendarName("QQ"); jobStore.storeTrigger(tr, true); //fails here assertEquals(tr, jobStore.retrieveTrigger(tr.getKey())); assertEquals("StoreJob doesn't replace triggers", "QQ", jobStore.retrieveTrigger(tr.getKey()).getCalendarName()); }
Example #17
Source File: JobStoreImplTest.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Test public void testTriggerStates() throws Exception { JobDetail jobDetail = JobBuilder.newJob(MyJob.class).withIdentity("job1", "jobGroup1").storeDurably(true).build(); this.jobStore.storeJob(jobDetail, false); OperableTrigger trigger = new SimpleTriggerImpl("trigger1", "triggerGroup1", jobDetail.getKey().getName(), jobDetail.getKey().getGroup(), new Date(System.currentTimeMillis() + 100000), new Date(System.currentTimeMillis() + 200000), 2, 2000); trigger.computeFirstFireTime(null); assertEquals(TriggerState.NONE, this.jobStore.getTriggerState(trigger.getKey())); this.jobStore.storeTrigger(trigger, false); assertEquals(TriggerState.NORMAL, this.jobStore.getTriggerState(trigger.getKey())); this.jobStore.pauseTrigger(trigger.getKey()); assertEquals(TriggerState.PAUSED, this.jobStore.getTriggerState(trigger.getKey())); this.jobStore.resumeTrigger(trigger.getKey()); assertEquals(TriggerState.NORMAL, this.jobStore.getTriggerState(trigger.getKey())); trigger = this.jobStore.acquireNextTriggers( new Date(trigger.getNextFireTime().getTime()).getTime() + 10000, 1, 1L).get(0); assertNotNull(trigger); this.jobStore.releaseAcquiredTrigger(trigger); trigger = this.jobStore.acquireNextTriggers( new Date(trigger.getNextFireTime().getTime()).getTime() + 10000, 1, 1L).get(0); assertNotNull(trigger); assertTrue(this.jobStore.acquireNextTriggers( new Date(trigger.getNextFireTime().getTime()).getTime() + 10000, 1, 1L).isEmpty()); }
Example #18
Source File: SimpleTriggerFactoryBean.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public void afterPropertiesSet() { if (this.name == null) { this.name = this.beanName; } if (this.group == null) { this.group = Scheduler.DEFAULT_GROUP; } if (this.jobDetail != null) { this.jobDataMap.put("jobDetail", this.jobDetail); } if (this.startDelay > 0 || this.startTime == null) { this.startTime = new Date(System.currentTimeMillis() + this.startDelay); } SimpleTriggerImpl sti = new SimpleTriggerImpl(); sti.setName(this.name); sti.setGroup(this.group); sti.setJobKey(this.jobDetail.getKey()); sti.setJobDataMap(this.jobDataMap); sti.setStartTime(this.startTime); sti.setRepeatInterval(this.repeatInterval); sti.setRepeatCount(this.repeatCount); sti.setPriority(this.priority); sti.setMisfireInstruction(this.misfireInstruction); sti.setDescription(this.description); this.simpleTrigger = sti; }
Example #19
Source File: SimpleTriggerSupport.java From lams with GNU General Public License v2.0 | 5 votes |
public static OperableTrigger newTrigger(Map<String, Object> attrMap) throws ParseException { SimpleTriggerImpl result = new SimpleTriggerImpl(); if(attrMap.containsKey("repeatCount")) { result.setRepeatCount(((Integer) attrMap.get("repeatCount")).intValue()); } if(attrMap.containsKey("repeatInterval")) { result.setRepeatInterval(((Long) attrMap.get("repeatInterval")).longValue()); } if(attrMap.containsKey("timesTriggered")) { result.setTimesTriggered(((Integer) attrMap.get("timesTriggered")).intValue()); } TriggerSupport.initializeTrigger(result, attrMap); return result; }
Example #20
Source File: SimpleTriggerSupport.java From lams with GNU General Public License v2.0 | 5 votes |
public static OperableTrigger newTrigger(CompositeData cData) throws ParseException { SimpleTriggerImpl result = new SimpleTriggerImpl(); result.setRepeatCount(((Integer) cData.get("repeatCount")).intValue()); result.setRepeatInterval(((Long) cData.get("repeatInterval")).longValue()); result.setTimesTriggered(((Integer) cData.get("timesTriggered")).intValue()); TriggerSupport.initializeTrigger(result, cData); return result; }
Example #21
Source File: SimpleScheduleBuilder.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Build the actual Trigger -- NOT intended to be invoked by end users, * but will rather be invoked by a TriggerBuilder which this * ScheduleBuilder is given to. * * @see TriggerBuilder#withSchedule(ScheduleBuilder) */ @Override public MutableTrigger build() { SimpleTriggerImpl st = new SimpleTriggerImpl(); st.setRepeatInterval(interval); st.setRepeatCount(repeatCount); st.setMisfireInstruction(misfireInstruction); return st; }
Example #22
Source File: DefaultClusteredJobStore.java From lams with GNU General Public License v2.0 | 5 votes |
protected OperableTrigger createRecoveryTrigger(TriggerWrapper tw, JobWrapper jw, String name, FiredTrigger recovering) { final SimpleTriggerImpl recoveryTrigger = new SimpleTriggerImpl(name, Scheduler.DEFAULT_RECOVERY_GROUP, new Date(recovering.getScheduledFireTime())); recoveryTrigger.setJobName(jw.getKey().getName()); recoveryTrigger.setJobGroup(jw.getKey().getGroup()); recoveryTrigger.setMisfireInstruction(SimpleTrigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY); recoveryTrigger.setPriority(tw.getPriority()); return recoveryTrigger; }
Example #23
Source File: SimpleTriggerFactoryBean.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void afterPropertiesSet() { if (this.name == null) { this.name = this.beanName; } if (this.group == null) { this.group = Scheduler.DEFAULT_GROUP; } if (this.jobDetail != null) { this.jobDataMap.put("jobDetail", this.jobDetail); } if (this.startDelay > 0 || this.startTime == null) { this.startTime = new Date(System.currentTimeMillis() + this.startDelay); } SimpleTriggerImpl sti = new SimpleTriggerImpl(); sti.setName(this.name); sti.setGroup(this.group); if (this.jobDetail != null) { sti.setJobKey(this.jobDetail.getKey()); } sti.setJobDataMap(this.jobDataMap); sti.setStartTime(this.startTime); sti.setRepeatInterval(this.repeatInterval); sti.setRepeatCount(this.repeatCount); sti.setPriority(this.priority); sti.setMisfireInstruction(this.misfireInstruction); sti.setDescription(this.description); this.simpleTrigger = sti; }
Example #24
Source File: EntityMocksHelper.java From griffin with Apache License 2.0 | 5 votes |
public static SimpleTrigger createSimpleTrigger( int repeatCount, int triggerCount) { SimpleTriggerImpl trigger = new SimpleTriggerImpl(); trigger.setRepeatCount(repeatCount); trigger.setTimesTriggered(triggerCount); trigger.setPreviousFireTime(new Date()); return trigger; }
Example #25
Source File: SimpleTriggerFactoryBean.java From java-technology-stack with MIT License | 5 votes |
@Override public void afterPropertiesSet() { if (this.name == null) { this.name = this.beanName; } if (this.group == null) { this.group = Scheduler.DEFAULT_GROUP; } if (this.jobDetail != null) { this.jobDataMap.put("jobDetail", this.jobDetail); } if (this.startDelay > 0 || this.startTime == null) { this.startTime = new Date(System.currentTimeMillis() + this.startDelay); } SimpleTriggerImpl sti = new SimpleTriggerImpl(); sti.setName(this.name != null ? this.name : toString()); sti.setGroup(this.group); if (this.jobDetail != null) { sti.setJobKey(this.jobDetail.getKey()); } sti.setJobDataMap(this.jobDataMap); sti.setStartTime(this.startTime); sti.setRepeatInterval(this.repeatInterval); sti.setRepeatCount(this.repeatCount); sti.setPriority(this.priority); sti.setMisfireInstruction(this.misfireInstruction); sti.setDescription(this.description); this.simpleTrigger = sti; }
Example #26
Source File: SimpleTriggerFactoryBean.java From spring-analysis-note with MIT License | 5 votes |
@Override public void afterPropertiesSet() { if (this.name == null) { this.name = this.beanName; } if (this.group == null) { this.group = Scheduler.DEFAULT_GROUP; } if (this.jobDetail != null) { this.jobDataMap.put("jobDetail", this.jobDetail); } if (this.startDelay > 0 || this.startTime == null) { this.startTime = new Date(System.currentTimeMillis() + this.startDelay); } SimpleTriggerImpl sti = new SimpleTriggerImpl(); sti.setName(this.name != null ? this.name : toString()); sti.setGroup(this.group); if (this.jobDetail != null) { sti.setJobKey(this.jobDetail.getKey()); } sti.setJobDataMap(this.jobDataMap); sti.setStartTime(this.startTime); sti.setRepeatInterval(this.repeatInterval); sti.setRepeatCount(this.repeatCount); sti.setPriority(this.priority); sti.setMisfireInstruction(this.misfireInstruction); sti.setDescription(this.description); this.simpleTrigger = sti; }
Example #27
Source File: JobStoreImplTest.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
@Test public void testAcquireNextTrigger() throws Exception { JobDetail jobDetail = JobBuilder.newJob(MyJob.class).withIdentity("job1", "jobGroup1").storeDurably(true).build(); this.jobStore.storeJob(jobDetail, false); Date baseFireTimeDate = DateBuilder.evenMinuteDateAfterNow(); long baseFireTime = baseFireTimeDate.getTime(); OperableTrigger trigger1 = new SimpleTriggerImpl("trigger1", "triggerGroup1", jobDetail.getKey().getName(), jobDetail.getKey().getGroup(), new Date(baseFireTime + 200000), new Date(baseFireTime + 200000), 2, 2000); OperableTrigger trigger2 = new SimpleTriggerImpl("trigger2", "triggerGroup1", jobDetail.getKey().getName(), jobDetail.getKey().getGroup(), new Date(baseFireTime + 50000), new Date(baseFireTime + 200000), 2, 2000); OperableTrigger trigger3 = new SimpleTriggerImpl("trigger1", "triggerGroup2", jobDetail.getKey().getName(), jobDetail.getKey().getGroup(), new Date(baseFireTime + 100000), new Date(baseFireTime + 200000), 2, 2000); trigger1.computeFirstFireTime(null); trigger2.computeFirstFireTime(null); trigger3.computeFirstFireTime(null); this.jobStore.storeTrigger(trigger1, false); this.jobStore.storeTrigger(trigger2, false); this.jobStore.storeTrigger(trigger3, false); long firstFireTime = new Date(trigger1.getNextFireTime().getTime()).getTime(); assertTrue(this.jobStore.acquireNextTriggers(10, 1, 0L).isEmpty()); assertEquals( trigger2.getKey(), this.jobStore.acquireNextTriggers(firstFireTime + 10000, 1, 0L).get(0).getKey()); assertEquals( trigger3.getKey(), this.jobStore.acquireNextTriggers(firstFireTime + 10000, 1, 0L).get(0).getKey()); assertEquals( trigger1.getKey(), this.jobStore.acquireNextTriggers(firstFireTime + 10000, 1, 0L).get(0).getKey()); assertTrue( this.jobStore.acquireNextTriggers(firstFireTime + 10000, 1, 0L).isEmpty()); // release trigger3 this.jobStore.releaseAcquiredTrigger(trigger3); assertEquals( trigger3, this.jobStore.acquireNextTriggers(new Date(trigger1.getNextFireTime().getTime()).getTime() + 10000, 1, 1L) .get(0)); }
Example #28
Source File: AbstractJobStoreTest.java From nexus-public with Eclipse Public License 1.0 | 4 votes |
@Test @SuppressWarnings("deprecation") public void testAcquireNextTrigger() throws Exception { Date baseFireTimeDate = DateBuilder.evenMinuteDateAfterNow(); long baseFireTime = baseFireTimeDate.getTime(); OperableTrigger trigger1 = new SimpleTriggerImpl("trigger1", "triggerGroup1", this.fJobDetail.getName(), this.fJobDetail.getGroup(), new Date(baseFireTime + 200000), new Date(baseFireTime + 200000), 2, 2000); OperableTrigger trigger2 = new SimpleTriggerImpl("trigger2", "triggerGroup1", this.fJobDetail.getName(), this.fJobDetail.getGroup(), new Date(baseFireTime + 50000), new Date(baseFireTime + 200000), 2, 2000); OperableTrigger trigger3 = new SimpleTriggerImpl("trigger1", "triggerGroup2", this.fJobDetail.getName(), this.fJobDetail.getGroup(), new Date(baseFireTime + 100000), new Date(baseFireTime + 200000), 2, 2000); trigger1.computeFirstFireTime(null); trigger2.computeFirstFireTime(null); trigger3.computeFirstFireTime(null); this.fJobStore.storeTrigger(trigger1, false); this.fJobStore.storeTrigger(trigger2, false); this.fJobStore.storeTrigger(trigger3, false); long firstFireTime = new Date(trigger1.getNextFireTime().getTime()).getTime(); assertTrue(this.fJobStore.acquireNextTriggers(10, 1, 0L).isEmpty()); assertEquals( trigger2.getKey(), this.fJobStore.acquireNextTriggers(firstFireTime + 10000, 1, 0L).get(0).getKey()); assertEquals( trigger3.getKey(), this.fJobStore.acquireNextTriggers(firstFireTime + 10000, 1, 0L).get(0).getKey()); assertEquals( trigger1.getKey(), this.fJobStore.acquireNextTriggers(firstFireTime + 10000, 1, 0L).get(0).getKey()); assertTrue( this.fJobStore.acquireNextTriggers(firstFireTime + 10000, 1, 0L).isEmpty()); // release trigger3 this.fJobStore.releaseAcquiredTrigger(trigger3); assertEquals( trigger3, this.fJobStore.acquireNextTriggers(new Date(trigger1.getNextFireTime().getTime()).getTime() + 10000, 1, 1L).get(0)); }
Example #29
Source File: SchedulerServiceImpl.java From uflo with Apache License 2.0 | 4 votes |
public void addReminderJob(TaskReminder reminder,ProcessInstance processInstance,Task task) { JobKey jobKey=new JobKey(JOB_NAME_PREFIX+reminder.getId(),JOB_GROUP_PREFIX); try { if(scheduler.checkExists(jobKey)){ return; } AbstractTrigger<? extends Trigger> trigger=null; if(reminder.getType().equals(ReminderType.Once)){ SimpleTriggerImpl simpleTrigger=new SimpleTriggerImpl(); simpleTrigger.setRepeatCount(0); trigger=simpleTrigger; long executeTime=reminder.getStartDate().getTime()+10000; long now=(new Date()).getTime(); if(executeTime<=now){ return; } }else{ CronTriggerImpl cronTrigger=new CronTriggerImpl(); cronTrigger.setCronExpression(reminder.getCron()); trigger=cronTrigger; } trigger.setName("trigger_"+reminder.getId()); trigger.setStartTime(reminder.getStartDate()); ReminderJobDetail jobDetail=new ReminderJobDetail(); jobDetail.setJobClass(ReminderJob.class); ReminderHandler handler=(ReminderHandler)applicationContext.getBean(reminder.getReminderHandlerBean()); jobDetail.setReminderHandlerBean(handler); if(task==null){ task=taskService.getTask(reminder.getTaskId()); } jobDetail.setTask(task); jobDetail.setProcessInstance(processService.getProcessInstanceById(task.getProcessInstanceId())); jobDetail.setKey(jobKey); Calendar calendar=getCalendar(reminder,processInstance,task); if(calendar!=null){ String calendarName=REMINDER_CALENDAR_PREFIX+reminder.getId(); scheduler.addCalendar(calendarName, calendar,false, false); trigger.setCalendarName(calendarName); } scheduler.scheduleJob(jobDetail, trigger); } catch (Exception e) { throw new RuntimeException(e); } }
Example #30
Source File: SimpleTriggerPersistenceDelegate.java From lams with GNU General Public License v2.0 | 4 votes |
public boolean canHandleTriggerType(OperableTrigger trigger) { return ((trigger instanceof SimpleTriggerImpl) && !((SimpleTriggerImpl)trigger).hasAdditionalProperties()); }