Java Code Examples for org.quartz.SchedulerConfigException

The following examples show how to use org.quartz.SchedulerConfigException. These examples are extracted from open source projects. 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
@Override
public void initialize(ClassLoadHelper loadHelper, SchedulerSignaler signaler) throws SchedulerConfigException {
  init();
  realJobStore.setInstanceId(schedInstId);
  realJobStore.setInstanceName(schedName);
  realJobStore.setTcRetryInterval(tcRetryInterval);

  if (misFireThreshold != null) {
    realJobStore.setMisfireThreshold(misFireThreshold);
  }

  if (synchWrite != null) {
    realJobStore.setSynchronousWrite(synchWrite);
  }

  if (estimatedTimeToReleaseAndAcquireTrigger != null) {
    realJobStore.setEstimatedTimeToReleaseAndAcquireTrigger(estimatedTimeToReleaseAndAcquireTrigger);
  }

  realJobStore.initialize(loadHelper, signaler);
}
 
Example 2
Source Project: lams   Source File: PlainTerracottaJobStore.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public synchronized void initialize(ClassLoadHelper loadHelper, SchedulerSignaler signaler)
    throws SchedulerConfigException {
  if (clusteredJobStore != null) { throw new IllegalStateException("already initialized"); }

  clusteredJobStore = createNewJobStoreInstance(schedName, Boolean.valueOf(synchWrite));
  clusteredJobStore.setThreadPoolSize(threadPoolSize);

  // apply deferred misfire threshold if present
  if (misfireThreshold != null) {
    clusteredJobStore.setMisfireThreshold(misfireThreshold);
    misfireThreshold = null;
  }

  if (estimatedTimeToReleaseAndAcquireTrigger != null) {
    clusteredJobStore.setEstimatedTimeToReleaseAndAcquireTrigger(estimatedTimeToReleaseAndAcquireTrigger);
    estimatedTimeToReleaseAndAcquireTrigger = null;
  }
  clusteredJobStore.setInstanceId(schedInstanceId);
  clusteredJobStore.setTcRetryInterval(tcRetryInterval);
  clusteredJobStore.initialize(loadHelper, signaler);

  // update check
  scheduleUpdateCheck();
}
 
Example 3
Source Project: lams   Source File: QuartzService.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void setJndiName(String jndiName) throws Exception {
    String oldName = this.jndiName;
    this.jndiName = jndiName;

    if (super.getState() == STARTED) {
        unbind(oldName);

        try {
            rebind();
        } catch (NamingException ne) {
            log.error("Failed to rebind Scheduler", ne);

            throw new SchedulerConfigException(
                    "Failed to rebind Scheduler - ", ne);
        }
    }
}
 
Example 4
Source Project: lams   Source File: QuartzService.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public void stopService() throws Exception {
    log.info("Stop QuartzService(" + jndiName + ")...");

    try {
        Scheduler scheduler = schedulerFactory.getScheduler();

        scheduler.shutdown();
    } catch (Exception e) {
        log.error("Failed to shutdown Scheduler", e);

        throw new SchedulerConfigException(
                "Failed to shutdown Scheduler - ", e);
    }

    unbind(jndiName);

    log.info("QuartzService(" + jndiName + ") stopped.");
}
 
Example 5
Source Project: lams   Source File: JobStoreSupport.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * @see org.quartz.spi.JobStore#schedulerStarted()
 */
public void schedulerStarted() throws SchedulerException {

    if (isClustered()) {
        clusterManagementThread = new ClusterManager();
        if(initializersLoader != null)
            clusterManagementThread.setContextClassLoader(initializersLoader);
        clusterManagementThread.initialize();
    } else {
        try {
            recoverJobs();
        } catch (SchedulerException se) {
            throw new SchedulerConfigException(
                    "Failure occured during job recovery.", se);
        }
    }

    misfireHandler = new MisfireHandler();
    if(initializersLoader != null)
        misfireHandler.setContextClassLoader(initializersLoader);
    misfireHandler.initialize();
    schedulerRunning = true;
    
    getLog().debug("JobStore background threads started (as scheduler was started).");
}
 
Example 6
Source Project: lams   Source File: JobStoreCMT.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public void initialize(ClassLoadHelper loadHelper,
        SchedulerSignaler signaler) throws SchedulerConfigException {

    if (nonManagedTxDsName == null) {
        throw new SchedulerConfigException(
            "Non-ManagedTX DataSource name not set!  " +
            "If your 'org.quartz.jobStore.dataSource' is XA, then set " + 
            "'org.quartz.jobStore.nonManagedTXDataSource' to a non-XA "+ 
            "datasource (for the same DB).  " + 
            "Otherwise, you can set them to be the same.");
    }

    if (getLockHandler() == null) {
        // If the user hasn't specified an explicit lock handler, 
        // then we *must* use DB locks with CMT...
        setUseDBLocks(true);
    }

    super.initialize(loadHelper, signaler);

    getLog().info("JobStoreCMT initialized.");
}
 
Example 7
Source Project: AsuraFramework   Source File: JobStoreSupport.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @see org.quartz.spi.JobStore#schedulerStarted()
 */
public void schedulerStarted() throws SchedulerException {

    if (isClustered()) {
        clusterManagementThread = new ClusterManager();
        if(initializersLoader != null)
        	clusterManagementThread.setContextClassLoader(initializersLoader);
        clusterManagementThread.initialize();
    } else {
        try {
            recoverJobs();
        } catch (SchedulerException se) {
            throw new SchedulerConfigException(
                    "Failure occured during job recovery.", se);
        }
    }

    misfireHandler = new MisfireHandler();
    if(initializersLoader != null)
    	misfireHandler.setContextClassLoader(initializersLoader);
    misfireHandler.initialize();
}
 
Example 8
Source Project: AsuraFramework   Source File: JobStoreCMT.java    License: Apache License 2.0 6 votes vote down vote up
public void initialize(ClassLoadHelper loadHelper,
        SchedulerSignaler signaler) throws SchedulerConfigException {

    if (nonManagedTxDsName == null) {
        throw new SchedulerConfigException(
            "Non-ManagedTX DataSource name not set!  " +
            "If your 'org.quartz.jobStore.dataSource' is XA, then set " + 
            "'org.quartz.jobStore.nonManagedTXDataSource' to a non-XA "+ 
            "datasource (for the same DB).  " + 
            "Otherwise, you can set them to be the same.");
    }

    if (getLockHandler() == null) {
        // If the user hasn't specified an explicit lock handler, 
        // then we *must* use DB locks with CMT...
        setUseDBLocks(true);
    }

    super.initialize(loadHelper, signaler);

    getLog().info("JobStoreCMT initialized.");
}
 
Example 9
Source Project: spring-analysis-note   Source File: LocalTaskExecutorThreadPool.java    License: MIT License 5 votes vote down vote up
@Override
public void initialize() throws SchedulerConfigException {
	// Absolutely needs thread-bound Executor to initialize.
	this.taskExecutor = SchedulerFactoryBean.getConfigTimeTaskExecutor();
	if (this.taskExecutor == null) {
		throw new SchedulerConfigException("No local Executor found for configuration - " +
				"'taskExecutor' property must be set on SchedulerFactoryBean");
	}
}
 
Example 10
@Override
public void initialize() throws SchedulerConfigException {
	// Absolutely needs thread-bound Executor to initialize.
	this.taskExecutor = SchedulerFactoryBean.getConfigTimeTaskExecutor();
	if (this.taskExecutor == null) {
		throw new SchedulerConfigException("No local Executor found for configuration - " +
				"'taskExecutor' property must be set on SchedulerFactoryBean");
	}
}
 
Example 11
@Override
public void initialize() throws SchedulerConfigException {
	// Absolutely needs thread-bound TaskExecutor to initialize.
	this.taskExecutor = SchedulerFactoryBean.getConfigTimeTaskExecutor();
	if (this.taskExecutor == null) {
		throw new SchedulerConfigException(
			"No local TaskExecutor found for configuration - " +
			"'taskExecutor' property must be set on SchedulerFactoryBean");
	}
}
 
Example 12
private void init() throws SchedulerConfigException {
  if (realJobStore != null) { return; }

  if ((tcConfig != null) && (tcConfigUrl != null)) {
    //
    throw new SchedulerConfigException("Both " + TC_CONFIG_PROP + " and " + TC_CONFIGURL_PROP
                                       + " are set in your properties. Please define only one of them");
  }

  if ((tcConfig == null) && (tcConfigUrl == null)) {
    //
    throw new SchedulerConfigException("Neither " + TC_CONFIG_PROP + " or " + TC_CONFIGURL_PROP
                                       + " are set in your properties. Please define one of them");
  }

  final boolean isURLConfig = tcConfig == null;
  TerracottaToolkitBuilder toolkitBuilder = new TerracottaToolkitBuilder();
  if (isURLConfig) {
    toolkitBuilder.setTCConfigUrl(tcConfigUrl);
  } else {
    toolkitBuilder.setTCConfigSnippet(tcConfig);
  }
  if (rejoin != null) {
    toolkitBuilder.setRejoin(rejoin);
  }
  toolkitBuilder.addTunnelledMBeanDomain("quartz");
  toolkit = (ToolkitInternal) toolkitBuilder.buildToolkit();

  try {
    realJobStore = getRealStore(toolkit);
  } catch (Exception e) {
    throw new SchedulerConfigException("Unable to create Terracotta client", e);
  }
}
 
Example 13
Source Project: lams   Source File: QuartzService.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void createService() throws Exception {
    log.info("Create QuartzService(" + jndiName + ")...");

    if (error) {
        log
                .error("Must specify only one of 'Properties' or 'PropertiesFile'");

        throw new Exception(
                "Must specify only one of 'Properties' or 'PropertiesFile'");
    }

    schedulerFactory = new StdSchedulerFactory();

    try {
        if (useProperties) {
            schedulerFactory.initialize(properties);
        }

        if (usePropertiesFile) {
            schedulerFactory.initialize(propertiesFile);
        }
    } catch (Exception e) {
        log.error("Failed to initialize Scheduler", e);

        throw new SchedulerConfigException(
                "Failed to initialize Scheduler - ", e);
    }

    log.info("QuartzService(" + jndiName + ") created.");
}
 
Example 14
Source Project: lams   Source File: QuartzService.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void startService() throws Exception {
    log.info("Start QuartzService(" + jndiName + ")...");

    try {
        rebind();
    } catch (NamingException ne) {
        log.error("Failed to rebind Scheduler", ne);

        throw new SchedulerConfigException("Failed to rebind Scheduler - ",
                ne);
    }

    try {
        Scheduler scheduler = schedulerFactory.getScheduler();

        if (startScheduler) {
            scheduler.start();
        } else {
            log.info("Skipping starting the scheduler (will not run jobs).");
        }
    } catch (Exception e) {
        log.error("Failed to start Scheduler", e);

        throw new SchedulerConfigException("Failed to start Scheduler - ",
                e);
    }

    log.info("QuartzService(" + jndiName + ") started.");
}
 
Example 15
Source Project: lams   Source File: JobStoreTX.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void initialize(ClassLoadHelper classLoadHelper,
        SchedulerSignaler schedSignaler) throws SchedulerConfigException {

    super.initialize(classLoadHelper, schedSignaler);

    getLog().info("JobStoreTX initialized.");
}
 
Example 16
Source Project: AsuraFramework   Source File: StdSchedulerFactory.java    License: Apache License 2.0 5 votes vote down vote up
private Class loadClass(String className) throws ClassNotFoundException, SchedulerConfigException {

        try {
            ClassLoader cl = findClassloader();
            if(cl != null)
                return cl.loadClass(className);
            throw new SchedulerConfigException("Unable to find a class loader on the current thread or class.");
        } catch (ClassNotFoundException e) {
            if(getClass().getClassLoader() != null)
                return getClass().getClassLoader().loadClass(className);
            throw e;
        }
    }
 
Example 17
@Override
public void initialize() throws SchedulerConfigException {
	// Absolutely needs thread-bound TaskExecutor to initialize.
	this.taskExecutor = SchedulerFactoryBean.getConfigTimeTaskExecutor();
	if (this.taskExecutor == null) {
		throw new SchedulerConfigException(
			"No local TaskExecutor found for configuration - " +
			"'taskExecutor' property must be set on SchedulerFactoryBean");
	}
}
 
Example 18
Source Project: nexus-public   Source File: JobStoreImpl.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void initialize(final ClassLoadHelper loadHelper, final SchedulerSignaler signaler)
    throws SchedulerConfigException
{
  log.info("Instance name: {}; ID: {}", instanceName, instanceId);

  // TODO: Should we consider using ClassLoadHelper?
  this.signaler = checkNotNull(signaler);

  log.info("Initialized");
}
 
Example 19
Source Project: micro-integrator   Source File: QuartzCachedThreadPool.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void initialize() throws SchedulerConfigException {
    this.executor = Executors.newCachedThreadPool();
}
 
Example 20
Source Project: spring-analysis-note   Source File: LocalDataSourceJobStore.java    License: MIT License 4 votes vote down vote up
@Override
public void initialize(ClassLoadHelper loadHelper, SchedulerSignaler signaler) throws SchedulerConfigException {
	// Absolutely needs thread-bound DataSource to initialize.
	this.dataSource = SchedulerFactoryBean.getConfigTimeDataSource();
	if (this.dataSource == null) {
		throw new SchedulerConfigException("No local DataSource found for configuration - " +
				"'dataSource' property must be set on SchedulerFactoryBean");
	}

	// Configure transactional connection settings for Quartz.
	setDataSource(TX_DATA_SOURCE_PREFIX + getInstanceName());
	setDontSetAutoCommitFalse(true);

	// Register transactional ConnectionProvider for Quartz.
	DBConnectionManager.getInstance().addConnectionProvider(
			TX_DATA_SOURCE_PREFIX + getInstanceName(),
			new ConnectionProvider() {
				@Override
				public Connection getConnection() throws SQLException {
					// Return a transactional Connection, if any.
					return DataSourceUtils.doGetConnection(dataSource);
				}
				@Override
				public void shutdown() {
					// Do nothing - a Spring-managed DataSource has its own lifecycle.
				}
				/* Quartz 2.2 initialize method */
				public void initialize() {
					// Do nothing - a Spring-managed DataSource has its own lifecycle.
				}
			}
	);

	// Non-transactional DataSource is optional: fall back to default
	// DataSource if not explicitly specified.
	DataSource nonTxDataSource = SchedulerFactoryBean.getConfigTimeNonTransactionalDataSource();
	final DataSource nonTxDataSourceToUse = (nonTxDataSource != null ? nonTxDataSource : this.dataSource);

	// Configure non-transactional connection settings for Quartz.
	setNonManagedTXDataSource(NON_TX_DATA_SOURCE_PREFIX + getInstanceName());

	// Register non-transactional ConnectionProvider for Quartz.
	DBConnectionManager.getInstance().addConnectionProvider(
			NON_TX_DATA_SOURCE_PREFIX + getInstanceName(),
			new ConnectionProvider() {
				@Override
				public Connection getConnection() throws SQLException {
					// Always return a non-transactional Connection.
					return nonTxDataSourceToUse.getConnection();
				}
				@Override
				public void shutdown() {
					// Do nothing - a Spring-managed DataSource has its own lifecycle.
				}
				/* Quartz 2.2 initialize method */
				public void initialize() {
					// Do nothing - a Spring-managed DataSource has its own lifecycle.
				}
			}
	);

	// No, if HSQL is the platform, we really don't want to use locks...
	try {
		String productName = JdbcUtils.extractDatabaseMetaData(this.dataSource, "getDatabaseProductName");
		productName = JdbcUtils.commonDatabaseName(productName);
		if (productName != null && productName.toLowerCase().contains("hsql")) {
			setUseDBLocks(false);
			setLockHandler(new SimpleSemaphore());
		}
	}
	catch (MetaDataAccessException ex) {
		logWarnIfNonZero(1, "Could not detect database type. Assuming locks can be taken.");
	}

	super.initialize(loadHelper, signaler);

}
 
Example 21
@Override
public void afterPropertiesSet() throws SchedulerConfigException {
	initialize();
}
 
Example 22
Source Project: java-technology-stack   Source File: LocalDataSourceJobStore.java    License: MIT License 4 votes vote down vote up
@Override
public void initialize(ClassLoadHelper loadHelper, SchedulerSignaler signaler) throws SchedulerConfigException {
	// Absolutely needs thread-bound DataSource to initialize.
	this.dataSource = SchedulerFactoryBean.getConfigTimeDataSource();
	if (this.dataSource == null) {
		throw new SchedulerConfigException("No local DataSource found for configuration - " +
				"'dataSource' property must be set on SchedulerFactoryBean");
	}

	// Configure transactional connection settings for Quartz.
	setDataSource(TX_DATA_SOURCE_PREFIX + getInstanceName());
	setDontSetAutoCommitFalse(true);

	// Register transactional ConnectionProvider for Quartz.
	DBConnectionManager.getInstance().addConnectionProvider(
			TX_DATA_SOURCE_PREFIX + getInstanceName(),
			new ConnectionProvider() {
				@Override
				public Connection getConnection() throws SQLException {
					// Return a transactional Connection, if any.
					return DataSourceUtils.doGetConnection(dataSource);
				}
				@Override
				public void shutdown() {
					// Do nothing - a Spring-managed DataSource has its own lifecycle.
				}
				/* Quartz 2.2 initialize method */
				public void initialize() {
					// Do nothing - a Spring-managed DataSource has its own lifecycle.
				}
			}
	);

	// Non-transactional DataSource is optional: fall back to default
	// DataSource if not explicitly specified.
	DataSource nonTxDataSource = SchedulerFactoryBean.getConfigTimeNonTransactionalDataSource();
	final DataSource nonTxDataSourceToUse = (nonTxDataSource != null ? nonTxDataSource : this.dataSource);

	// Configure non-transactional connection settings for Quartz.
	setNonManagedTXDataSource(NON_TX_DATA_SOURCE_PREFIX + getInstanceName());

	// Register non-transactional ConnectionProvider for Quartz.
	DBConnectionManager.getInstance().addConnectionProvider(
			NON_TX_DATA_SOURCE_PREFIX + getInstanceName(),
			new ConnectionProvider() {
				@Override
				public Connection getConnection() throws SQLException {
					// Always return a non-transactional Connection.
					return nonTxDataSourceToUse.getConnection();
				}
				@Override
				public void shutdown() {
					// Do nothing - a Spring-managed DataSource has its own lifecycle.
				}
				/* Quartz 2.2 initialize method */
				public void initialize() {
					// Do nothing - a Spring-managed DataSource has its own lifecycle.
				}
			}
	);

	// No, if HSQL is the platform, we really don't want to use locks...
	try {
		String productName = JdbcUtils.extractDatabaseMetaData(this.dataSource, "getDatabaseProductName");
		productName = JdbcUtils.commonDatabaseName(productName);
		if (productName != null && productName.toLowerCase().contains("hsql")) {
			setUseDBLocks(false);
			setLockHandler(new SimpleSemaphore());
		}
	}
	catch (MetaDataAccessException ex) {
		logWarnIfNonZero(1, "Could not detect database type. Assuming locks can be taken.");
	}

	super.initialize(loadHelper, signaler);

}
 
Example 23
@Override
public void afterPropertiesSet() throws SchedulerConfigException {
	initialize();
}
 
Example 24
Source Project: lams   Source File: LocalDataSourceJobStore.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public void initialize(ClassLoadHelper loadHelper, SchedulerSignaler signaler)
		throws SchedulerConfigException {

	// Absolutely needs thread-bound DataSource to initialize.
	this.dataSource = SchedulerFactoryBean.getConfigTimeDataSource();
	if (this.dataSource == null) {
		throw new SchedulerConfigException(
			"No local DataSource found for configuration - " +
			"'dataSource' property must be set on SchedulerFactoryBean");
	}

	// Configure transactional connection settings for Quartz.
	setDataSource(TX_DATA_SOURCE_PREFIX + getInstanceName());
	setDontSetAutoCommitFalse(true);

	// Register transactional ConnectionProvider for Quartz.
	DBConnectionManager.getInstance().addConnectionProvider(
			TX_DATA_SOURCE_PREFIX + getInstanceName(),
			new ConnectionProvider() {
				@Override
				public Connection getConnection() throws SQLException {
					// Return a transactional Connection, if any.
					return DataSourceUtils.doGetConnection(dataSource);
				}
				@Override
				public void shutdown() {
					// Do nothing - a Spring-managed DataSource has its own lifecycle.
				}
				/* Quartz 2.2 initialize method */
				public void initialize() {
					// Do nothing - a Spring-managed DataSource has its own lifecycle.
				}
			}
	);

	// Non-transactional DataSource is optional: fall back to default
	// DataSource if not explicitly specified.
	DataSource nonTxDataSource = SchedulerFactoryBean.getConfigTimeNonTransactionalDataSource();
	final DataSource nonTxDataSourceToUse = (nonTxDataSource != null ? nonTxDataSource : this.dataSource);

	// Configure non-transactional connection settings for Quartz.
	setNonManagedTXDataSource(NON_TX_DATA_SOURCE_PREFIX + getInstanceName());

	// Register non-transactional ConnectionProvider for Quartz.
	DBConnectionManager.getInstance().addConnectionProvider(
			NON_TX_DATA_SOURCE_PREFIX + getInstanceName(),
			new ConnectionProvider() {
				@Override
				public Connection getConnection() throws SQLException {
					// Always return a non-transactional Connection.
					return nonTxDataSourceToUse.getConnection();
				}
				@Override
				public void shutdown() {
					// Do nothing - a Spring-managed DataSource has its own lifecycle.
				}
				/* Quartz 2.2 initialize method */
				public void initialize() {
					// Do nothing - a Spring-managed DataSource has its own lifecycle.
				}
			}
	);

	// No, if HSQL is the platform, we really don't want to use locks...
	try {
		String productName = JdbcUtils.extractDatabaseMetaData(this.dataSource, "getDatabaseProductName").toString();
		productName = JdbcUtils.commonDatabaseName(productName);
		if (productName != null && productName.toLowerCase().contains("hsql")) {
			setUseDBLocks(false);
			setLockHandler(new SimpleSemaphore());
		}
	}
	catch (MetaDataAccessException ex) {
		logWarnIfNonZero(1, "Could not detect database type. Assuming locks can be taken.");
	}

	super.initialize(loadHelper, signaler);

}
 
Example 25
@Override
public void afterPropertiesSet() throws SchedulerConfigException {
	initialize();
}
 
Example 26
Source Project: lams   Source File: SimpleThreadPool.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void initialize() throws SchedulerConfigException {

        if(workers != null && workers.size() > 0) // already initialized...
            return;
        
        if (count <= 0) {
            throw new SchedulerConfigException(
                    "Thread count must be > 0");
        }
        if (prio <= 0 || prio > 9) {
            throw new SchedulerConfigException(
                    "Thread priority must be > 0 and <= 9");
        }

        if(isThreadsInheritGroupOfInitializingThread()) {
            threadGroup = Thread.currentThread().getThreadGroup();
        } else {
            // follow the threadGroup tree to the root thread group.
            threadGroup = Thread.currentThread().getThreadGroup();
            ThreadGroup parent = threadGroup;
            while ( !parent.getName().equals("main") ) {
                threadGroup = parent;
                parent = threadGroup.getParent();
            }
            threadGroup = new ThreadGroup(parent, schedulerInstanceName + "-SimpleThreadPool");
            if (isMakeThreadsDaemons()) {
                threadGroup.setDaemon(true);
            }
        }


        if (isThreadsInheritContextClassLoaderOfInitializingThread()) {
            getLog().info(
                    "Job execution threads will use class loader of thread: "
                            + Thread.currentThread().getName());
        }

        // create the worker threads and start them
        Iterator<WorkerThread> workerThreads = createWorkerThreads(count).iterator();
        while(workerThreads.hasNext()) {
            WorkerThread wt = workerThreads.next();
            wt.start();
            availWorkers.add(wt);
        }
    }
 
Example 27
Source Project: lams   Source File: ZeroSizeThreadPool.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void initialize() throws SchedulerConfigException {
}
 
Example 28
Source Project: lams   Source File: SimpleTimeBroker.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void initialize() throws SchedulerConfigException {
    // do nothing...
}
 
Example 29
Source Project: lams   Source File: JobStoreSupport.java    License: GNU General Public License v2.0 4 votes vote down vote up
/**
 * <p>
 * Called by the QuartzScheduler before the <code>JobStore</code> is
 * used, in order to give it a chance to initialize.
 * </p>
 */
public void initialize(ClassLoadHelper loadHelper,
        SchedulerSignaler signaler) throws SchedulerConfigException {

    if (dsName == null) { 
        throw new SchedulerConfigException("DataSource name not set."); 
    }

    classLoadHelper = loadHelper;
    if(isThreadsInheritInitializersClassLoadContext()) {
        log.info("JDBCJobStore threads will inherit ContextClassLoader of thread: " + Thread.currentThread().getName());
        initializersLoader = Thread.currentThread().getContextClassLoader();
    }
    
    this.schedSignaler = signaler;

    // If the user hasn't specified an explicit lock handler, then 
    // choose one based on CMT/Clustered/UseDBLocks.
    if (getLockHandler() == null) {
        
        // If the user hasn't specified an explicit lock handler, 
        // then we *must* use DB locks with clustering
        if (isClustered()) {
            setUseDBLocks(true);
        }
        
        if (getUseDBLocks()) {
            if(getDriverDelegateClass() != null && getDriverDelegateClass().equals(MSSQLDelegate.class.getName())) {
                if(getSelectWithLockSQL() == null) {
                    String msSqlDflt = "SELECT * FROM {0}LOCKS WITH (UPDLOCK,ROWLOCK) WHERE " + COL_SCHEDULER_NAME + " = {1} AND LOCK_NAME = ?";
                    getLog().info("Detected usage of MSSQLDelegate class - defaulting 'selectWithLockSQL' to '" + msSqlDflt + "'.");
                    setSelectWithLockSQL(msSqlDflt);
                }
            }
            getLog().info("Using db table-based data access locking (synchronization).");
            setLockHandler(new StdRowLockSemaphore(getTablePrefix(), getInstanceName(), getSelectWithLockSQL()));
        } else {
            getLog().info(
                "Using thread monitor-based data access locking (synchronization).");
            setLockHandler(new SimpleSemaphore());
        }
    }

}
 
Example 30
Source Project: AsuraFramework   Source File: SimpleThreadPool.java    License: Apache License 2.0 4 votes vote down vote up
public void initialize() throws SchedulerConfigException {

        if(workers != null && workers.size() > 0) // already initialized...
            return;
        
        if (count <= 0) {
            throw new SchedulerConfigException(
                    "Thread count must be > 0");
        }
        if (prio <= 0 || prio > 9) {
            throw new SchedulerConfigException(
                    "Thread priority must be > 0 and <= 9");
        }

        if(isThreadsInheritGroupOfInitializingThread()) {
            threadGroup = Thread.currentThread().getThreadGroup();
        } else {
            // follow the threadGroup tree to the root thread group.
            threadGroup = Thread.currentThread().getThreadGroup();
            ThreadGroup parent = threadGroup;
            while ( !parent.getName().equals("main") ) {
                threadGroup = parent;
                parent = threadGroup.getParent();
            }
            threadGroup = new ThreadGroup(parent, schedulerInstanceName + "-SimpleThreadPool");
            if (isMakeThreadsDaemons()) {
                threadGroup.setDaemon(true);
            }
        }


        if (isThreadsInheritContextClassLoaderOfInitializingThread()) {
            getLog().info(
                    "Job execution threads will use class loader of thread: "
                            + Thread.currentThread().getName());
        }

        // create the worker threads and start them
        Iterator workerThreads = createWorkerThreads(count).iterator();
        while(workerThreads.hasNext()) {
            WorkerThread wt = (WorkerThread) workerThreads.next();
            wt.start();
            availWorkers.add(wt);
        }
    }