Search in sources :

Example 46 with SimpleTrigger

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);
}
Also used : CamelContext(org.apache.camel.CamelContext) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) AbstractXmlApplicationContext(org.springframework.context.support.AbstractXmlApplicationContext) SimpleTrigger(org.quartz.SimpleTrigger) Test(org.junit.Test)

Example 47 with SimpleTrigger

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));
}
Also used : JobDetail(org.quartz.JobDetail) Trigger(org.quartz.Trigger) SimpleTrigger(org.quartz.SimpleTrigger) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) SimpleTrigger(org.quartz.SimpleTrigger) Test(org.junit.Test)

Example 48 with SimpleTrigger

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

Example 49 with SimpleTrigger

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

Example 50 with SimpleTrigger

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

Aggregations

SimpleTrigger (org.quartz.SimpleTrigger)75 CronTrigger (org.quartz.CronTrigger)27 SchedulerException (org.quartz.SchedulerException)27 JobDetail (org.quartz.JobDetail)24 Date (java.util.Date)22 Scheduler (org.quartz.Scheduler)21 Trigger (org.quartz.Trigger)20 Test (org.junit.Test)11 JobDataMap (org.quartz.JobDataMap)11 ArrayList (java.util.ArrayList)9 JobDetailBean (org.springframework.scheduling.quartz.JobDetailBean)8 HashMap (java.util.HashMap)7 Test (org.junit.jupiter.api.Test)7 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)6 SimpleDateFormat (java.text.SimpleDateFormat)5 DatasetBean (org.akaza.openclinica.bean.extract.DatasetBean)5 DatasetDAO (org.akaza.openclinica.dao.extract.DatasetDAO)5 TriggerKey (org.quartz.TriggerKey)5 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)4 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)4