Search in sources :

Example 21 with SimpleTrigger

use of org.quartz.SimpleTrigger in project searchcode-server by boyter.

the class JobService method startIndexerJob.

private void startIndexerJob() throws SchedulerException {
    Scheduler scheduler = Singleton.getScheduler();
    // Setup the indexer which runs forever indexing
    JobDetail job = newJob(IndexDocumentsJob.class).withIdentity("indexerjob").build();
    SimpleTrigger trigger = newTrigger().withIdentity("indexerjob").withSchedule(simpleSchedule().withIntervalInSeconds(this.INDEXTIME).repeatForever()).build();
    scheduler.scheduleJob(job, trigger);
    scheduler.start();
}
Also used : JobDetail(org.quartz.JobDetail) Scheduler(org.quartz.Scheduler) SimpleTrigger(org.quartz.SimpleTrigger)

Example 22 with SimpleTrigger

use of org.quartz.SimpleTrigger in project searchcode-server by boyter.

the class JobService method startIndexSvnRepoJobs.

/**
     * Creates a svn repo indexer job which will pull from the list of git repositories and start
     * indexing them
     */
public void startIndexSvnRepoJobs(String uniquename) {
    try {
        Scheduler scheduler = Singleton.getScheduler();
        JobDetail job = newJob(IndexSvnRepoJob.class).withIdentity("updateindex-svn-" + uniquename).build();
        SimpleTrigger trigger = newTrigger().withIdentity("updateindex-svn-" + 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)

Example 23 with SimpleTrigger

use of org.quartz.SimpleTrigger in project head by mifos.

the class MifosScheduler method schedule.

@Deprecated
public void schedule(final String jobName, Date initialTime, long delay, JobRegistry jobRegistry, final JobRepository jobRepository, Map<String, Object> jobData, ResourcelessTransactionManager transactionManager) throws TaskSystemException {
    try {
        final TaskletStep step = new TaskletStep();
        step.setName(jobName);
        Tasklet tasklet = (Tasklet) Class.forName(BATCH_JOB_CLASS_PATH_PREFIX + getHelperName(jobName)).newInstance();
        step.setTasklet(tasklet);
        step.setJobRepository(jobRepository);
        step.setTransactionManager(transactionManager);
        step.afterPropertiesSet();
        jobRegistry.register(new JobFactory() {

            @Override
            public Job createJob() {
                SimpleJob job = new SimpleJob(jobName + "Job");
                job.setJobRepository(jobRepository);
                job.setRestartable(true);
                job.registerJobExecutionListener(new BatchJobListener());
                job.addStep(step);
                return job;
            }

            @Override
            public String getJobName() {
                return jobName + "Job";
            }
        });
    } catch (Exception e) {
        throw new TaskSystemException(e);
    }
    JobDetailBean jobDetailBean = new JobDetailBean();
    jobDetailBean.setJobDataAsMap(jobData);
    try {
        jobDetailBean.setJobClass(Class.forName(BATCH_JOB_CLASS_PATH_PREFIX + jobName));
    } catch (ClassNotFoundException cnfe) {
        throw new TaskSystemException(cnfe);
    }
    jobDetailBean.setName(jobName + "Job");
    jobDetailBean.setGroup(Scheduler.DEFAULT_GROUP);
    jobDetailBean.afterPropertiesSet();
    SimpleTrigger trigger = new SimpleTrigger();
    trigger.setName(jobName + "Job");
    trigger.setGroup(Scheduler.DEFAULT_GROUP);
    trigger.setStartTime(initialTime);
    trigger.setRepeatInterval(delay);
    trigger.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY);
    try {
        scheduler.scheduleJob(jobDetailBean, trigger);
    } catch (SchedulerException se) {
        throw new TaskSystemException(se);
    }
}
Also used : SchedulerException(org.quartz.SchedulerException) JobDetailBean(org.springframework.scheduling.quartz.JobDetailBean) Tasklet(org.springframework.batch.core.step.tasklet.Tasklet) TaskSystemException(org.mifos.framework.components.batchjobs.exceptions.TaskSystemException) SchedulerException(org.quartz.SchedulerException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) IOException(java.io.IOException) JobFactory(org.springframework.batch.core.configuration.JobFactory) TaskSystemException(org.mifos.framework.components.batchjobs.exceptions.TaskSystemException) SimpleJob(org.springframework.batch.core.job.SimpleJob) TaskletStep(org.springframework.batch.core.step.tasklet.TaskletStep) Job(org.springframework.batch.core.Job) SimpleJob(org.springframework.batch.core.job.SimpleJob) SimpleTrigger(org.quartz.SimpleTrigger)

Example 24 with SimpleTrigger

use of org.quartz.SimpleTrigger in project head by mifos.

the class MifosScheduler method scheduleLoanArrearsAndPortfolioAtRisk.

@Deprecated
public void scheduleLoanArrearsAndPortfolioAtRisk(Date initialTime, long delay, JobRegistry jobRegistry, final JobRepository jobRepository, Map<String, Object> jobData, ResourcelessTransactionManager transactionManager) throws TaskSystemException {
    final String jobName = "LoanArrearsAndPortfolioAtRiskTask";
    try {
        final TaskletStep step1 = new TaskletStep();
        step1.setName("LoanArrearsAndPortfolioAtRiskTask-step-1");
        step1.setTasklet((Tasklet) Class.forName(BATCH_JOB_CLASS_PATH_PREFIX + getHelperName("LoanArrearsTask")).newInstance());
        step1.setJobRepository(jobRepository);
        step1.setTransactionManager(transactionManager);
        step1.afterPropertiesSet();
        final TaskletStep step2 = new TaskletStep();
        step2.setName("LoanArrearsAndPortfolioAtRiskTask-step-2");
        step2.setTasklet((Tasklet) Class.forName(BATCH_JOB_CLASS_PATH_PREFIX + getHelperName("PortfolioAtRiskTask")).newInstance());
        step2.setJobRepository(jobRepository);
        step2.setTransactionManager(transactionManager);
        step2.afterPropertiesSet();
        jobRegistry.register(new JobFactory() {

            @Override
            public Job createJob() {
                SimpleJob job = new SimpleJob(jobName + "Job");
                job.setJobRepository(jobRepository);
                job.setRestartable(true);
                job.registerJobExecutionListener(new BatchJobListener());
                job.addStep(step1);
                job.addStep(step2);
                return job;
            }

            @Override
            public String getJobName() {
                return jobName + "Job";
            }
        });
    } catch (Exception e) {
        throw new TaskSystemException(e);
    }
    JobDetailBean jobDetailBean = new JobDetailBean();
    jobDetailBean.setJobDataAsMap(jobData);
    try {
        jobDetailBean.setJobClass(Class.forName(BATCH_JOB_CLASS_PATH_PREFIX + "PortfolioAtRiskTask"));
    } catch (ClassNotFoundException cnfe) {
        throw new TaskSystemException(cnfe);
    }
    jobDetailBean.setName(jobName + "Job");
    jobDetailBean.setGroup(Scheduler.DEFAULT_GROUP);
    jobDetailBean.afterPropertiesSet();
    SimpleTrigger trigger = new SimpleTrigger();
    trigger.setName(jobName + "Job");
    trigger.setGroup(Scheduler.DEFAULT_GROUP);
    trigger.setStartTime(initialTime);
    trigger.setRepeatInterval(delay);
    trigger.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY);
    try {
        scheduler.scheduleJob(jobDetailBean, trigger);
    } catch (SchedulerException se) {
        throw new TaskSystemException(se);
    }
}
Also used : SchedulerException(org.quartz.SchedulerException) JobDetailBean(org.springframework.scheduling.quartz.JobDetailBean) TaskSystemException(org.mifos.framework.components.batchjobs.exceptions.TaskSystemException) SchedulerException(org.quartz.SchedulerException) MifosRuntimeException(org.mifos.core.MifosRuntimeException) IOException(java.io.IOException) JobFactory(org.springframework.batch.core.configuration.JobFactory) TaskSystemException(org.mifos.framework.components.batchjobs.exceptions.TaskSystemException) SimpleJob(org.springframework.batch.core.job.SimpleJob) TaskletStep(org.springframework.batch.core.step.tasklet.TaskletStep) Job(org.springframework.batch.core.Job) SimpleJob(org.springframework.batch.core.job.SimpleJob) SimpleTrigger(org.quartz.SimpleTrigger)

Example 25 with SimpleTrigger

use of org.quartz.SimpleTrigger in project openhab1-addons by openhab.

the class CalDavLoaderImpl method startLoading.

public void startLoading() {
    if (execService != null) {
        return;
    }
    log.trace("starting execution...");
    int i = 0;
    for (final CalendarRuntime eventRuntime : EventStorage.getInstance().getEventCache().values()) {
        try {
            JobDetail job = JobBuilder.newJob().ofType(EventReloaderJob.class).usingJobData(EventReloaderJob.KEY_CONFIG, eventRuntime.getConfig().getKey()).withIdentity(eventRuntime.getConfig().getKey(), JOB_NAME_EVENT_RELOADER).storeDurably().build();
            this.scheduler.addJob(job, false);
            SimpleTrigger jobTrigger = TriggerBuilder.newTrigger().forJob(job).withIdentity(eventRuntime.getConfig().getKey(), JOB_NAME_EVENT_RELOADER).startAt(DateBuilder.futureDate(10 + i, IntervalUnit.SECOND)).withSchedule(SimpleScheduleBuilder.repeatMinutelyForever(eventRuntime.getConfig().getReloadMinutes())).build();
            this.scheduler.scheduleJob(jobTrigger);
            log.info("reload job scheduled for: {}", eventRuntime.getConfig().getKey());
        } catch (SchedulerException e) {
            log.error("cannot schedule calendar-reloader", e);
        }
        // next event 10 seconds later
        i += 10;
    }
}
Also used : JobDetail(org.quartz.JobDetail) SchedulerException(org.quartz.SchedulerException) CalendarRuntime(org.openhab.io.caldav.internal.EventStorage.CalendarRuntime) SimpleTrigger(org.quartz.SimpleTrigger)

Aggregations

SimpleTrigger (org.quartz.SimpleTrigger)37 SchedulerException (org.quartz.SchedulerException)18 JobDetail (org.quartz.JobDetail)14 CronTrigger (org.quartz.CronTrigger)11 Scheduler (org.quartz.Scheduler)11 Date (java.util.Date)8 Test (org.junit.Test)8 Trigger (org.quartz.Trigger)6 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)5 JobDataMap (org.quartz.JobDataMap)5 SimpleDateFormat (java.text.SimpleDateFormat)4 DatasetBean (org.akaza.openclinica.bean.extract.DatasetBean)4 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)4 DatasetDAO (org.akaza.openclinica.dao.extract.DatasetDAO)4 CamelContext (org.apache.camel.CamelContext)4 AbstractXmlApplicationContext (org.springframework.context.support.AbstractXmlApplicationContext)4 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)4 IOException (java.io.IOException)3 HashMap (java.util.HashMap)3 JobExecutionException (org.quartz.JobExecutionException)3