org.quartz.spi.ThreadExecutor Java Examples

The following examples show how to use org.quartz.spi.ThreadExecutor. 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: QuartzScheduler.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * <p>
 * Create a <code>QuartzScheduler</code> with the given configuration
 * properties.
 * </p>
 * 
 * @see QuartzSchedulerResources
 */
public QuartzScheduler(QuartzSchedulerResources resources, long idleWaitTime, @Deprecated long dbRetryInterval)
    throws SchedulerException {
    this.resources = resources;
    if (resources.getJobStore() instanceof JobListener) {
        addInternalJobListener((JobListener)resources.getJobStore());
    }

    this.schedThread = new QuartzSchedulerThread(this, resources);
    ThreadExecutor schedThreadExecutor = resources.getThreadExecutor();
    schedThreadExecutor.execute(this.schedThread);
    if (idleWaitTime > 0) {
        this.schedThread.setIdleWaitTime(idleWaitTime);
    }

    jobMgr = new ExecutingJobsManager();
    addInternalJobListener(jobMgr);
    errLogger = new ErrorLogger();
    addInternalSchedulerListener(errLogger);

    signaler = new SchedulerSignalerImpl(this, this.schedThread);
    
    if(shouldRunUpdateCheck()) 
        updateTimer = scheduleUpdateCheck();
    else
        updateTimer = null;
    
    getLog().info("Quartz Scheduler v." + getVersion() + " created.");
}
 
Example #2
Source File: QuartzScheduler.java    From AsuraFramework with Apache License 2.0 5 votes vote down vote up
/**
 * <p>
 * Create a <code>QuartzScheduler</code> with the given configuration
 * properties.
 * </p>
 * 
 * @see QuartzSchedulerResources
 */
public QuartzScheduler(QuartzSchedulerResources resources,
        SchedulingContext ctxt, long idleWaitTime, long dbRetryInterval)
    throws SchedulerException {
    this.resources = resources;

    this.schedThread = new QuartzSchedulerThread(this, resources, ctxt);
    ThreadExecutor schedThreadExecutor = resources.getThreadExecutor();
    schedThreadExecutor.execute(this.schedThread);
    if (idleWaitTime > 0) {
        this.schedThread.setIdleWaitTime(idleWaitTime);
    }
    if (dbRetryInterval > 0) {
        this.schedThread.setDbFailureRetryInterval(dbRetryInterval);
    }

    jobMgr = new ExecutingJobsManager();
    addGlobalJobListener(jobMgr);
    errLogger = new ErrorLogger();
    addSchedulerListener(errLogger);

    signaler = new SchedulerSignalerImpl(this, this.schedThread);
    
    if(shouldRunUpdateCheck()) 
        updateTimer = scheduleUpdateCheck();
    else
        updateTimer = null;
    
    this.dbRetryInterval = dbRetryInterval;
    
    getLog().info("Quartz Scheduler v." + getVersion() + " created.");
    
}
 
Example #3
Source File: JobStoreSupport.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public void setThreadExecutor(ThreadExecutor threadExecutor) {
    this.threadExecutor = threadExecutor;
}
 
Example #4
Source File: JobStoreSupport.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public ThreadExecutor getThreadExecutor() {
    return threadExecutor;
}
 
Example #5
Source File: JobStoreSupport.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public void initialize() {
    this.manage();

    ThreadExecutor executor = getThreadExecutor();
    executor.execute(ClusterManager.this);
}
 
Example #6
Source File: JobStoreSupport.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
public void initialize() {
    ThreadExecutor executor = getThreadExecutor();
    executor.execute(MisfireHandler.this);
}
 
Example #7
Source File: QuartzSchedulerResources.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Get the ThreadExecutor which runs the QuartzSchedulerThread
 */
public ThreadExecutor getThreadExecutor() {
    return threadExecutor;
}
 
Example #8
Source File: QuartzSchedulerResources.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Set the ThreadExecutor which runs the QuartzSchedulerThread
 */
public void setThreadExecutor(ThreadExecutor threadExecutor) {
    this.threadExecutor = threadExecutor;
}
 
Example #9
Source File: JobStoreSupport.java    From AsuraFramework with Apache License 2.0 4 votes vote down vote up
public void setThreadExecutor(ThreadExecutor threadExecutor) {
	this.threadExecutor = threadExecutor;
}
 
Example #10
Source File: JobStoreSupport.java    From AsuraFramework with Apache License 2.0 4 votes vote down vote up
public ThreadExecutor getThreadExecutor() {
	return threadExecutor;
}
 
Example #11
Source File: JobStoreSupport.java    From AsuraFramework with Apache License 2.0 4 votes vote down vote up
public void initialize() {
    this.manage();

    ThreadExecutor executor = getThreadExecutor();
    executor.execute(ClusterManager.this);
}
 
Example #12
Source File: JobStoreSupport.java    From AsuraFramework with Apache License 2.0 4 votes vote down vote up
public void initialize() {
    ThreadExecutor executor = getThreadExecutor();
    executor.execute(MisfireHandler.this);
}
 
Example #13
Source File: QuartzSchedulerProvider.java    From nexus-public with Eclipse Public License 1.0 4 votes vote down vote up
private Scheduler createScheduler() {
  try {
    // ensure executed threads have TCCL set
    ThreadExecutor threadExecutor = new DefaultThreadExecutor()
    {
      @Override
      public void execute(final Thread thread) {
        thread.setContextClassLoader(QuartzSchedulerProvider.class.getClassLoader());
        super.execute(thread);
      }
    };

    // create Scheduler (implicitly registers it with repository)
    DirectSchedulerFactory.getInstance().createScheduler(
        SCHEDULER_NAME,
        nodeAccess.getId(), // instance-id
        new QuartzThreadPool(threadPoolSize, threadPriority),
        threadExecutor,
        jobStore.get(),
        null, // scheduler plugin-map
        null, // rmi-registry host
        0,    // rmi-registry port
        -1,   // idle-wait time
        -1,   // db-failure retry-interval
        true, // jmx-export
        null, // custom jmx object-name, lets use the default
        1,    // max batch-size
        0L    // batch time-window
    );
    Scheduler s = DirectSchedulerFactory.getInstance().getScheduler(SCHEDULER_NAME);
    s.setJobFactory(jobFactory);

    // re-logging with version, as by default we limit quartz logging to WARN, hiding its default version logging
    log.info("Quartz Scheduler v{}", s.getMetaData().getVersion());

    s.standby();

    return s;
  }
  catch (Exception e) {
    throw new RuntimeException(e);
  }
}
 
Example #14
Source File: DirectSchedulerFactory.java    From lams with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Creates a scheduler using the specified thread pool, job store, and
 * plugins, and binds it to RMI.
 *
 * @param schedulerName
 *          The name for the scheduler.
 * @param schedulerInstanceId
 *          The instance ID for the scheduler.
 * @param threadPool
 *          The thread pool for executing jobs
 * @param threadExecutor
 *          The thread executor for executing jobs
 * @param jobStore
 *          The type of job store
 * @param schedulerPluginMap
 *          Map from a <code>String</code> plugin names to
 *          <code>{@link org.quartz.spi.SchedulerPlugin}</code>s.  Can use
 *          "null" if no plugins are required.
 * @param rmiRegistryHost
 *          The hostname to register this scheduler with for RMI. Can use
 *          "null" if no RMI is required.
 * @param rmiRegistryPort
 *          The port for RMI. Typically 1099.
 * @param idleWaitTime
 *          The idle wait time in milliseconds. You can specify "-1" for
 *          the default value, which is currently 30000 ms.
 * @throws SchedulerException
 *           if initialization failed
 */
public void createScheduler(String schedulerName,
        String schedulerInstanceId, ThreadPool threadPool,
        ThreadExecutor threadExecutor,
        JobStore jobStore, Map<String, SchedulerPlugin> schedulerPluginMap,
        String rmiRegistryHost, int rmiRegistryPort,
        long idleWaitTime, long dbFailureRetryInterval,
        boolean jmxExport, String jmxObjectName)
    throws SchedulerException {
    createScheduler(schedulerName, schedulerInstanceId, threadPool,
            DEFAULT_THREAD_EXECUTOR, jobStore, schedulerPluginMap,
            rmiRegistryHost, rmiRegistryPort, idleWaitTime,
            dbFailureRetryInterval, jmxExport, jmxObjectName, DEFAULT_BATCH_MAX_SIZE, DEFAULT_BATCH_TIME_WINDOW);
}
 
Example #15
Source File: QuartzSchedulerResources.java    From AsuraFramework with Apache License 2.0 2 votes vote down vote up
/**
 * Get the ThreadExecutor which runs the QuartzSchedulerThread
 * 
 * @return
 */
public ThreadExecutor getThreadExecutor() {
    return threadExecutor;
}
 
Example #16
Source File: QuartzSchedulerResources.java    From AsuraFramework with Apache License 2.0 2 votes vote down vote up
/**
 * Set the ThreadExecutor which runs the QuartzSchedulerThread
 *
 * @param threadExecutor
 */
public void setThreadExecutor(ThreadExecutor threadExecutor) {
    this.threadExecutor = threadExecutor;
}