當前位置: 首頁>>代碼示例>>Java>>正文


Java GenericObjectPool.setNumTestsPerEvictionRun方法代碼示例

本文整理匯總了Java中org.apache.commons.pool2.impl.GenericObjectPool.setNumTestsPerEvictionRun方法的典型用法代碼示例。如果您正苦於以下問題:Java GenericObjectPool.setNumTestsPerEvictionRun方法的具體用法?Java GenericObjectPool.setNumTestsPerEvictionRun怎麽用?Java GenericObjectPool.setNumTestsPerEvictionRun使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.pool2.impl.GenericObjectPool的用法示例。


在下文中一共展示了GenericObjectPool.setNumTestsPerEvictionRun方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createConnectionPool

import org.apache.commons.pool2.impl.GenericObjectPool; //導入方法依賴的package包/類
/**
 * Creates a connection pool for this datasource.  This method only exists
 * so subclasses can replace the implementation class.
 *
 * This implementation configures all pool properties other than
 * timeBetweenEvictionRunsMillis.  Setting that property is deferred to
 * {@link #startPoolMaintenance()}, since setting timeBetweenEvictionRunsMillis
 * to a positive value causes {@link GenericObjectPool}'s eviction timer
 * to be started.
 */
protected void createConnectionPool(final PoolableConnectionFactory factory) {
    // Create an object pool to contain our active connections
    final GenericObjectPoolConfig config = new GenericObjectPoolConfig();
    updateJmxName(config);
    config.setJmxEnabled(registeredJmxObjectName != null);  // Disable JMX on the underlying pool if the DS is not registered.
    final GenericObjectPool<PoolableConnection> gop = createObjectPool(factory, config, abandonedConfig);
    gop.setMaxTotal(maxTotal);
    gop.setMaxIdle(maxIdle);
    gop.setMinIdle(minIdle);
    gop.setMaxWaitMillis(maxWaitMillis);
    gop.setTestOnCreate(testOnCreate);
    gop.setTestOnBorrow(testOnBorrow);
    gop.setTestOnReturn(testOnReturn);
    gop.setNumTestsPerEvictionRun(numTestsPerEvictionRun);
    gop.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
    gop.setSoftMinEvictableIdleTimeMillis(softMinEvictableIdleTimeMillis);
    gop.setTestWhileIdle(testWhileIdle);
    gop.setLifo(lifo);
    gop.setSwallowedExceptionListener(new SwallowedExceptionLogger(log, logExpiredConnections));
    gop.setEvictionPolicyClassName(evictionPolicyClassName);
    factory.setPool(gop);
    connectionPool = gop;
}
 
開發者ID:apache,項目名稱:commons-dbcp,代碼行數:34,代碼來源:BasicDataSource.java

示例2: createProcessPool

import org.apache.commons.pool2.impl.GenericObjectPool; //導入方法依賴的package包/類
private GenericObjectPool<PhantomJSProcess> createProcessPool(JRPropertiesUtil properties)
{
	ProcessFactory processFactory = new ProcessFactory(this, properties);
	GenericObjectPool<PhantomJSProcess> pool = new GenericObjectPool<>(processFactory);
	pool.setLifo(true);
	
	int maxProcessCount = properties.getIntegerProperty(PhantomJS.PROPERTY_PHANTOMJS_MAX_PROCESS_COUNT, 
			PhantomJS.DEFAULT_PHANTOMJS_MAX_PROCESS_COUNT);
	pool.setMaxTotal(maxProcessCount);
	pool.setMaxIdle(maxProcessCount);
	
	int borrowTimeout = properties.getIntegerProperty(PhantomJS.PROPERTY_PHANTOMJS_POOL_BORROW_TIMEOUT, 
			PhantomJS.DEFAULT_PHANTOMJS_POOL_BORROW_TIMEOUT);
	pool.setMaxWaitMillis(borrowTimeout);
	
	int idleTimeout = properties.getIntegerProperty(PhantomJS.PROPERTY_PHANTOMJS_IDLE_TIMEOUT, 
			PhantomJS.DEFAULT_PHANTOMJS_IDLE_TIMEOUT);
	pool.setMinEvictableIdleTimeMillis(idleTimeout);
	
	pool.setTimeBetweenEvictionRunsMillis(idlePingInterval);
	
	pool.setTestWhileIdle(true);
	pool.setNumTestsPerEvictionRun(Integer.MAX_VALUE);
	
	pool.setSwallowedExceptionListener(new SwallowedExceptionListener()
	{
		@Override
		public void onSwallowException(Exception e)
		{
			if (log.isDebugEnabled())
			{
				log.debug("Pool exception", e);
			}
		}
	});
	
	return pool;
}
 
開發者ID:TIBCOSoftware,項目名稱:jasperreports,代碼行數:39,代碼來源:ProcessDirector.java

示例3: registerPool

import org.apache.commons.pool2.impl.GenericObjectPool; //導入方法依賴的package包/類
private synchronized void registerPool(final String username, final String password)
        throws NamingException, SQLException {

    final ConnectionPoolDataSource cpds = testCPDS(username, password);

    // Set up the factory we will use (passing the pool associates
    // the factory with the pool, so we do not have to do so
    // explicitly)
    final CPDSConnectionFactory factory = new CPDSConnectionFactory(cpds,
            getValidationQuery(), getValidationQueryTimeout(),
            isRollbackAfterValidation(), username, password);
    factory.setMaxConnLifetimeMillis(getMaxConnLifetimeMillis());

    // Create an object pool to contain our PooledConnections
    final GenericObjectPool<PooledConnectionAndInfo> pool =
            new GenericObjectPool<>(factory);
    factory.setPool(pool);
    pool.setBlockWhenExhausted(getPerUserBlockWhenExhausted(username));
    pool.setEvictionPolicyClassName(
            getPerUserEvictionPolicyClassName(username));
    pool.setLifo(getPerUserLifo(username));
    pool.setMaxIdle(getPerUserMaxIdle(username));
    pool.setMaxTotal(getPerUserMaxTotal(username));
    pool.setMaxWaitMillis(getPerUserMaxWaitMillis(username));
    pool.setMinEvictableIdleTimeMillis(
            getPerUserMinEvictableIdleTimeMillis(username));
    pool.setMinIdle(getPerUserMinIdle(username));
    pool.setNumTestsPerEvictionRun(
            getPerUserNumTestsPerEvictionRun(username));
    pool.setSoftMinEvictableIdleTimeMillis(
            getPerUserSoftMinEvictableIdleTimeMillis(username));
    pool.setTestOnCreate(getPerUserTestOnCreate(username));
    pool.setTestOnBorrow(getPerUserTestOnBorrow(username));
    pool.setTestOnReturn(getPerUserTestOnReturn(username));
    pool.setTestWhileIdle(getPerUserTestWhileIdle(username));
    pool.setTimeBetweenEvictionRunsMillis(
            getPerUserTimeBetweenEvictionRunsMillis(username));

    pool.setSwallowedExceptionListener(new SwallowedExceptionLogger(log));

    final Object old = managers.put(getPoolKey(username), factory);
    if (old != null) {
        throw new IllegalStateException("Pool already contains an entry for this user/password: " + username);
    }
}
 
開發者ID:apache,項目名稱:commons-dbcp,代碼行數:46,代碼來源:PerUserPoolDataSource.java


注:本文中的org.apache.commons.pool2.impl.GenericObjectPool.setNumTestsPerEvictionRun方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。