Java Code Examples for org.quartz.SimpleScheduleBuilder#repeatMinutelyForever()
The following examples show how to use
org.quartz.SimpleScheduleBuilder#repeatMinutelyForever() .
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: JobStoreImplTest.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Test public void testAcquireTriggers() throws Exception { // Setup: Store jobs and triggers. long MIN = 60 * 1000L; Date startTime0 = new Date(System.currentTimeMillis() + MIN); // a min from now. for (int i = 0; i < 10; i++) { Date startTime = new Date(startTime0.getTime() + i * MIN); // a min apart JobDetail job = JobBuilder.newJob(MyJob.class).withIdentity("job" + i).build(); SimpleScheduleBuilder schedule = SimpleScheduleBuilder.repeatMinutelyForever(2); OperableTrigger trigger = (OperableTrigger) TriggerBuilder.newTrigger().withIdentity("job" + i) .withSchedule(schedule).forJob(job).startAt(startTime).build(); // Manually trigger the first fire time computation that scheduler would do. Otherwise // the store.acquireNextTriggers() will not work properly. Date fireTime = trigger.computeFirstFireTime(null); assertEquals(true, fireTime != null); jobStore.storeJobAndTrigger(job, trigger); } // Test acquire one trigger at a time for (int i = 0; i < 10; i++) { long noLaterThan = (startTime0.getTime() + i * MIN); int maxCount = 1; long timeWindow = 0; List<OperableTrigger> triggers = jobStore.acquireNextTriggers(noLaterThan, maxCount, timeWindow); assertEquals(1, triggers.size()); assertEquals("job" + i, triggers.get(0).getKey().getName()); // Let's remove the trigger now. jobStore.removeJob(triggers.get(0).getJobKey()); } }
Example 2
Source File: JobStoreImplTest.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Test public void testAcquireTriggersInBatch() throws Exception { // Setup: Store jobs and triggers. long MIN = 60 * 1000L; Date startTime0 = new Date(System.currentTimeMillis() + MIN); // a min from now. for (int i = 0; i < 10; i++) { Date startTime = new Date(startTime0.getTime() + i * MIN); // a min apart JobDetail job = JobBuilder.newJob(MyJob.class).withIdentity("job" + i).build(); SimpleScheduleBuilder schedule = SimpleScheduleBuilder.repeatMinutelyForever(2); OperableTrigger trigger = (OperableTrigger) TriggerBuilder.newTrigger().withIdentity("job" + i) .withSchedule(schedule).forJob(job).startAt(startTime).build(); // Manually trigger the first fire time computation that scheduler would do. Otherwise // the store.acquireNextTriggers() will not work properly. Date fireTime = trigger.computeFirstFireTime(null); assertEquals(true, fireTime != null); jobStore.storeJobAndTrigger(job, trigger); } // Test acquire batch of triggers at a time long noLaterThan = startTime0.getTime() + 10 * MIN; int maxCount = 7; // time window needs to be big to be able to pick up multiple triggers when they are a minute apart long timeWindow = 8 * MIN; List<OperableTrigger> triggers = jobStore.acquireNextTriggers(noLaterThan, maxCount, timeWindow); assertEquals(7, triggers.size()); for (int i = 0; i < 7; i++) { assertEquals("job" + i, triggers.get(i).getKey().getName()); } }
Example 3
Source File: AbstractJobStoreTest.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Test public void testAcquireTriggers() throws Exception { SchedulerSignaler schedSignaler = new SampleSignaler(); ClassLoadHelper loadHelper = new CascadingClassLoadHelper(); loadHelper.initialize(); JobStore store = createJobStore("testAcquireTriggers"); store.initialize(loadHelper, schedSignaler); // Setup: Store jobs and triggers. long MIN = 60 * 1000L; Date startTime0 = new Date(System.currentTimeMillis() + MIN); // a min from now. for (int i=0; i < 10; i++) { Date startTime = new Date(startTime0.getTime() + i * MIN); // a min apart JobDetail job = JobBuilder.newJob(MyJob.class).withIdentity("job" + i).build(); SimpleScheduleBuilder schedule = SimpleScheduleBuilder.repeatMinutelyForever(2); OperableTrigger trigger = (OperableTrigger)TriggerBuilder.newTrigger().withIdentity("job" + i).withSchedule(schedule).forJob(job).startAt(startTime).build(); // Manually trigger the first fire time computation that scheduler would do. Otherwise // the store.acquireNextTriggers() will not work properly. Date fireTime = trigger.computeFirstFireTime(null); Assert.assertEquals(true, fireTime != null); store.storeJobAndTrigger(job, trigger); } // Test acquire one trigger at a time for (int i=0; i < 10; i++) { long noLaterThan = (startTime0.getTime() + i * MIN); int maxCount = 1; long timeWindow = 0; List<OperableTrigger> triggers = store.acquireNextTriggers(noLaterThan, maxCount, timeWindow); Assert.assertEquals(1, triggers.size()); Assert.assertEquals("job" + i, triggers.get(0).getKey().getName()); // Let's remove the trigger now. store.removeJob(triggers.get(0).getJobKey()); } }
Example 4
Source File: AbstractJobStoreTest.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
@Test public void testAcquireTriggersInBatch() throws Exception { SchedulerSignaler schedSignaler = new SampleSignaler(); ClassLoadHelper loadHelper = new CascadingClassLoadHelper(); loadHelper.initialize(); JobStore store = createJobStore("testAcquireTriggersInBatch"); store.initialize(loadHelper, schedSignaler); // Setup: Store jobs and triggers. long MIN = 60 * 1000L; Date startTime0 = new Date(System.currentTimeMillis() + MIN); // a min from now. for (int i=0; i < 10; i++) { Date startTime = new Date(startTime0.getTime() + i * MIN); // a min apart JobDetail job = JobBuilder.newJob(MyJob.class).withIdentity("job" + i).build(); SimpleScheduleBuilder schedule = SimpleScheduleBuilder.repeatMinutelyForever(2); OperableTrigger trigger = (OperableTrigger)TriggerBuilder.newTrigger().withIdentity("job" + i).withSchedule(schedule).forJob(job).startAt(startTime).build(); // Manually trigger the first fire time computation that scheduler would do. Otherwise // the store.acquireNextTriggers() will not work properly. Date fireTime = trigger.computeFirstFireTime(null); Assert.assertEquals(true, fireTime != null); store.storeJobAndTrigger(job, trigger); } // Test acquire batch of triggers at a time long noLaterThan = startTime0.getTime() + 10 * MIN; int maxCount = 7; // time window needs to be big to be able to pick up multiple triggers when they are a minute apart long timeWindow = 8 * MIN; List<OperableTrigger> triggers = store.acquireNextTriggers(noLaterThan, maxCount, timeWindow); Assert.assertEquals(7, triggers.size()); for (int i=0; i < 7; i++) { Assert.assertEquals("job" + i, triggers.get(i).getKey().getName()); } }
Example 5
Source File: DefaultProjectManager.java From onedev with MIT License | 4 votes |
@Override public ScheduleBuilder<?> getScheduleBuilder() { return SimpleScheduleBuilder.repeatMinutelyForever(); }