use of org.quartz.SimpleTrigger in project camel by apache.
the class SpringQuartzPersistentStoreRestartAppChangeOptionsTest method testRestartAppChangeTriggerOptions.
@Test
public void testRestartAppChangeTriggerOptions() throws Exception {
// Test creates application context twice with different simple trigger options in configuration xml.
// Both times it retrieves back the option, accessing it via trigger (so, using value stored in DB).
// After that it asserts that two options are not equal.
// load spring app
AbstractXmlApplicationContext app = new ClassPathXmlApplicationContext("org/apache/camel/component/quartz2/SpringQuartzPersistentStoreRestartAppChangeOptionsTest1.xml");
app.start();
CamelContext camel = app.getBean("camelContext", CamelContext.class);
assertNotNull(camel);
SimpleTrigger trigger = (SimpleTrigger) getTrigger(camel, "quartzRoute");
long repeatInterval = trigger.getRepeatInterval();
app.stop();
log.info("Restarting ...");
log.info("Restarting ...");
log.info("Restarting ...");
// load spring app
AbstractXmlApplicationContext app2 = new ClassPathXmlApplicationContext("org/apache/camel/component/quartz2/SpringQuartzPersistentStoreRestartAppChangeOptionsTest2.xml");
app2.start();
CamelContext camel2 = app2.getBean("camelContext", CamelContext.class);
assertNotNull(camel2);
SimpleTrigger trigger2 = (SimpleTrigger) getTrigger(camel2, "quartzRoute");
long repeatInterval2 = trigger2.getRepeatInterval();
app2.stop();
// we're done so let's properly close the application contexts, but close
// the second app before the first one so that the quartz scheduler running
// inside it can be properly shutdown
IOHelper.close(app2, app);
assertNotEquals(repeatInterval, repeatInterval2);
}
use of org.quartz.SimpleTrigger in project camel by apache.
the class QuartzSimpleRouteTest method testQuartzCronRoute.
@Test
public void testQuartzCronRoute() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMinimumMessageCount(3);
assertMockEndpointsSatisfied();
Trigger trigger = mock.getReceivedExchanges().get(0).getIn().getHeader("trigger", Trigger.class);
Assert.assertThat(trigger instanceof SimpleTrigger, CoreMatchers.is(true));
JobDetail detail = mock.getReceivedExchanges().get(0).getIn().getHeader("jobDetail", JobDetail.class);
Assert.assertThat(detail.getJobClass().equals(CamelJob.class), CoreMatchers.is(true));
Assert.assertThat(detail.getJobDataMap().get(QuartzConstants.QUARTZ_TRIGGER_TYPE).equals("simple"), CoreMatchers.is(true));
Assert.assertThat(detail.getJobDataMap().get(QuartzConstants.QUARTZ_TRIGGER_SIMPLE_REPEAT_COUNTER).equals(-1), CoreMatchers.is(true));
Assert.assertThat(detail.getJobDataMap().get(QuartzConstants.QUARTZ_TRIGGER_SIMPLE_REPEAT_INTERVAL).equals(2000L), CoreMatchers.is(true));
}
use of org.quartz.SimpleTrigger in project searchcode-server by boyter.
the class JobService method startSpellingJob.
/**
* Starts a background job which updates the spelling corrector
*/
private void startSpellingJob() {
try {
Scheduler scheduler = Singleton.getScheduler();
// Setup the indexer which runs forever adding documents to be indexed
JobDetail job = newJob(PopulateSpellingCorrectorJob.class).withIdentity("spellingjob").build();
SimpleTrigger trigger = newTrigger().withIdentity("spellingjob").withSchedule(simpleSchedule().withIntervalInSeconds(360).repeatForever()).build();
scheduler.scheduleJob(job, trigger);
scheduler.start();
} catch (SchedulerException ex) {
Singleton.getLogger().severe(" caught a " + ex.getClass() + "\n with message: " + ex.getMessage());
}
}
use of org.quartz.SimpleTrigger in project searchcode-server by boyter.
the class JobService method startEnqueueJob.
/**
* Starts a background job which pulls all repositories from the database and adds them to the
* queue to be indexed
*/
private void startEnqueueJob() {
try {
Scheduler scheduler = Singleton.getScheduler();
// Setup the indexer which runs forever adding documents to be indexed
JobDetail job = newJob(EnqueueRepositoryJob.class).withIdentity("enqueuejob").build();
SimpleTrigger trigger = newTrigger().withIdentity("enqueuejob").withSchedule(simpleSchedule().withIntervalInSeconds(this.UPDATETIME).repeatForever()).build();
scheduler.scheduleJob(job, trigger);
scheduler.start();
Scheduler scheduler2 = Singleton.getScheduler();
// Setup the indexer which runs forever adding documents to be indexed
JobDetail job2 = newJob(EnqueueFileRepositoryJob.class).withIdentity("enqueuefilejob").build();
SimpleTrigger trigger2 = newTrigger().withIdentity("enqueuefilejob").withSchedule(simpleSchedule().withIntervalInSeconds(this.FILEINDEXUPDATETIME).repeatForever()).build();
scheduler2.scheduleJob(job2, trigger2);
scheduler2.start();
} catch (SchedulerException ex) {
Singleton.getLogger().severe(" caught a " + ex.getClass() + "\n with message: " + ex.getMessage());
}
}
use of org.quartz.SimpleTrigger in project searchcode-server by boyter.
the class JobService method startIndexGitRepoJobs.
/**
* Creates a git repo indexer job which will pull from the list of git repositories and start
* indexing them
*/
public void startIndexGitRepoJobs(String uniquename) {
try {
Scheduler scheduler = Singleton.getScheduler();
JobDetail job = newJob(IndexGitRepoJob.class).withIdentity("updateindex-git-" + uniquename).build();
SimpleTrigger trigger = newTrigger().withIdentity("updateindex-git-" + uniquename).withSchedule(simpleSchedule().withIntervalInSeconds(this.INDEXTIME).repeatForever()).build();
job.getJobDataMap().put("REPOLOCATIONS", this.REPOLOCATION);
job.getJobDataMap().put("LOWMEMORY", this.LOWMEMORY);
scheduler.scheduleJob(job, trigger);
scheduler.start();
} catch (SchedulerException ex) {
Singleton.getLogger().severe(" caught a " + ex.getClass() + "\n with message: " + ex.getMessage());
}
}
Aggregations