当前位置: 首页>>代码示例>>Java>>正文


Java AbandonedConfig类代码示例

本文整理汇总了Java中org.apache.commons.pool2.impl.AbandonedConfig的典型用法代码示例。如果您正苦于以下问题:Java AbandonedConfig类的具体用法?Java AbandonedConfig怎么用?Java AbandonedConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AbandonedConfig类属于org.apache.commons.pool2.impl包,在下文中一共展示了AbandonedConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: DefaultSessionPool

import org.apache.commons.pool2.impl.AbandonedConfig; //导入依赖的package包/类
public DefaultSessionPool(final ConnectionService connect, final X509TrustManager trust, final X509KeyManager key,
                          final VaultRegistry registry, final Cache<Path> cache, final TranscriptListener transcript,
                          final Host bookmark) {
    this.connect = connect;
    this.registry = registry;
    this.cache = cache;
    this.bookmark = bookmark;
    this.transcript = transcript;
    final GenericObjectPoolConfig configuration = new GenericObjectPoolConfig();
    configuration.setJmxEnabled(false);
    configuration.setEvictionPolicyClassName(CustomPoolEvictionPolicy.class.getName());
    configuration.setBlockWhenExhausted(true);
    configuration.setMaxWaitMillis(BORROW_MAX_WAIT_INTERVAL);
    this.pool = new GenericObjectPool<Session>(new PooledSessionFactory(connect, trust, key, cache, bookmark, registry), configuration);
    final AbandonedConfig abandon = new AbandonedConfig();
    abandon.setUseUsageTracking(true);
    this.pool.setAbandonedConfig(abandon);
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:19,代码来源:DefaultSessionPool.java

示例2: setUp

import org.apache.commons.pool2.impl.AbandonedConfig; //导入依赖的package包/类
@Before
public void setUp() {
    log = new StringWriter();

    final PrintWriter pw = new PrintWriter(log);
    final AbandonedConfig abandonedConfig = new AbandonedConfig();
    abandonedConfig.setLogAbandoned(true);
    abandonedConfig.setRemoveAbandonedOnBorrow(true);
    abandonedConfig.setUseUsageTracking(true);
    abandonedConfig.setRemoveAbandonedTimeout(ABANDONED_TIMEOUT_SECS);
    abandonedConfig.setLogWriter(pw);

    final GenericObjectPoolConfig config = new GenericObjectPoolConfig();
    config.setMaxTotal(3);

    final PooledObjectFactory<TestObject> factory = new TestObjectFactory();

    final ObjectPool<TestObject> innerPool =
            new GenericObjectPool<>(factory, config, abandonedConfig);

    pool = new ProxiedObjectPool<>(innerPool, getproxySource());
}
 
开发者ID:apache,项目名称:commons-pool,代码行数:23,代码来源:BaseTestProxiedObjectPool.java

示例3: 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);
}
 
开发者ID:tanhaichao,项目名称:leopard,代码行数:11,代码来源:JedisPool.java

示例4: 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;
}
 
开发者ID:carryxyh,项目名称:FKC,代码行数:8,代码来源:KryoPoolConfig.java

示例5: 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);
}
 
开发者ID:qiujiayu,项目名称:AutoLoadCache,代码行数:14,代码来源:DataLoaderFactory.java

示例6: 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);
    }
}
 
开发者ID:rancher,项目名称:cattle,代码行数:16,代码来源:LDAPIdentityProvider.java

示例7: createObjectPool

import org.apache.commons.pool2.impl.AbandonedConfig; //导入依赖的package包/类
private static <T> ObjectPool<T> createObjectPool(final PooledObjectFactory<T> factory) {
    final GenericObjectPoolConfig objectPoolConfig = new GenericObjectPoolConfig();
    objectPoolConfig.setMinEvictableIdleTimeMillis(TimeUnit.HOURS.toMillis(1)); // arbitrary, but positive so objects do get evicted
    objectPoolConfig.setTimeBetweenEvictionRunsMillis(TimeUnit.MINUTES.toMillis(10)); // arbitrary, but positive so objects do get evicted
    objectPoolConfig.setJmxEnabled(false);
    objectPoolConfig.setBlockWhenExhausted(false);
    objectPoolConfig.setMaxTotal(-1); // uncapped number of objects in the pool
    final AbandonedConfig abandonedConfig = new AbandonedConfig();
    abandonedConfig.setRemoveAbandonedOnBorrow(true);
    abandonedConfig.setRemoveAbandonedTimeout((int) TimeUnit.MINUTES.toSeconds(30));
    return new GenericObjectPool<T>(factory, objectPoolConfig, abandonedConfig);
}
 
开发者ID:indeedeng,项目名称:proctor,代码行数:13,代码来源:SvnObjectPools.java

示例8: createObjectPool

import org.apache.commons.pool2.impl.AbandonedConfig; //导入依赖的package包/类
/**
 * Creates an object pool used to provide pooling support for {@link Connection JDBC connections}.
 *
 * @param factory         the object factory
 * @param poolConfig      the object pool configuration
 * @param abandonedConfig the abandoned objects configuration
 * @return a non-null instance
 */
protected  GenericObjectPool<PoolableConnection> createObjectPool(
        final PoolableConnectionFactory factory, final GenericObjectPoolConfig poolConfig,
        final AbandonedConfig abandonedConfig) {
    GenericObjectPool<PoolableConnection> gop;
    if (abandonedConfig != null &&
            (abandonedConfig.getRemoveAbandonedOnBorrow() ||
                    abandonedConfig.getRemoveAbandonedOnMaintenance())) {
        gop = new GenericObjectPool<>(factory, poolConfig, abandonedConfig);
    }
    else {
        gop = new GenericObjectPool<>(factory, poolConfig);
    }
    return gop;
}
 
开发者ID:apache,项目名称:commons-dbcp,代码行数:23,代码来源:BasicDataSource.java

示例9: KryoPoolCommonsImpl

import org.apache.commons.pool2.impl.AbandonedConfig; //导入依赖的package包/类
public KryoPoolCommonsImpl(GenericObjectPoolConfig genericObjectPoolConfig, PooledObjectFactory<Kryo> pooledObjectFactory, AbandonedConfig abandonedConfig, FKCExceptionHandler fkcExceptionHandler) {
    this.kryoPool = new GenericObjectPool<Kryo>(pooledObjectFactory, genericObjectPoolConfig, abandonedConfig);
    this.fkcExceptionHandler = fkcExceptionHandler;
}
 
开发者ID:carryxyh,项目名称:FKC,代码行数:5,代码来源:KryoPoolCommonsImpl.java

示例10: abandonedStrategy

import org.apache.commons.pool2.impl.AbandonedConfig; //导入依赖的package包/类
public CommonsBuilder abandonedStrategy(AbandonedConfig abandonedConfig) {
    this.abandonedConfig = abandonedConfig;
    return this;
}
 
开发者ID:carryxyh,项目名称:FKC,代码行数:5,代码来源:KryoPool.java

示例11: HBaseResourcePoolDefault

import org.apache.commons.pool2.impl.AbandonedConfig; //导入依赖的package包/类
public HBaseResourcePoolDefault(final PooledObjectFactory<R> factory, final GenericObjectPoolConfig config, final AbandonedConfig abandonedConfig) {
    super(factory, config, abandonedConfig);
}
 
开发者ID:LiaisonTechnologies,项目名称:shachi,代码行数:4,代码来源:HBaseResourcePoolDefault.java

示例12: SmtpConnectionPool

import org.apache.commons.pool2.impl.AbandonedConfig; //导入依赖的package包/类
public SmtpConnectionPool(SmtpConnectionFactory factory, GenericObjectPoolConfig config, AbandonedConfig abandonedConfig) {
  super(factory, config, abandonedConfig);
}
 
开发者ID:nithril,项目名称:smtp-connection-pool,代码行数:4,代码来源:SmtpConnectionPool.java

示例13: 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);
}
 
开发者ID:ezbake,项目名称:ezbake-common-java,代码行数:50,代码来源:ThriftClientPool.java

示例14: 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.");
	}
}
 
开发者ID:SeldonIO,项目名称:seldon-server,代码行数:49,代码来源:DbcpFactory.java

示例15: PoolClientInvocationHandler

import org.apache.commons.pool2.impl.AbandonedConfig; //导入依赖的package包/类
public PoolClientInvocationHandler(Configuration conf) throws Exception {
  this.conf = conf;
  readConfiguration();
  poolFactory = new SentryServiceClientPoolFactory(conf);
  pool = new GenericObjectPool<SentryPolicyServiceClient>(poolFactory, poolConfig, new AbandonedConfig());
}
 
开发者ID:apache,项目名称:incubator-sentry,代码行数:7,代码来源:PoolClientInvocationHandler.java


注:本文中的org.apache.commons.pool2.impl.AbandonedConfig类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。