Search in sources :

Example 61 with StdSchedulerFactory

use of org.quartz.impl.StdSchedulerFactory in project ovirt-engine by oVirt.

the class SchedulerUtilQuartzImpl method setup.

/*
     * retrieving the quartz scheduler from the factory.
     */
public void setup() {
    try {
        SchedulerFactory sf = new StdSchedulerFactory();
        sched = sf.getScheduler();
        sched.start();
        sched.getListenerManager().addJobListener(new FixedDelayJobListener(this), jobGroupEquals(Scheduler.DEFAULT_GROUP));
    } catch (SchedulerException se) {
        log.error("there is a problem with the underlying Scheduler: {}", se.getMessage());
        log.debug("Exception", se);
    }
}
Also used : StdSchedulerFactory(org.quartz.impl.StdSchedulerFactory) SchedulerException(org.quartz.SchedulerException) SchedulerFactory(org.quartz.SchedulerFactory) StdSchedulerFactory(org.quartz.impl.StdSchedulerFactory)

Example 62 with StdSchedulerFactory

use of org.quartz.impl.StdSchedulerFactory in project sharding-jdbc by shardingjdbc.

the class BASETransactionJobFactory method start.

/**
 * start job.
 *
 * @throws SchedulerException quartz scheduler exception
 */
public void start() throws SchedulerException {
    SchedulerFactory schedulerFactory = new StdSchedulerFactory();
    Scheduler scheduler = schedulerFactory.getScheduler();
    scheduler.scheduleJob(buildJobDetail(), buildTrigger());
    scheduler.start();
}
Also used : StdSchedulerFactory(org.quartz.impl.StdSchedulerFactory) Scheduler(org.quartz.Scheduler) SchedulerFactory(org.quartz.SchedulerFactory) StdSchedulerFactory(org.quartz.impl.StdSchedulerFactory)

Example 63 with StdSchedulerFactory

use of org.quartz.impl.StdSchedulerFactory in project sponge by softelnet.

the class QuartzEventScheduler method doStartup.

/**
 * Starts up this event scheduler.
 */
@Override
public void doStartup() {
    try {
        Properties props = new Properties();
        props.put(StdSchedulerFactory.PROP_SCHED_INSTANCE_NAME, getName());
        props.put(StdSchedulerFactory.PROP_SCHED_INSTANCE_ID, getName());
        props.put(StdSchedulerFactory.PROP_THREAD_POOL_CLASS, SimpleThreadPool.class.getName());
        // There should be only one thread here to ensure the proper order of scheduled events.
        props.put(PROP_THREAD_COUNT, Integer.toString(1));
        StdSchedulerFactory schedulerFactory = new StdSchedulerFactory();
        schedulerFactory.initialize(props);
        scheduler = schedulerFactory.getScheduler();
        scheduler.start();
    } catch (SchedulerException e) {
        throw SpongeUtils.wrapException(getName(), e);
    }
}
Also used : StdSchedulerFactory(org.quartz.impl.StdSchedulerFactory) SchedulerException(org.quartz.SchedulerException) Properties(java.util.Properties) SimpleThreadPool(org.quartz.simpl.SimpleThreadPool)

Example 64 with StdSchedulerFactory

use of org.quartz.impl.StdSchedulerFactory in project midpoint by Evolveum.

the class QuartzInitializationHelper method initializeScheduler.

/**
 * Prepares Quartz scheduler. Configures its properties (based on Task Manager configuration) and creates the instance.
 * Does not start the scheduler, because this is done during post initialization.
 */
public void initializeScheduler() throws TaskManagerInitializationException {
    Properties quartzProperties = new Properties();
    if (configuration.isJdbcJobStore()) {
        quartzProperties.put("org.quartz.jobStore.class", "org.quartz.impl.jdbcjobstore.JobStoreTX");
        quartzProperties.put("org.quartz.jobStore.driverDelegateClass", configuration.getJdbcDriverDelegateClass());
        quartzProperties.put("org.quartz.jobStore.clusterCheckinInterval", String.valueOf(configuration.getQuartzClusterCheckinInterval()));
        quartzProperties.put("org.quartz.jobStore.clusterCheckinGracePeriod", String.valueOf(configuration.getQuartzClusterCheckinGracePeriod()));
        createQuartzDbSchema(configuration);
        final String myDs = "myDS";
        quartzProperties.put("org.quartz.jobStore.dataSource", myDs);
        if (configuration.isUseRepositoryConnectionProvider()) {
            int index = (int) (Math.random() * Integer.MAX_VALUE);
            RepositoryConnectionProvider.DATA_SOURCES.put(index, repositoryDataSource);
            quartzProperties.put("org.quartz.dataSource." + myDs + ".connectionProvider.class", RepositoryConnectionProvider.class.getName());
            quartzProperties.put("org.quartz.dataSource." + myDs + ".dataSourceIndex", String.valueOf(index));
        } else if (configuration.getDataSource() != null) {
            quartzProperties.put("org.quartz.dataSource." + myDs + ".jndiURL", configuration.getDataSource());
        } else {
            quartzProperties.put("org.quartz.dataSource." + myDs + ".provider", "hikaricp");
            quartzProperties.put("org.quartz.dataSource." + myDs + ".driver", configuration.getJdbcDriver());
            quartzProperties.put("org.quartz.dataSource." + myDs + ".URL", configuration.getJdbcUrl());
            quartzProperties.put("org.quartz.dataSource." + myDs + ".user", configuration.getJdbcUser());
            quartzProperties.put("org.quartz.dataSource." + myDs + ".password", configuration.getJdbcPassword());
        }
        quartzProperties.put("org.quartz.jobStore.isClustered", configuration.isClustered() ? "true" : "false");
    } else {
        quartzProperties.put("org.quartz.jobStore.class", "org.quartz.simpl.RAMJobStore");
    }
    quartzProperties.put("org.quartz.scheduler.instanceName", "midPointScheduler");
    quartzProperties.put("org.quartz.scheduler.instanceId", configuration.getNodeId());
    quartzProperties.put("org.quartz.scheduler.skipUpdateCheck", "true");
    quartzProperties.put("org.quartz.threadPool.threadCount", Integer.toString(configuration.getThreads()));
    quartzProperties.put("org.quartz.scheduler.idleWaitTime", Integer.toString(determineIdleWaitTime()));
    quartzProperties.put("org.quartz.scheduler.jmx.export", "true");
    if (configuration.isTestMode()) {
        LOGGER.info("QuartzScheduler is set to be reusable: the task manager threads will NOT be stopped on shutdown. Also, scheduler threads will run as daemon ones.");
        quartzProperties.put("org.quartz.scheduler.makeSchedulerThreadDaemon", "true");
        quartzProperties.put("org.quartz.threadPool.makeThreadsDaemons", "true");
    }
    LOGGER.info("Initializing Quartz scheduler (but not starting it yet).");
    // initialize the scheduler (without starting it)
    try {
        LOGGER.trace("Quartz scheduler properties: {}", quartzProperties);
        StdSchedulerFactory sf = new StdSchedulerFactory();
        sf.initialize(quartzProperties);
        Scheduler scheduler = sf.getScheduler();
        setMySchedulerListener(scheduler);
        localScheduler.setQuartzScheduler(scheduler);
        LOGGER.info("... Quartz scheduler initialized.");
    } catch (SchedulerException e) {
        throw new TaskManagerInitializationException("Cannot initialize the Quartz scheduler", e);
    }
}
Also used : StdSchedulerFactory(org.quartz.impl.StdSchedulerFactory) SchedulerException(org.quartz.SchedulerException) TaskManagerInitializationException(com.evolveum.midpoint.task.api.TaskManagerInitializationException) Scheduler(org.quartz.Scheduler) Properties(java.util.Properties)

Example 65 with StdSchedulerFactory

use of org.quartz.impl.StdSchedulerFactory in project serverless by bluenimble.

the class SchedulerPlugin method init.

@Override
public void init(final ApiServer server) throws Exception {
    this.server = server;
    Properties props = new Properties();
    Iterator<String> keys = scheduler.keys();
    while (keys.hasNext()) {
        String key = keys.next();
        props.put(key, scheduler.get(key));
    }
    StdSchedulerFactory factory = new StdSchedulerFactory();
    factory.initialize(props);
    oScheduler = factory.getScheduler();
    oScheduler.start();
}
Also used : StdSchedulerFactory(org.quartz.impl.StdSchedulerFactory) Properties(java.util.Properties)

Aggregations

StdSchedulerFactory (org.quartz.impl.StdSchedulerFactory)66 SchedulerFactory (org.quartz.SchedulerFactory)29 SchedulerException (org.quartz.SchedulerException)22 Scheduler (org.quartz.Scheduler)19 JobDetail (org.quartz.JobDetail)17 Logger (org.slf4j.Logger)14 Date (java.util.Date)11 Properties (java.util.Properties)11 Trigger (org.quartz.Trigger)11 JobKey (org.quartz.JobKey)7 JobDataMap (org.quartz.JobDataMap)6 TriggerBuilder.newTrigger (org.quartz.TriggerBuilder.newTrigger)5 InputStream (java.io.InputStream)4 Test (org.junit.Test)4 DateBuilder.nextGivenSecondDate (org.quartz.DateBuilder.nextGivenSecondDate)4 SimpleTrigger (org.quartz.SimpleTrigger)4 ParseException (java.text.ParseException)3 CronTrigger (org.quartz.CronTrigger)3 SimpleThreadPool (org.quartz.simpl.SimpleThreadPool)3 QuartzManager (com.example.quartz.QuartzManager)2