本文整理匯總了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;
}
示例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;
}
示例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);
}
}