本文整理汇总了Java中org.apache.commons.pool2.impl.AbandonedConfig.setRemoveAbandonedOnMaintenance方法的典型用法代码示例。如果您正苦于以下问题:Java AbandonedConfig.setRemoveAbandonedOnMaintenance方法的具体用法?Java AbandonedConfig.setRemoveAbandonedOnMaintenance怎么用?Java AbandonedConfig.setRemoveAbandonedOnMaintenance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.pool2.impl.AbandonedConfig
的用法示例。
在下文中一共展示了AbandonedConfig.setRemoveAbandonedOnMaintenance方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAbandonedConfig
import org.apache.commons.pool2.impl.AbandonedConfig; //导入方法依赖的package包/类
public AbandonedConfig getAbandonedConfig() {
AbandonedConfig abandonedConfig = new AbandonedConfig();
abandonedConfig.setRemoveAbandonedOnBorrow(this.removeAbandonedOnBorrow);
abandonedConfig.setRemoveAbandonedTimeout(this.removeAbandonedTimeout);
abandonedConfig.setRemoveAbandonedOnMaintenance(this.removeAbandonedOnMaintenance);
return abandonedConfig;
}
示例2: JedisPool
import org.apache.commons.pool2.impl.AbandonedConfig; //导入方法依赖的package包/类
public JedisPool(final JedisPoolConfig poolConfig, final String host, final int port, final int timeout, String password) {
super(poolConfig, host, port, timeout, formatPassword(password));
this.initRedisConnectionListener(poolConfig, host, port, timeout);
AbandonedConfig abandonedConfig = new AbandonedConfig();
abandonedConfig.setRemoveAbandonedTimeout(10);
abandonedConfig.setRemoveAbandonedOnBorrow(true);
abandonedConfig.setRemoveAbandonedOnMaintenance(true);
internalPool.setAbandonedConfig(abandonedConfig);
}
示例3: DataLoaderFactory
import org.apache.commons.pool2.impl.AbandonedConfig; //导入方法依赖的package包/类
private DataLoaderFactory() {
GenericObjectPoolConfig config=new GenericObjectPoolConfig();
config.setMaxTotal(1024);
config.setMaxIdle(50);
config.setMinIdle(8);
config.setBlockWhenExhausted(false);// 当Pool中没有对象时不等待,而是直接new个新的
AbandonedConfig abandonConfig=new AbandonedConfig();
abandonConfig.setRemoveAbandonedTimeout(300);
abandonConfig.setRemoveAbandonedOnBorrow(true);
abandonConfig.setRemoveAbandonedOnMaintenance(true);
factory=new GenericObjectPool<DataLoader>(this, config, abandonConfig);
}
示例4: init
import org.apache.commons.pool2.impl.AbandonedConfig; //导入方法依赖的package包/类
public void init() {
if (getContextPool() == null) {
GenericObjectPoolConfig config = new GenericObjectPoolConfig();
PoolConfig.setConfig(config, "ldap.context.pool", "ldap.context.pool.", "global.pool.");
config.setTestOnBorrow(true);
LdapServiceContextPoolFactory serviceContextPoolFactory = new LdapServiceContextPoolFactory(getConstantsConfig());
setContextPool(new GenericObjectPool<>(serviceContextPoolFactory, config));
AbandonedConfig abandonedConfig = new AbandonedConfig();
abandonedConfig.setUseUsageTracking(true);
abandonedConfig.setRemoveAbandonedOnMaintenance(true);
abandonedConfig.setRemoveAbandonedOnBorrow(true);
abandonedConfig.setRemoveAbandonedTimeout(60);
getContextPool().setAbandonedConfig(abandonedConfig);
}
}
示例5: ThriftClientPool
import org.apache.commons.pool2.impl.AbandonedConfig; //导入方法依赖的package包/类
/**
* Initializes a new ThriftClientPool.
*
* @param configuration The properties for this instance of the pool
*/
public ThriftClientPool(Properties configuration) {
this.configuration = new EzProperties(configuration, true);
/* We only need to use this to get the application name, so we want this to fall out of scope and get garbage
collected */
EzBakeApplicationConfigurationHelper appConfig = new EzBakeApplicationConfigurationHelper(configuration);
this.applicationName = appConfig.getApplicationName();
this.applicationSecurityId = appConfig.getSecurityID();
if (Strings.isNullOrEmpty(applicationName)) {
logger.warn("No application name was found. Only common services will be discoverable");
}
this.thriftConfiguration = new ThriftConfigurationHelper(configuration);
poolConfig = new GenericObjectPoolConfig();
poolConfig.setMaxIdle(thriftConfiguration.getMaxIdleClients());
poolConfig.setMaxTotal(thriftConfiguration.getMaxPoolClients());
poolConfig.setMinEvictableIdleTimeMillis(thriftConfiguration.getMillisIdleBeforeEviction());
poolConfig.setTimeBetweenEvictionRunsMillis(thriftConfiguration.getMillisIdleBeforeEviction());
poolConfig.setTestOnBorrow(thriftConfiguration.getTestOnBorrow());
poolConfig.setTestWhileIdle(thriftConfiguration.getTestWhileIdle());
poolConfig.setBlockWhenExhausted(thriftConfiguration.getBlockWhenExhausted());
abandonedConfig = new AbandonedConfig();
abandonedConfig.setLogAbandoned(thriftConfiguration.getLogAbandoned());
abandonedConfig.setRemoveAbandonedOnBorrow(thriftConfiguration.getRemoveAbandonedOnBorrow());
abandonedConfig.setRemoveAbandonedOnMaintenance(thriftConfiguration.getRemoveAbandonedOnMaintenance());
abandonedConfig.setRemoveAbandonedTimeout(thriftConfiguration.getRemoveAbandonedTimeout());
if(!thriftConfiguration.actuallyPoolClients()) {
logger.info("Thrift client pool is NOT actually pooling clients!");
}
ServiceDiscovery serviceDiscoveryClient = getServiceDiscoveryClient();
try {
this.commonServices.addAll(serviceDiscoveryClient.getServices());
} catch(Exception e) {
logger.warn("Could not obtain common services!");
throw new RuntimeException(e);
}
RefreshEndpoints(serviceDiscoveryClient);
RefreshCommonEndpoints(serviceDiscoveryClient);
closeClient(serviceDiscoveryClient);
}
示例6: createDbcp
import org.apache.commons.pool2.impl.AbandonedConfig; //导入方法依赖的package包/类
private void createDbcp(DbcpConfig conf)
{
if (!dataSources.containsKey(conf.name))
{
try
{
Class.forName(conf.driverClassName);
DriverManagerConnectionFactory cf = new DriverManagerConnectionFactory(conf.jdbc,conf.user,conf.password);
PoolableConnectionFactory pcf = new PoolableConnectionFactory(cf,null);
pcf.setValidationQuery(conf.validationQuery);
//, pool, null, conf.validationQuery, false, true,abandondedConfig);
logger.info("Creating pool "+conf.toString());
// create a generic pool
GenericObjectPool<PoolableConnection> pool = new GenericObjectPool<PoolableConnection>(pcf);
pool.setMaxTotal(conf.maxTotal);
pool.setMaxIdle(conf.maxIdle);
pool.setMinIdle(conf.minIdle);
pool.setMaxWaitMillis(conf.maxWait);
pool.setTimeBetweenEvictionRunsMillis(conf.timeBetweenEvictionRunsMillis);
pool.setMinEvictableIdleTimeMillis(conf.minEvictableIdleTimeMillis);
pool.setTestWhileIdle(conf.testWhileIdle);
pool.setTestOnBorrow(conf.testOnBorrow);
AbandonedConfig abandonedConfig = new AbandonedConfig();
abandonedConfig.setRemoveAbandonedOnMaintenance(conf.removeAbanadoned);
abandonedConfig.setRemoveAbandonedTimeout(conf.removeAbandonedTimeout);
abandonedConfig.setLogAbandoned(conf.logAbandonded);
pool.setAbandonedConfig(abandonedConfig);
pcf.setPool(pool);
DataSource ds = new PoolingDataSource(pool);
dataSources.put(conf.name, ds);
} catch (ClassNotFoundException e) {
logger.error("Failed to create datasource for "+conf.name+ " with class "+conf.driverClassName);
}
}
else
{
logger.error("Pool "+conf.name+" already exists. Can't change existing datasource at present.");
}
}