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

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

Introduction

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

Prototype

public void setMaxIdle(int maxIdle) 

Source Link

Document

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

Usage

From source file:org.bigbluebutton.core.service.recorder.RedisDispatcher.java

public RedisDispatcher(String host, int port, String password, int keysExpiresInSec) {
    GenericObjectPoolConfig config = new GenericObjectPoolConfig();
    config.setMaxTotal(32);//from w  w w . ja va 2  s. c om
    config.setMaxIdle(8);
    config.setMinIdle(1);
    config.setTestOnBorrow(true);
    config.setTestOnReturn(true);
    config.setTestWhileIdle(true);
    config.setNumTestsPerEvictionRun(12);
    config.setMaxWaitMillis(5000);
    config.setTimeBetweenEvictionRunsMillis(60000);
    config.setBlockWhenExhausted(true);

    this.keysExpiresInSec = keysExpiresInSec;

    // Set the name of this client to be able to distinguish when doing
    // CLIENT LIST on redis-cli
    redisPool = new JedisPool(config, host, port, Protocol.DEFAULT_TIMEOUT, null, Protocol.DEFAULT_DATABASE,
            "BbbAppsAkkaRec");
}

From source file:org.cloudgraph.hbase.connect.HBaseConnectionManager.java

private HBaseConnectionManager() {
    this.config = CloudGraphContext.instance().getConfig();

    GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();

    poolConfig.setMaxTotal(//from w  ww  .  j  a  va  2  s  .  c o m
            this.config.getInt(CONNECTION_POOL_MAX_TOTAL, GenericObjectPoolConfig.DEFAULT_MAX_TOTAL));
    if (this.config.get(CONNECTION_POOL_MAX_SIZE) != null)
        poolConfig.setMaxTotal(
                this.config.getInt(CONNECTION_POOL_MAX_SIZE, GenericObjectPoolConfig.DEFAULT_MAX_TOTAL));

    poolConfig
            .setMaxIdle(this.config.getInt(CONNECTION_POOL_MAX_IDLE, GenericObjectPoolConfig.DEFAULT_MAX_IDLE));
    poolConfig
            .setMinIdle(this.config.getInt(CONNECTION_POOL_MIN_IDLE, GenericObjectPoolConfig.DEFAULT_MIN_IDLE));
    if (this.config.get(CONNECTION_POOL_MIN_SIZE) != null)
        poolConfig.setMinIdle(
                this.config.getInt(CONNECTION_POOL_MIN_SIZE, GenericObjectPoolConfig.DEFAULT_MIN_IDLE));

    poolConfig.setLifo(this.config.getBoolean(CONNECTION_POOL_LIFO, GenericObjectPoolConfig.DEFAULT_LIFO));

    poolConfig.setMaxWaitMillis(this.config.getLong(CONNECTION_POOL_MAX_WAIT_MILLIS,
            GenericObjectPoolConfig.DEFAULT_MAX_WAIT_MILLIS));

    // eviction
    poolConfig.setTimeBetweenEvictionRunsMillis(
            this.config.getLong(CONNECTION_POOL_TIME_BETWEEN_EVICTION_RUNS_MILLIS,
                    GenericObjectPoolConfig.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS));
    poolConfig.setEvictionPolicyClassName(this.config.get(CONNECTION_POOL_EVICTION_POLICY_CLASS_NAME,
            GenericObjectPoolConfig.DEFAULT_EVICTION_POLICY_CLASS_NAME));
    poolConfig.setMinEvictableIdleTimeMillis(this.config.getLong(CONNECTION_POOL_MIN_EVICTABLE_IDLE_TIME_MILLIS,
            GenericObjectPoolConfig.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS));
    poolConfig.setSoftMinEvictableIdleTimeMillis(
            this.config.getLong(CONNECTION_POOL_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS,
                    GenericObjectPoolConfig.DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS));
    poolConfig.setNumTestsPerEvictionRun(this.config.getInt(CONNECTION_POOL_NUM_TESTS_PER_EVICTION_RUN,
            GenericObjectPoolConfig.DEFAULT_NUM_TESTS_PER_EVICTION_RUN));

    poolConfig.setTestOnCreate(this.config.getBoolean(CONNECTION_POOL_TEST_ON_CREATE,
            GenericObjectPoolConfig.DEFAULT_TEST_ON_CREATE));
    poolConfig.setTestOnBorrow(this.config.getBoolean(CONNECTION_POOL_TEST_ON_BORROW,
            GenericObjectPoolConfig.DEFAULT_TEST_ON_BORROW));
    poolConfig.setTestOnReturn(this.config.getBoolean(CONNECTION_POOL_TEST_ON_RETURN,
            GenericObjectPoolConfig.DEFAULT_TEST_ON_RETURN));
    poolConfig.setTestWhileIdle(this.config.getBoolean(CONNECTION_POOL_TEST_WHILE_IDLE,
            GenericObjectPoolConfig.DEFAULT_TEST_WHILE_IDLE));
    poolConfig.setBlockWhenExhausted(this.config.getBoolean(CONNECTION_POOL_BLOCK_WHEN_EXHAUSTED,
            GenericObjectPoolConfig.DEFAULT_BLOCK_WHEN_EXHAUSTED));
    poolConfig.setJmxEnabled(this.config.getBoolean(CONNECTION_POOL_JMX_ENABLED, false));
    poolConfig.setJmxNameBase(
            this.config.get(CONNECTION_POOL_JMX_NAME_BASE, GenericObjectPoolConfig.DEFAULT_JMX_NAME_BASE));
    poolConfig.setJmxNamePrefix(
            this.config.get(CONNECTION_POOL_JMX_NAME_PREFIX, GenericObjectPoolConfig.DEFAULT_JMX_NAME_PREFIX));

    PooledConnectionFactory factory = new PooledConnectionFactory(this.config);
    this.pool = new GenericObjectPool<Connection>(factory, poolConfig);
    factory.setPool(pool);

    log.info("created connection pool[ " + "\n\tMaxTotal:\t\t" + poolConfig.getMaxTotal() + "\n\tMinIdle:\t\t"
            + poolConfig.getMinIdle() + "\n\tMaxIdle:\t\t" + poolConfig.getMaxIdle() + "\n\tLifo:\t\t"
            + poolConfig.getLifo() + "\n\tMaxWaitMillis:\t\t" + poolConfig.getMaxWaitMillis()
            + "\n\tTimeBetweenEvictionRunsMillis:\t\t" + poolConfig.getTimeBetweenEvictionRunsMillis()
            + "\n\tEvictionPolicyClassName:\t\t" + poolConfig.getEvictionPolicyClassName()
            + "\n\tMinEvictableIdleTimeMillis:\t\t" + poolConfig.getMinEvictableIdleTimeMillis()
            + "\n\tSoftMinEvictableIdleTimeMillis:\t\t" + poolConfig.getSoftMinEvictableIdleTimeMillis()
            + "\n\tNumTestsPerEvictionRun:\t\t" + poolConfig.getNumTestsPerEvictionRun() + "\n...]");
}

From source file:org.coodex.sharedcache.jedis.JedisClientFactory.java

@Override
public SharedCacheClient getClientInstance() {
    synchronized (JedisClientFactory.class) {
        if (client == null) {
            profile = Profile.getProfile("sharedcache-jedis.properties");
            String[] redisServers = profile.getStrList("redisServers");
            if (redisServers == null)
                throw new RuntimeException("no redis server defined.");

            Set<HostAndPort> servers = new HashSet<HostAndPort>();
            for (String server : redisServers) {
                try {
                    servers.add(toHostAndPort(server));
                } catch (Throwable e) {
                    throw new RuntimeException("unknown redis server: " + server, e);
                }//  ww w  .  java2  s .c  o  m
            }

            GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();

            poolConfig.setMinIdle(profile.getInt("pool.minIdle", GenericObjectPoolConfig.DEFAULT_MIN_IDLE));
            poolConfig.setMaxIdle(profile.getInt("pool.maxIdle", GenericObjectPoolConfig.DEFAULT_MAX_IDLE));
            poolConfig.setMaxTotal(profile.getInt("pool.maxTotal", GenericObjectPoolConfig.DEFAULT_MAX_TOTAL));

            // TODO ?

            if (servers.size() == 0)
                throw new RuntimeException("no redis server defined.");
            long defaultMaxCacheTime = profile.getLong("defaultMaxCacheTime", DEFAULT_MAX_CACHED_SECENDS)
                    * 1000;

            if (servers.size() == 1) {
                HostAndPort server = servers.iterator().next();
                client = new JedisSingleNodeClient(
                        new JedisPool(poolConfig, server.getHost(), server.getPort()), defaultMaxCacheTime);
            } else {
                client = new JedisClusterClient(new JedisCluster(servers, poolConfig), defaultMaxCacheTime);

            }
        }
    }
    return client;
}

From source file:org.eclipse.kapua.broker.core.pool.JmsAssistantProducerPool.java

/**
 * Create a JmsAssistantProducerPool from the given factory
 * /*from   w w  w  .j av  a  2s. c o m*/
 * @param factory
 */
protected JmsAssistantProducerPool(JmsAssistantProducerWrapperFactory factory) {
    super(factory);
    // TODO parameter to be added to configuration
    // int totalMaxSize = KapuaEnvironmentConfig.getInstance().getString(KapuaEnvironmentConfigKeys.POOL_TOTAL_MAX_SIZE);
    // int maxSize = KapuaEnvironmentConfig.getInstance().getString(KapuaEnvironmentConfigKeys.POOL_MAX_SIZE);
    // int minSize = KapuaEnvironmentConfig.getInstance().getString(KapuaEnvironmentConfigKeys.POOL_MIN_SIZE);
    int totalMaxSize = 25;
    int maxSize = 25;
    int minSize = 10;

    GenericObjectPoolConfig jmsPoolConfig = new GenericObjectPoolConfig();
    jmsPoolConfig.setMaxTotal(totalMaxSize);
    jmsPoolConfig.setMaxIdle(maxSize);
    jmsPoolConfig.setMinIdle(minSize);
    s_logger.info("Set test on return to true for JmsAssistantProducerPool");
    jmsPoolConfig.setTestOnReturn(true);
    s_logger.info("Set test on borrow to true for JmsAssistantProducerPool");
    jmsPoolConfig.setTestOnBorrow(true);
    s_logger.info("Set block when exausted to true for JmsAssistantProducerPool");
    jmsPoolConfig.setBlockWhenExhausted(true);

    setConfig(jmsPoolConfig);
}

From source file:org.eclipse.kapua.transport.mqtt.pooling.MqttClientPool.java

/**
 * Initialize a {@link MqttClientPool} with the according configuration sourced from {@link MqttClientPoolSetting}.
 * /*from  w  w w .  j av  a2s  .com*/
 * @since 1.0.0
 */
private MqttClientPool(PooledMqttClientFactory factory) {
    super(factory);

    MqttClientPoolSetting config = MqttClientPoolSetting.getInstance();
    GenericObjectPoolConfig clientPoolConfig = new GenericObjectPoolConfig();
    clientPoolConfig.setMinIdle(config.getInt(MqttClientPoolSettingKeys.CLIENT_POOL_SIZE_IDLE_MIN));
    clientPoolConfig.setMaxIdle(config.getInt(MqttClientPoolSettingKeys.CLIENT_POOL_SIZE_IDLE_MAX));
    clientPoolConfig.setMaxTotal(config.getInt(MqttClientPoolSettingKeys.CLIENT_POOL_SIZE_TOTAL_MAX));

    clientPoolConfig.setMaxWaitMillis(config.getInt(MqttClientPoolSettingKeys.CLIENT_POOL_BORROW_WAIT_MAX));

    clientPoolConfig.setTestOnReturn(config.getBoolean(MqttClientPoolSettingKeys.CLIENT_POOL_ON_RETURN_TEST));
    clientPoolConfig.setTestOnBorrow(config.getBoolean(MqttClientPoolSettingKeys.CLIENT_POOL_ON_BORROW_TEST));

    clientPoolConfig.setTestWhileIdle(config.getBoolean(MqttClientPoolSettingKeys.CLIENT_POOL_WHEN_IDLE_TEST));
    clientPoolConfig.setBlockWhenExhausted(
            config.getBoolean(MqttClientPoolSettingKeys.CLIENT_POOL_WHEN_EXAUSTED_BLOCK));

    clientPoolConfig.setTimeBetweenEvictionRunsMillis(
            config.getLong(MqttClientPoolSettingKeys.CLIENT_POOL_EVICTION_INTERVAL));

    setConfig(clientPoolConfig);
}

From source file:org.jooby.jedis.Redis.java

private GenericObjectPoolConfig poolConfig(final Config config) {
    GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
    poolConfig.setBlockWhenExhausted(config.getBoolean("blockWhenExhausted"));
    poolConfig.setEvictionPolicyClassName(config.getString("evictionPolicyClassName"));
    poolConfig.setJmxEnabled(config.getBoolean("jmxEnabled"));
    poolConfig.setJmxNamePrefix(config.getString("jmxNamePrefix"));
    poolConfig.setLifo(config.getBoolean("lifo"));
    poolConfig.setMaxIdle(config.getInt("maxIdle"));
    poolConfig.setMaxTotal(config.getInt("maxTotal"));
    poolConfig.setMaxWaitMillis(config.getDuration("maxWait", TimeUnit.MILLISECONDS));
    poolConfig.setMinEvictableIdleTimeMillis(config.getDuration("minEvictableIdle", TimeUnit.MILLISECONDS));
    poolConfig.setMinIdle(config.getInt("minIdle"));
    poolConfig.setNumTestsPerEvictionRun(config.getInt("numTestsPerEvictionRun"));
    poolConfig.setSoftMinEvictableIdleTimeMillis(
            config.getDuration("softMinEvictableIdle", TimeUnit.MILLISECONDS));
    poolConfig.setTestOnBorrow(config.getBoolean("testOnBorrow"));
    poolConfig.setTestOnReturn(config.getBoolean("testOnReturn"));
    poolConfig.setTestWhileIdle(config.getBoolean("testWhileIdle"));
    poolConfig.setTimeBetweenEvictionRunsMillis(
            config.getDuration("timeBetweenEvictionRuns", TimeUnit.MILLISECONDS));

    return poolConfig;
}

From source file:org.nd4j.linalg.jcublas.context.ContextHolder.java

/**
 * Configure the given information/*from   ww  w  . j  a  va2  s.  c  o  m*/
 * based on the device
 */
public void configure() {
    if (confCalled)
        return;

    JCublas2.setExceptionsEnabled(true);
    JCudaDriver.setExceptionsEnabled(true);
    JCuda.setExceptionsEnabled(true);

    if (deviceSetup.get())
        return;

    JCudaDriver.cuInit(0);
    int count[] = new int[1];
    cuDeviceGetCount(count);
    numDevices = count[0];
    log.debug("Found " + numDevices + " gpus");

    if (numDevices < 1)
        numDevices = 1;
    bannedDevices = new ArrayList<>();

    String props = System.getProperty(DEVICES_TO_BAN, "-1");
    String[] split = props.split(",");
    //Should only be used in multi device scenarios; otherwise always use one device
    if (split.length >= 1)
        for (String s : split) {
            Integer i = Integer.parseInt(s);
            if (i >= 0)
                bannedDevices.add(Integer.parseInt(s));

        }

    deviceSetup.set(true);
    Set<Thread> threadSet = Thread.getAllStackTraces().keySet();

    for (int i = 0; i < numDevices; i++) {
        for (Thread thread : threadSet)
            getContext(i, thread.getName());
    }

    setContext();

    try {
        KernelFunctionLoader.getInstance().load();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    // Check if the device supports mapped host memory
    cudaDeviceProp deviceProperties = new cudaDeviceProp();
    JCuda.cudaGetDeviceProperties(deviceProperties, 0);
    if (deviceProperties.canMapHostMemory == 0) {
        System.err.println("This device can not map host memory");
        System.err.println(deviceProperties.toFormattedString());
        return;
    }

    //force certain ops to have a certain number of threads
    Properties threadProps = new Properties();
    try {
        InputStream is = ContextHolder.class.getResourceAsStream("/function_threads.properties");
        threadProps.load(is);
    } catch (IOException e) {
        e.printStackTrace();
    }

    for (String prop : threadProps.stringPropertyNames()) {
        threads.put(prop, Integer.parseInt(threadProps.getProperty(prop)));
    }

    try {
        GenericObjectPoolConfig config = new GenericObjectPoolConfig();
        config.setJmxEnabled(true);
        config.setBlockWhenExhausted(false);
        config.setMaxIdle(Runtime.getRuntime().availableProcessors());
        config.setMaxTotal(Runtime.getRuntime().availableProcessors());
        config.setMinIdle(Runtime.getRuntime().availableProcessors());
        config.setJmxNameBase("handles");
        handlePool = new CublasHandlePool(new CublasHandlePooledItemFactory(), config);
        GenericObjectPoolConfig confClone = config.clone();
        confClone.setMaxTotal(Runtime.getRuntime().availableProcessors() * 10);
        confClone.setMaxIdle(Runtime.getRuntime().availableProcessors() * 10);
        confClone.setMinIdle(Runtime.getRuntime().availableProcessors() * 10);
        GenericObjectPoolConfig streamConf = confClone.clone();
        streamConf.setJmxNameBase("streams");
        streamPool = new StreamPool(new StreamItemFactory(), streamConf);
        GenericObjectPoolConfig oldStreamConf = streamConf.clone();
        oldStreamConf.setJmxNameBase("oldstream");
        oldStreamPool = new OldStreamPool(new OldStreamItemFactory(), oldStreamConf);
        setContext();
        //seed with multiple streams to encourage parallelism
        for (int i = 0; i < Runtime.getRuntime().availableProcessors(); i++) {
            streamPool.addObject();
            oldStreamPool.addObject();
        }

        //force context initialization to occur
        JCuda.cudaFree(Pointer.to(new int[] { 0 }));

    } catch (Exception e) {
        log.warn("Unable to initialize cuda", e);
    }

    for (int i = 0; i < numDevices; i++) {
        ClassPathResource confFile = new ClassPathResource("devices/" + i,
                ContextHolder.class.getClassLoader());
        if (confFile.exists()) {
            Properties props2 = new Properties();
            try {
                props2.load(confFile.getInputStream());
                confs.put(i, new DeviceConfiguration(i, props2));
            } catch (IOException e) {
                throw new RuntimeException(e);
            }

        } else
            confs.put(i, new DeviceConfiguration(i));

    }

    confCalled = true;
}

From source file:org.noerp.entity.connection.DBCPConnectionFactory.java

public Connection getConnection(GenericHelperInfo helperInfo, JdbcElement abstractJdbc)
        throws SQLException, GenericEntityException {
    String cacheKey = helperInfo.getHelperFullName();
    ManagedDataSource mds = dsCache.get(cacheKey);
    if (mds != null) {
        return TransactionUtil.getCursorConnection(helperInfo, mds.getConnection());
    }//  w  w  w .  j  a va 2 s.c  om
    if (!(abstractJdbc instanceof InlineJdbc)) {
        throw new GenericEntityConfException(
                "DBCP requires an <inline-jdbc> child element in the <datasource> element");
    }
    InlineJdbc jdbcElement = (InlineJdbc) abstractJdbc;
    // connection properties
    TransactionManager txMgr = TransactionFactoryLoader.getInstance().getTransactionManager();
    String driverName = jdbcElement.getJdbcDriver();

    String jdbcUri = helperInfo.getOverrideJdbcUri(jdbcElement.getJdbcUri());
    String jdbcUsername = helperInfo.getOverrideUsername(jdbcElement.getJdbcUsername());
    String jdbcPassword = helperInfo.getOverridePassword(EntityConfig.getJdbcPassword(jdbcElement));

    // pool settings
    int maxSize = jdbcElement.getPoolMaxsize();
    int minSize = jdbcElement.getPoolMinsize();
    int maxIdle = jdbcElement.getIdleMaxsize();
    // maxIdle must be greater than pool-minsize
    maxIdle = maxIdle > minSize ? maxIdle : minSize;
    // load the driver
    Driver jdbcDriver;
    synchronized (DBCPConnectionFactory.class) {
        // Sync needed for MS SQL JDBC driver. See OFBIZ-5216.
        try {
            jdbcDriver = (Driver) Class
                    .forName(driverName, true, Thread.currentThread().getContextClassLoader()).newInstance();
        } catch (Exception e) {
            Debug.logError(e, module);
            throw new GenericEntityException(e.getMessage(), e);
        }
    }

    // connection factory properties
    Properties cfProps = new Properties();
    cfProps.put("user", jdbcUsername);
    cfProps.put("password", jdbcPassword);

    // create the connection factory
    org.apache.commons.dbcp2.ConnectionFactory cf = new DriverConnectionFactory(jdbcDriver, jdbcUri, cfProps);

    // wrap it with a LocalXAConnectionFactory
    XAConnectionFactory xacf = new LocalXAConnectionFactory(txMgr, cf);

    // create the pool object factory
    PoolableConnectionFactory factory = new PoolableManagedConnectionFactory(xacf, null);
    factory.setValidationQuery(jdbcElement.getPoolJdbcTestStmt());
    factory.setDefaultReadOnly(false);
    String transIso = jdbcElement.getIsolationLevel();
    if (!transIso.isEmpty()) {
        if ("Serializable".equals(transIso)) {
            factory.setDefaultTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE);
        } else if ("RepeatableRead".equals(transIso)) {
            factory.setDefaultTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
        } else if ("ReadUncommitted".equals(transIso)) {
            factory.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
        } else if ("ReadCommitted".equals(transIso)) {
            factory.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
        } else if ("None".equals(transIso)) {
            factory.setDefaultTransactionIsolation(Connection.TRANSACTION_NONE);
        }
    }

    // configure the pool settings
    GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
    poolConfig.setMaxTotal(maxSize);
    // settings for idle connections
    poolConfig.setMaxIdle(maxIdle);
    poolConfig.setMinIdle(minSize);
    poolConfig.setTimeBetweenEvictionRunsMillis(jdbcElement.getTimeBetweenEvictionRunsMillis());
    poolConfig.setMinEvictableIdleTimeMillis(-1); // disabled in favour of setSoftMinEvictableIdleTimeMillis(...)
    poolConfig.setSoftMinEvictableIdleTimeMillis(jdbcElement.getSoftMinEvictableIdleTimeMillis());
    poolConfig.setNumTestsPerEvictionRun(maxSize); // test all the idle connections
    // settings for when the pool is exhausted
    poolConfig.setBlockWhenExhausted(true); // the thread requesting the connection waits if no connection is available
    poolConfig.setMaxWaitMillis(jdbcElement.getPoolSleeptime()); // throw an exception if, after getPoolSleeptime() ms, no connection is available for the requesting thread
    // settings for the execution of the validation query
    poolConfig.setTestOnCreate(jdbcElement.getTestOnCreate());
    poolConfig.setTestOnBorrow(jdbcElement.getTestOnBorrow());
    poolConfig.setTestOnReturn(jdbcElement.getTestOnReturn());
    poolConfig.setTestWhileIdle(jdbcElement.getTestWhileIdle());

    GenericObjectPool pool = new GenericObjectPool(factory, poolConfig);
    factory.setPool(pool);

    mds = new ManagedDataSource(pool, xacf.getTransactionRegistry());
    //mds = new DebugManagedDataSource(pool, xacf.getTransactionRegistry()); // Useful to debug the usage of connections in the pool
    mds.setAccessToUnderlyingConnectionAllowed(true);

    // cache the pool
    dsCache.putIfAbsent(cacheKey, mds);
    mds = dsCache.get(cacheKey);

    return TransactionUtil.getCursorConnection(helperInfo, mds.getConnection());
}

From source file:org.power.commons.redis.RedisClient.java

private GenericObjectPoolConfig getPoolConfig() {
    GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
    // maxIdle?pool size???????redis
    poolConfig.setMaxTotal(this.maxTotal);
    if (this.maxIdle > 0) {
        poolConfig.setMaxIdle(this.maxIdle);
    }//ww  w  . j a v a  2  s.  co  m
    poolConfig.setMaxWaitMillis(this.maxWait);
    /* if (this.whenExhaustedAction >= 0 && this.whenExhaustedAction < 3) {
    poolConfig.whenExhaustedAction = this.whenExhaustedAction;
     }*/
    poolConfig.setBlockWhenExhausted(this.blockWhenExhausted);
    poolConfig.setTestOnBorrow(this.testOnBorrow);
    poolConfig.setMinIdle(this.minIdle);
    poolConfig.setTestOnReturn(testOnReturn);
    poolConfig.setTestWhileIdle(testWhileIdle);
    poolConfig.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
    poolConfig.setNumTestsPerEvictionRun(numTestsPerEvictionRun);
    poolConfig.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
    poolConfig.setSoftMinEvictableIdleTimeMillis(softMinEvictableIdleTimeMillis);
    poolConfig.setLifo(lifo);
    return poolConfig;
}

From source file:org.springframework.aop.target.CommonsPool2TargetSource.java

/**
 * Subclasses can override this if they want to return a specific Commons pool.
 * They should apply any configuration properties to the pool here.
 * <p>Default is a GenericObjectPool instance with the given pool size.
 * @return an empty Commons {@code ObjectPool}.
 * @see GenericObjectPool//from  w  w w .  j ava 2s .com
 * @see #setMaxSize
 */
protected ObjectPool createObjectPool() {
    GenericObjectPoolConfig config = new GenericObjectPoolConfig();
    config.setMaxTotal(getMaxSize());
    config.setMaxIdle(getMaxIdle());
    config.setMinIdle(getMinIdle());
    config.setMaxWaitMillis(getMaxWait());
    config.setTimeBetweenEvictionRunsMillis(getTimeBetweenEvictionRunsMillis());
    config.setMinEvictableIdleTimeMillis(getMinEvictableIdleTimeMillis());
    config.setBlockWhenExhausted(isBlockWhenExhausted());
    return new GenericObjectPool(this, config);
}