本文整理汇总了Java中org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig.setMinEvictableIdleTimeMillis方法的典型用法代码示例。如果您正苦于以下问题:Java GenericKeyedObjectPoolConfig.setMinEvictableIdleTimeMillis方法的具体用法?Java GenericKeyedObjectPoolConfig.setMinEvictableIdleTimeMillis怎么用?Java GenericKeyedObjectPoolConfig.setMinEvictableIdleTimeMillis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig
的用法示例。
在下文中一共展示了GenericKeyedObjectPoolConfig.setMinEvictableIdleTimeMillis方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入方法依赖的package包/类
@Before
public void init() throws InterruptedException {
this.appKey = "proxytest" + NumUtil.nextNum();
ServiceFactoryTest serviceFactoryTest = new ServiceFactoryTest();
ServerArgs serverArgs = serviceFactoryTest.getServerArgs(this.appKey, "127.0.0.1", NumUtil.nextPort());
ZkRegistry zkRegistry = serviceFactoryTest.getZkRegistry();
serverArgs.setRegistrys(ImmutableList.of(zkRegistry));
ThriftServerPublisher publisher = new ThriftServerPublisher(serverArgs);
Thread thread = new Thread(publisher::init);
thread.setDaemon(true);
thread.start();
TimeUnit.MILLISECONDS.sleep(400);
poolConfig = new GenericKeyedObjectPoolConfig();
poolConfig.setMaxTotal(MAX_CONN);
poolConfig.setMaxTotalPerKey(MAX_CONN);
poolConfig.setMaxIdlePerKey(MAX_CONN);
poolConfig.setMinIdlePerKey(MIN_CONN);
poolConfig.setTestOnBorrow(true);
poolConfig.setMinEvictableIdleTimeMillis(MINUTES.toMillis(1));
poolConfig.setSoftMinEvictableIdleTimeMillis(MINUTES.toMillis(1));
poolConfig.setJmxEnabled(false);
}
示例2: init
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入方法依赖的package包/类
@Before
public void init() throws InterruptedException {
ServiceFactoryTest serviceFactoryTest = new ServiceFactoryTest();
ServerArgs serverArgs = serviceFactoryTest.getServerArgs(appKey, "127.0.0.1", port);
ThriftServerPublisher publisher = new ThriftServerPublisher(serverArgs);
Thread thread = new Thread(publisher::init);
thread.setDaemon(true);
thread.start();
TimeUnit.MILLISECONDS.sleep(400);
poolConfig = new GenericKeyedObjectPoolConfig();
poolConfig.setMaxTotal(MAX_CONN);
poolConfig.setMaxTotalPerKey(MAX_CONN);
poolConfig.setMaxIdlePerKey(MAX_CONN);
poolConfig.setMinIdlePerKey(MIN_CONN);
poolConfig.setTestOnBorrow(true);
poolConfig.setMinEvictableIdleTimeMillis(MINUTES.toMillis(1));
poolConfig.setSoftMinEvictableIdleTimeMillis(MINUTES.toMillis(1));
poolConfig.setJmxEnabled(false);
}
示例3: initializeAPNSConnectionPool
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入方法依赖的package包/类
public void initializeAPNSConnectionPool() {
MMXConfiguration configuration = MMXConfiguration.getConfiguration();
int maxObjectsPerKey = configuration.getInt(MMXConfigKeys.APNS_POOL_MAX_CONNECTIONS_PER_APP, MMXServerConstants.APNS_POOL_MAX_CONNECTIONS_PER_APP);
int maxIdleObjectsPerKey = configuration.getInt(MMXConfigKeys.APNS_POOL_MAX_IDLE_CONNECTIONS_PER_APP, MMXServerConstants.APNS_POOL_MAX_IDLE_CONNECTIONS_PER_APP);
int ttlForIdleObjectsInMinutes = configuration.getInt(MMXConfigKeys.APNS_POOL_IDLE_TTL_MINUTES, MMXServerConstants.APNS_POOL_IDLE_TTL_MINUTES);
int maxTotal = configuration.getInt(MMXConfigKeys.APNS_POOL_MAX_TOTAL_CONNECTIONS, MMXServerConstants.APNS_POOL_MAX_TOTAL_CONNECTIONS);
Log.info("Configuring APNS Connection pool with following values: maxObjects:{}, maxObjectsPerKey:{}, " +
"maxIdleObjectsPerKey:{}, ttlForIdleObjectsInMinutes:{}", maxTotal, maxObjectsPerKey, maxIdleObjectsPerKey, ttlForIdleObjectsInMinutes);
GenericKeyedObjectPoolConfig config = new GenericKeyedObjectPoolConfig();
config.setMaxTotalPerKey(maxObjectsPerKey);
config.setMaxTotal(maxTotal);
config.setMaxIdlePerKey(maxIdleObjectsPerKey);
config.setMinEvictableIdleTimeMillis(ttlForIdleObjectsInMinutes * 60 * 1000L);
APNSConnectionPoolImpl.initialize(config);
}
示例4: getColorSpacePoolConfig
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入方法依赖的package包/类
public GenericKeyedObjectPoolConfig getColorSpacePoolConfig() {
GenericKeyedObjectPoolConfig result = new GenericKeyedObjectPoolConfig();
if (colorSpacePoolMaxTotal != null) {
result.setMaxTotal(colorSpacePoolMaxTotal);
}
if (colorSpacePoolMaxPerKey != null) {
result.setMaxTotalPerKey(colorSpacePoolMaxPerKey);
}
if (colorSpacePoolMaxIdlePerKey != null) {
result.setMaxIdlePerKey(colorSpacePoolMaxIdlePerKey);
}
if (colorSpacePoolMinIdlePerKey != null) {
result.setMinIdlePerKey(colorSpacePoolMinIdlePerKey);
}
if (colorSpacePoolMaxWait != null) {
result.setMaxWaitMillis(colorSpacePoolMaxWait);
}
if (colorSpacePoolMinEvictableIdleTime != null) {
result.setMinEvictableIdleTimeMillis(colorSpacePoolMinEvictableIdleTime);
}
if (colorSpacePoolSoftMinEvictableIdleTime != null) {
result.setSoftMinEvictableIdleTimeMillis(colorSpacePoolSoftMinEvictableIdleTime);
}
if (colorSpacePoolTimeBetweenEvictionRuns != null) {
result.setTimeBetweenEvictionRunsMillis(colorSpacePoolTimeBetweenEvictionRuns);
}
if (colorSpacePoolBlockWhenExhausted != null) {
result.setBlockWhenExhausted(colorSpacePoolBlockWhenExhausted);
}
return result;
}
示例5: init
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入方法依赖的package包/类
@Before
public void init() {
this.port = RandomUtils.nextInt(10000, 20000);
new DemoServer().startDaemon(this.port);
config = new GenericKeyedObjectPoolConfig();
config.setMaxTotal(MAX_CONN);
config.setMaxTotalPerKey(MAX_CONN);
config.setMaxIdlePerKey(MAX_CONN);
config.setMinIdlePerKey(MIN_CONN);
config.setTestOnBorrow(true);
config.setMinEvictableIdleTimeMillis(MINUTES.toMillis(1));
config.setSoftMinEvictableIdleTimeMillis(MINUTES.toMillis(1));
config.setJmxEnabled(false);
}
示例6: setUp
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入方法依赖的package包/类
@BeforeClass
public static void setUp() throws Exception {
LOGGER.info("Setting up the pool");
GenericKeyedObjectPoolConfig config = new GenericKeyedObjectPoolConfig();
config.setMaxTotalPerKey(MAX_OBJECTS_PER_KEY);
config.setMaxIdlePerKey(3);
config.setMinEvictableIdleTimeMillis(10*60*1000L);
config.setTimeBetweenEvictionRunsMillis(1000L);
objectFactory = new StubAPNSConnectionKeyedPooledObjectFactory(appWithBadCert);
APNSConnectionPoolImpl.initialize(objectFactory, config);
}
示例7: registerPool
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入方法依赖的package包/类
private void registerPool(final String username, final String password)
throws NamingException, SQLException {
final ConnectionPoolDataSource cpds = testCPDS(username, password);
// Create an object pool to contain our PooledConnections
factory = new KeyedCPDSConnectionFactory(cpds, getValidationQuery(),
getValidationQueryTimeout(), isRollbackAfterValidation());
factory.setMaxConnLifetimeMillis(getMaxConnLifetimeMillis());
final GenericKeyedObjectPoolConfig config =
new GenericKeyedObjectPoolConfig();
config.setBlockWhenExhausted(getDefaultBlockWhenExhausted());
config.setEvictionPolicyClassName(getDefaultEvictionPolicyClassName());
config.setLifo(getDefaultLifo());
config.setMaxIdlePerKey(getDefaultMaxIdle());
config.setMaxTotal(getMaxTotal());
config.setMaxTotalPerKey(getDefaultMaxTotal());
config.setMaxWaitMillis(getDefaultMaxWaitMillis());
config.setMinEvictableIdleTimeMillis(
getDefaultMinEvictableIdleTimeMillis());
config.setMinIdlePerKey(getDefaultMinIdle());
config.setNumTestsPerEvictionRun(getDefaultNumTestsPerEvictionRun());
config.setSoftMinEvictableIdleTimeMillis(
getDefaultSoftMinEvictableIdleTimeMillis());
config.setTestOnCreate(getDefaultTestOnCreate());
config.setTestOnBorrow(getDefaultTestOnBorrow());
config.setTestOnReturn(getDefaultTestOnReturn());
config.setTestWhileIdle(getDefaultTestWhileIdle());
config.setTimeBetweenEvictionRunsMillis(
getDefaultTimeBetweenEvictionRunsMillis());
final KeyedObjectPool<UserPassKey,PooledConnectionAndInfo> tmpPool =
new GenericKeyedObjectPool<>(factory, config);
factory.setPool(tmpPool);
pool = tmpPool;
}
示例8: getConfig
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入方法依赖的package包/类
private GenericKeyedObjectPoolConfig getConfig(PoolConfig poolConfig) {
GenericKeyedObjectPoolConfig objectPoolConfig = new GenericKeyedObjectPoolConfig();
objectPoolConfig.setMaxTotalPerKey(poolConfig.getMaxTotalPerKey());
objectPoolConfig.setMaxTotal(poolConfig.getMaxTotal());
objectPoolConfig.setMaxIdlePerKey(poolConfig.getMaxIdlePerKey());
objectPoolConfig.setMinIdlePerKey(poolConfig.getMinIdlePerKey());
objectPoolConfig.setTestWhileIdle(poolConfig.isTestWhileIdle());
objectPoolConfig.setTestOnReturn(poolConfig.isTestOnReturn());
objectPoolConfig.setTestOnCreate(poolConfig.isTestOnCreate());
objectPoolConfig.setTestOnBorrow(poolConfig.isTestOnBorrow());
objectPoolConfig.setTimeBetweenEvictionRunsMillis(poolConfig.getTimeBetweenEvictionRunsMillis());
objectPoolConfig.setEvictionPolicyClassName(poolConfig.getEvictionPolicyClassName());
objectPoolConfig.setMinEvictableIdleTimeMillis(poolConfig.getMinEvictableIdleTimeMillis());
objectPoolConfig.setNumTestsPerEvictionRun(poolConfig.getNumTestsPerEvictionRun());
objectPoolConfig.setSoftMinEvictableIdleTimeMillis(poolConfig.getSoftMinEvictableIdleTimeMillis());
objectPoolConfig.setJmxEnabled(poolConfig.isJmxEnabled());
objectPoolConfig.setJmxNameBase(poolConfig.getJmxNameBase());
objectPoolConfig.setJmxNamePrefix(poolConfig.getJmxNamePrefix());
objectPoolConfig.setMaxWaitMillis(poolConfig.getMaxWaitMillis());
objectPoolConfig.setFairness(poolConfig.isFairness());
objectPoolConfig.setBlockWhenExhausted(poolConfig.isBlockWhenExhausted());
objectPoolConfig.setLifo(poolConfig.isLifo());
return objectPoolConfig;
}
示例9: initTrackerConfig
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入方法依赖的package包/类
private void initTrackerConfig(Config cf) {
GenericKeyedObjectPoolConfig pc = new GenericKeyedObjectPoolConfig();
pc.setLifo(cf.getBooleanValue("pool.tracker.lifo", true));
pc.setMaxTotalPerKey(cf.getIntValue("pool.tracker.maxTotal", 10));
pc.setMinIdlePerKey(cf.getIntValue("pool.tracker.minIdle", 2));
pc.setMaxIdlePerKey(cf.getIntValue("pool.tracker.maxIdle", 4));
pc.setMaxWaitMillis(cf.getIntValue("pool.tracker.maxWaitMillis", 10 * 1000));
pc.setSoftMinEvictableIdleTimeMillis(cf.getIntValue("pool.tracker.softMinEvictableIdleTimeMillis",
1000 * 60 * 2));
pc.setTestWhileIdle(cf.getBooleanValue("pool.tracker.testWhileIdle", true));
pc.setTimeBetweenEvictionRunsMillis(cf.getIntValue("pool.tracker.timeBetweenEvictionRunsMillis", 1000 * 12));
pc.setMinEvictableIdleTimeMillis(cf.getIntValue("pool.tracker.minEvictableIdleTimeMillis", 1000 * 60 * 5));
trackerServers = new FdfsKeyedObjectPool<PooledTrackerServer>(new PooledServerFactory<PooledTrackerServer>() {
@Override
public PooledTrackerServer create(InetSocketAddress address) throws IOException {
PooledTrackerServer srv = new PooledTrackerServer(address);
if (log.isDebugEnabled()) {
log.debug(String.format("create tracker server:%s address:%X", address.toString(), srv.hashCode()));
}
return srv;
}
}, pc);
}
示例10: initStorageConfig
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入方法依赖的package包/类
private void initStorageConfig(Config cf) {
GenericKeyedObjectPoolConfig pc = new GenericKeyedObjectPoolConfig();
pc.setLifo(cf.getBooleanValue("pool.storage.lifo", true));
pc.setMaxTotalPerKey(cf.getIntValue("pool.storage.maxTotal", 20));
pc.setMinIdlePerKey(cf.getIntValue("pool.storage.minIdle", 2));
pc.setMaxIdlePerKey(cf.getIntValue("pool.storage.maxIdle", 8));
pc.setMaxWaitMillis(cf.getIntValue("pool.storage.maxWaitMillis", 10 * 1000));
pc.setSoftMinEvictableIdleTimeMillis(cf.getIntValue("pool.storage.softMinEvictableIdleTimeMillis",
1000 * 60 * 2));
pc.setTestWhileIdle(cf.getBooleanValue("pool.storage.testWhileIdle", true));
pc.setTimeBetweenEvictionRunsMillis(cf.getIntValue("pool.storage.timeBetweenEvictionRunsMillis", 1000 * 12));
pc.setMinEvictableIdleTimeMillis(cf.getIntValue("pool.storage.minEvictableIdleTimeMillis", 1000 * 60 * 3));
storageServers = new FdfsKeyedObjectPool<PooledStorageServer>(new PooledServerFactory<PooledStorageServer>() {
@Override
public PooledStorageServer create(InetSocketAddress address) throws IOException {
PooledStorageServer srv = new PooledStorageServer(address, 0);
if (log.isDebugEnabled()) {
log.debug(String.format("create storge server:%s address:%X", address.toString(), srv.hashCode()));
}
return srv;
}
}, pc);
}
示例11: ThriftConnectionPool
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入方法依赖的package包/类
public ThriftConnectionPool(Class<T> cls, ThriftPoolConfig cfg,ThriftConnectionFactory connectionFactory) {
this.clientClass = cls;
this.cfg = cfg;
poolConfig = new GenericKeyedObjectPoolConfig();
poolConfig.setLifo(cfg.getBoolean("thrift.pool.lifo", false));
poolConfig.setMaxTotal(cfg.getInt("thrift.pool.maxActive", 10));
poolConfig.setMaxIdlePerKey(cfg.getInt("thrift.pool.maxIdlePerKey", 3));
poolConfig.setMinIdlePerKey(cfg.getInt("thrift.pool.minIdlePerKey", 0));
poolConfig.setMaxTotalPerKey(cfg.getInt("thrift.pool.maxTotalPerKey", 10));
/**
set the maximum amount of time (in milliseconds) the
<code>borrowObject()</code> method should block before throwing an
exception when the pool is exhausted and {@link #getBlockWhenExhausted} is true.
When less than 0, the <code>borrowObject()</code> method may block indefinitely.
*/
poolConfig.setMaxWaitMillis(cfg.getInt("thrift.pool.maxWait",20 * 1000));
/**
Sets whether to block when the <code>borrowObject()</code> method is
invoked when the pool is exhausted (the maximum number of "active"
objects has been reached).
*/
poolConfig.setBlockWhenExhausted(true);
/**为了提升性能 关闭testOnBorrow**/
poolConfig.setTestOnBorrow(false);
poolConfig.setTestWhileIdle(true);
this.loop = cfg.getBoolean("thrift.pool.get.loop",false);
// 开启一个线程执行扫描检测connection
poolConfig.setTimeBetweenEvictionRunsMillis(cfg.getInt("thrift.pool.timeBetweenEvictionRunsMillis",3*60*1000));
poolConfig.setMinEvictableIdleTimeMillis(cfg.getInt("thrift.pool.minEvictableIdleTimeMillis",5*60*1000));
poolConfig.setNumTestsPerEvictionRun(cfg.getInt("thrift.pool.numTestsPerEvictionRun",3));
this.factory = connectionFactory;
this.factory.setPool(this);
mPool = new GenericKeyedObjectPool<>(factory, poolConfig);
}
示例12: initTask
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入方法依赖的package包/类
@Override
public void initTask() {
super.initTask();
stageClassLoaders = runtimeInfo.getStageLibraryClassLoaders();
if (!stageClassLoaders.isEmpty()) {
resolveClassLoaderMethods(stageClassLoaders.get(0));
}
if(configuration.get(CONFIG_CP_VALIDATION, DEFAULT_CP_VALIDATION)) {
validateStageClasspaths();
}
// Load all stages and other objects from the libraries
json = ObjectMapperFactory.get();
stageList = new ArrayList<>();
stageMap = new HashMap<>();
lineagePublisherDefinitions = new ArrayList<>();
lineagePublisherDefinitionMap = new HashMap<>();
credentialStoreDefinitions = new ArrayList<>();
serviceList = new ArrayList<>();
serviceMap = new HashMap<>();
loadStages();
stageList = ImmutableList.copyOf(stageList);
stageMap = ImmutableMap.copyOf(stageMap);
lineagePublisherDefinitions = ImmutableList.copyOf(lineagePublisherDefinitions);
lineagePublisherDefinitionMap = ImmutableMap.copyOf(lineagePublisherDefinitionMap);
credentialStoreDefinitions = ImmutableList.copyOf(credentialStoreDefinitions);
serviceList = ImmutableList.copyOf(serviceList);
serviceMap = ImmutableMap.copyOf(serviceMap);
// Various validations
validateAllServicesAvailable();
// localization cache for definitions
localizedStageList = CacheBuilder.newBuilder().build(new CacheLoader<Locale, List<StageDefinition>>() {
@Override
public List<StageDefinition> load(Locale key) throws Exception {
List<StageDefinition> list = new ArrayList<>();
for (StageDefinition stage : stageList) {
list.add(stage.localize());
}
return list;
}
});
validateStageVersions(stageList);
validateServices(stageList, serviceList);
// initializing the list of targets that can be used for error handling
ErrorHandlingChooserValues.setErrorHandlingOptions(this);
// initializing the list of targets that can be used as aggregating sink
StatsTargetChooserValues.setStatsTargetOptions(this);
// initializing the list of targets that can be used for pipeline lifecycle events
PipelineLifecycleStageChooserValues.setHandlingOptions(this);
// initializing the pool of private stage classloaders
GenericKeyedObjectPoolConfig poolConfig = new GenericKeyedObjectPoolConfig();
poolConfig.setJmxEnabled(false);
poolConfig.setMaxTotal(configuration.get(MAX_PRIVATE_STAGE_CLASS_LOADERS_KEY,
MAX_PRIVATE_STAGE_CLASS_LOADERS_DEFAULT));
poolConfig.setMinEvictableIdleTimeMillis(-1);
poolConfig.setNumTestsPerEvictionRun(0);
poolConfig.setMaxIdlePerKey(-1);
poolConfig.setMinIdlePerKey(0);
poolConfig.setMaxTotalPerKey(-1);
poolConfig.setBlockWhenExhausted(false);
poolConfig.setMaxWaitMillis(0);
privateClassLoaderPool = new GenericKeyedObjectPool<>(new ClassLoaderFactory(stageClassLoaders), poolConfig);
}
示例13: JSchClient
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入方法依赖的package包/类
public JSchClient(final Settings componentSettings,
final RepositorySettings repositorySettings,
final ThreadPool threadPool) throws JSchException {
SshConfig config = new SshConfig();
config.setHost(repositorySettings.settings().get("host", componentSettings.get("host")));
config.setPort(
repositorySettings.settings().getAsInt("port", componentSettings.getAsInt("port", 22)));
config.setUsername(
repositorySettings.settings().get("username", componentSettings.get("username")));
config.setPassword(
repositorySettings.settings().get("password", componentSettings.get("password")));
config.setLocation(
repositorySettings.settings().get("location", componentSettings.get("location", "~/")));
config.setPrivateKey(
repositorySettings.settings().get("private_key", componentSettings.get("private_key")));
config.setPassphrase(
repositorySettings.settings().get("passphrase", componentSettings.get("passphrase")));
config.setKnownHosts(
repositorySettings.settings().get("known_hosts", componentSettings.get("known_hosts")));
config.setIgnoreHostKeyChecking(repositorySettings.settings()
.getAsBoolean("ignore_host_key",
componentSettings.getAsBoolean("ignore_host_key", false)));
if (config.getPassword() == null && config.getPrivateKey() == null) {
throw new JSchException(
"A password and private key for SSH are empty.");
}
this.config = config;
GenericKeyedObjectPoolConfig poolConfig = new GenericKeyedObjectPoolConfig();
poolConfig.setMaxTotalPerKey(5);
poolConfig.setMinEvictableIdleTimeMillis(repositorySettings.settings()
.getAsLong("session_expire", componentSettings.getAsLong("session_expire", 60000L)));
TimeValue cleanInterval = repositorySettings.settings().getAsTime("clean_interval",
componentSettings.getAsTime("clean_interval", TimeValue.timeValueMinutes(1)));
poolConfig.setJmxEnabled(false);
poolConfig.setTimeBetweenEvictionRunsMillis(cleanInterval.getMillis());
this.sshPool = new SshPool(config, poolConfig);
}
示例14: getPooledConnection
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig; //导入方法依赖的package包/类
/**
* Attempt to establish a database connection.
* @param username name to be used for the connection
* @param pass password to be used fur the connection
*/
@Override
public PooledConnection getPooledConnection(final String username, final String pass)
throws SQLException {
getConnectionCalled = true;
PooledConnectionImpl pci = null;
// Workaround for buggy WebLogic 5.1 classloader - ignore the
// exception upon first invocation.
try {
if (connectionProperties != null) {
connectionProperties.put("user", username);
connectionProperties.put("password", pass);
pci = new PooledConnectionImpl(DriverManager.getConnection(
getUrl(), connectionProperties));
} else {
pci = new PooledConnectionImpl(DriverManager.getConnection(
getUrl(), username, pass));
}
pci.setAccessToUnderlyingConnectionAllowed(isAccessToUnderlyingConnectionAllowed());
}
catch (final ClassCircularityError e)
{
if (connectionProperties != null) {
pci = new PooledConnectionImpl(DriverManager.getConnection(
getUrl(), connectionProperties));
} else {
pci = new PooledConnectionImpl(DriverManager.getConnection(
getUrl(), username, pass));
}
pci.setAccessToUnderlyingConnectionAllowed(isAccessToUnderlyingConnectionAllowed());
}
KeyedObjectPool<PStmtKeyCPDS, PoolablePreparedStatement<PStmtKeyCPDS>> stmtPool = null;
if (isPoolPreparedStatements()) {
final GenericKeyedObjectPoolConfig config = new GenericKeyedObjectPoolConfig();
config.setMaxTotalPerKey(Integer.MAX_VALUE);
config.setBlockWhenExhausted(false);
config.setMaxWaitMillis(0);
config.setMaxIdlePerKey(getMaxIdle());
if (getMaxPreparedStatements() <= 0)
{
// since there is no limit, create a prepared statement pool with an eviction thread
// evictor settings are the same as the connection pool settings.
config.setTimeBetweenEvictionRunsMillis(getTimeBetweenEvictionRunsMillis());
config.setNumTestsPerEvictionRun(getNumTestsPerEvictionRun());
config.setMinEvictableIdleTimeMillis(getMinEvictableIdleTimeMillis());
}
else
{
// since there is limit, create a prepared statement pool without an eviction thread
// pool has LRU functionality so when the limit is reached, 15% of the pool is cleared.
// see org.apache.commons.pool2.impl.GenericKeyedObjectPool.clearOldest method
config.setMaxTotal(getMaxPreparedStatements());
config.setTimeBetweenEvictionRunsMillis(-1);
config.setNumTestsPerEvictionRun(0);
config.setMinEvictableIdleTimeMillis(0);
}
stmtPool = new GenericKeyedObjectPool<>(pci, config);
pci.setStatementPool(stmtPool);
}
return pci;
}