Example usage for org.apache.commons.pool2.impl GenericObjectPoolConfig setMinIdle

List of usage examples for org.apache.commons.pool2.impl GenericObjectPoolConfig setMinIdle

Introduction

In this page you can find the example usage for org.apache.commons.pool2.impl GenericObjectPoolConfig setMinIdle.

Prototype

public void setMinIdle(int minIdle) 

Source Link

Document

Set the value for the minIdle configuration attribute for pools created with this configuration instance.

Usage

From source file:com.gxl.test.shark.resource.redisSetData.java

public @BeforeClass static void init() {
    GenericObjectPoolConfig cfg = new GenericObjectPoolConfig();
    cfg.setMaxIdle(10);//from  w w w .  jav  a 2 s . c o  m
    cfg.setMinIdle(1);
    cfg.setMaxIdle(5);
    cfg.setMaxWaitMillis(5000);
    cfg.setTestOnBorrow(true);
    cfg.setTestOnReturn(true);
    Set<HostAndPort> hostAndPorts = new HashSet<HostAndPort>();
    HostAndPort hostAndPort = new HostAndPort("120.24.75.22", 7000);
    hostAndPorts.add(hostAndPort);
    jedis = new JedisCluster(hostAndPorts, cfg);
}

From source file:net.greghaines.jesque.utils.PoolUtils.java

/**
 * @return a GenericObjectPoolConfig configured with: maxActive=-1,
 * maxIdle=10, minIdle=1, testOnBorrow=true,
 * blockWhenExhausted=false//from w  w  w  .  j av a 2 s.co  m
 */
public static GenericObjectPoolConfig getDefaultPoolConfig() {
    final GenericObjectPoolConfig cfg = new GenericObjectPoolConfig();
    cfg.setMaxTotal(-1); // Infinite
    cfg.setMaxIdle(10);
    cfg.setMinIdle(1);
    cfg.setTestOnBorrow(true);
    cfg.setBlockWhenExhausted(false);
    return cfg;
}

From source file:com.reversemind.hypergate.client.ClientPool.java

private static GenericObjectPoolConfig createConfig(int poolSize) {
    GenericObjectPoolConfig genericObjectPoolConfig = new GenericObjectPoolConfig();
    genericObjectPoolConfig.setJmxEnabled(true);
    genericObjectPoolConfig.setJmxNameBase("HyperGatePool");
    genericObjectPoolConfig.setJmxNamePrefix("HyperGatePoolPrefix");
    genericObjectPoolConfig.setBlockWhenExhausted(false);
    genericObjectPoolConfig.setMinIdle(0);
    genericObjectPoolConfig.setTestOnBorrow(true);
    genericObjectPoolConfig.setMaxWaitMillis(500);
    START_POOL_SIZE = poolSize;/* w  w  w  . j  av  a2  s  . c o m*/
    genericObjectPoolConfig.setMaxTotal(START_POOL_SIZE);
    genericObjectPoolConfig.setMaxIdle(START_POOL_SIZE);
    return genericObjectPoolConfig;
}

From source file:io.lettuce.core.support.GenericConnectionPoolBenchmark.java

@Setup
public void setup() {

    GenericObjectPoolConfig config = new GenericObjectPoolConfig();
    config.setMinIdle(0);
    config.setMaxIdle(20);/*from  w  ww  .  jav a  2 s.c om*/
    config.setMaxTotal(20);

    pool = ConnectionPoolSupport.createGenericObjectPool(
            () -> new EmptyStatefulRedisConnection(EmptyRedisChannelWriter.INSTANCE), config);
}

From source file:com.kurento.kmf.thrift.pool.AbstractPool.java

protected void init(BasePooledObjectFactory<T> factory) {
    GenericObjectPoolConfig config = new GenericObjectPoolConfig();
    config.setMinIdle(apiConfig.getClientPoolSize());
    config.setTestOnBorrow(true);/*from  w w  w.j  av  a 2s  .  c o m*/
    config.setTestOnReturn(true);
    this.pool = PoolUtils.erodingPool(new GenericObjectPool<>(factory, config));
}

From source file:com.newlandframework.rpc.serialize.hessian.HessianSerializePool.java

public HessianSerializePool(final int maxTotal, final int minIdle, final long maxWaitMillis,
        final long minEvictableIdleTimeMillis) {
    hessianPool = new GenericObjectPool<HessianSerialize>(new HessianSerializeFactory());

    GenericObjectPoolConfig config = new GenericObjectPoolConfig();

    config.setMaxTotal(maxTotal);/*  w  w w  .  ja va  2 s. co m*/
    config.setMinIdle(minIdle);
    config.setMaxWaitMillis(maxWaitMillis);
    config.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);

    hessianPool.setConfig(config);
}

From source file:com.newlandframework.rpc.serialize.protostuff.ProtostuffSerializePool.java

public ProtostuffSerializePool(final int maxTotal, final int minIdle, final long maxWaitMillis,
        final long minEvictableIdleTimeMillis) {
    ProtostuffPool = new GenericObjectPool<ProtostuffSerialize>(new ProtostuffSerializeFactory());

    GenericObjectPoolConfig config = new GenericObjectPoolConfig();

    config.setMaxTotal(maxTotal);/* w  w  w .jav  a 2  s .  com*/
    config.setMinIdle(minIdle);
    config.setMaxWaitMillis(maxWaitMillis);
    config.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);

    ProtostuffPool.setConfig(config);
}

From source file:com.zxy.commons.redis.RedisPoolFactory.java

private RedisPoolFactory() {
    GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
    poolConfig.setMaxIdle(RedisPropUtils.getMaxIdle());
    poolConfig.setMinIdle(RedisPropUtils.getMinIdle());
    poolConfig.setMaxTotal(RedisPropUtils.getMaxTotal());
    poolConfig.setMaxWaitMillis(RedisPropUtils.getMaxWaitMillis());
    poolConfig.setTimeBetweenEvictionRunsMillis(RedisPropUtils.getTimeBetweenEvictionRunsMillis());
    poolConfig.setMinEvictableIdleTimeMillis(RedisPropUtils.getMinEvictableIdleTimeMillis());
    poolConfig.setTestWhileIdle(RedisPropUtils.getTestWhileIdle());
    poolConfig.setTestOnBorrow(RedisPropUtils.getTestOnBorrow());

    Set<String> hosts = RedisPropUtils.getServers();
    if (hosts.size() > 1) {
        throw new IllegalArgumentException("ip port??!");
    }/*w w  w.  j  a  v a  2s  . co  m*/
    HostAndPort hostAndPort = RedisPropUtils.getServer();
    int timeout = RedisPropUtils.getTimeout();
    this.jedisPool = new JedisPool(poolConfig, hostAndPort.getHost(), hostAndPort.getPort(), timeout);
}

From source file:com.streamsets.pipeline.lib.parser.log.TestCEFParser.java

private GenericObjectPool<StringBuilder> getStringBuilderPool() {
    GenericObjectPoolConfig stringBuilderPoolConfig = new GenericObjectPoolConfig();
    stringBuilderPoolConfig.setMaxTotal(1);
    stringBuilderPoolConfig.setMinIdle(1);
    stringBuilderPoolConfig.setMaxIdle(1);
    stringBuilderPoolConfig.setBlockWhenExhausted(false);
    return new GenericObjectPool<>(new StringBuilderPoolFactory(1024), stringBuilderPoolConfig);
}

From source file:com.zxy.commons.redis.RedisClusterFactory.java

private RedisClusterFactory() {
    GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
    poolConfig.setMaxIdle(RedisPropUtils.getMaxIdle());
    poolConfig.setMinIdle(RedisPropUtils.getMinIdle());
    poolConfig.setMaxTotal(RedisPropUtils.getMaxTotal());
    poolConfig.setMaxWaitMillis(RedisPropUtils.getMaxWaitMillis());
    poolConfig.setTimeBetweenEvictionRunsMillis(RedisPropUtils.getTimeBetweenEvictionRunsMillis());
    poolConfig.setMinEvictableIdleTimeMillis(RedisPropUtils.getMinEvictableIdleTimeMillis());
    poolConfig.setTestWhileIdle(RedisPropUtils.getTestWhileIdle());
    poolConfig.setTestOnBorrow(RedisPropUtils.getTestOnBorrow());

    int timeout = RedisPropUtils.getTimeout();
    Set<HostAndPort> haps = parseHostAndPort();
    int maxRedirections = RedisPropUtils.getMaxRedirections();
    if (maxRedirections <= 0) {
        maxRedirections = 5;//from w ww  .j a v  a  2 s .  c om
    }
    jedisCluster = new JedisCluster(haps, timeout, maxRedirections, poolConfig);
}