Java Code Examples for org.apache.commons.pool2.impl.GenericObjectPoolConfig#setBlockWhenExhausted()
The following examples show how to use
org.apache.commons.pool2.impl.GenericObjectPoolConfig#setBlockWhenExhausted() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: J2CacheSpringRedisAutoConfiguration.java From spring-boot-tutorial with Creative Commons Attribution Share Alike 4.0 International | 6 votes |
private GenericObjectPoolConfig getGenericRedisPool(Properties props, String prefix) { GenericObjectPoolConfig cfg = new GenericObjectPoolConfig(); cfg.setMaxTotal(Integer.valueOf((String) props.getOrDefault(key(prefix, "maxTotal"), "-1"))); cfg.setMaxIdle(Integer.valueOf((String) props.getOrDefault(key(prefix, "maxIdle"), "100"))); cfg.setMaxWaitMillis(Integer.valueOf((String) props.getOrDefault(key(prefix, "maxWaitMillis"), "100"))); cfg.setMinEvictableIdleTimeMillis( Integer.valueOf((String) props.getOrDefault(key(prefix, "minEvictableIdleTimeMillis"), "864000000"))); cfg.setMinIdle(Integer.valueOf((String) props.getOrDefault(key(prefix, "minIdle"), "10"))); cfg.setNumTestsPerEvictionRun( Integer.valueOf((String) props.getOrDefault(key(prefix, "numTestsPerEvictionRun"), "10"))); cfg.setLifo(Boolean.valueOf(props.getProperty(key(prefix, "lifo"), "false"))); cfg.setSoftMinEvictableIdleTimeMillis( Integer.valueOf((String) props.getOrDefault(key(prefix, "softMinEvictableIdleTimeMillis"), "10"))); cfg.setTestOnBorrow(Boolean.valueOf(props.getProperty(key(prefix, "testOnBorrow"), "true"))); cfg.setTestOnReturn(Boolean.valueOf(props.getProperty(key(prefix, "testOnReturn"), "false"))); cfg.setTestWhileIdle(Boolean.valueOf(props.getProperty(key(prefix, "testWhileIdle"), "true"))); cfg.setTimeBetweenEvictionRunsMillis( Integer.valueOf((String) props.getOrDefault(key(prefix, "timeBetweenEvictionRunsMillis"), "300000"))); cfg.setBlockWhenExhausted(Boolean.valueOf(props.getProperty(key(prefix, "blockWhenExhausted"), "false"))); return cfg; }
Example 2
Source File: J2CacheRedisAutoConfiguration.java From Aooms with Apache License 2.0 | 6 votes |
private GenericObjectPoolConfig getGenericRedisPool(Properties props, String prefix) { GenericObjectPoolConfig cfg = new GenericObjectPoolConfig(); cfg.setMaxTotal(Integer.valueOf((String) props.getOrDefault(key(prefix, "maxTotal"), "-1"))); cfg.setMaxIdle(Integer.valueOf((String) props.getOrDefault(key(prefix, "maxIdle"), "100"))); cfg.setMaxWaitMillis(Integer.valueOf((String) props.getOrDefault(key(prefix, "maxWaitMillis"), "100"))); cfg.setMinEvictableIdleTimeMillis( Integer.valueOf((String) props.getOrDefault(key(prefix, "minEvictableIdleTimeMillis"), "864000000"))); cfg.setMinIdle(Integer.valueOf((String) props.getOrDefault(key(prefix, "minIdle"), "10"))); cfg.setNumTestsPerEvictionRun( Integer.valueOf((String) props.getOrDefault(key(prefix, "numTestsPerEvictionRun"), "10"))); cfg.setLifo(Boolean.valueOf(props.getProperty(key(prefix, "lifo"), "false"))); cfg.setSoftMinEvictableIdleTimeMillis( Integer.valueOf((String) props.getOrDefault(key(prefix, "softMinEvictableIdleTimeMillis"), "10"))); cfg.setTestOnBorrow(Boolean.valueOf(props.getProperty(key(prefix, "testOnBorrow"), "true"))); cfg.setTestOnReturn(Boolean.valueOf(props.getProperty(key(prefix, "testOnReturn"), "false"))); cfg.setTestWhileIdle(Boolean.valueOf(props.getProperty(key(prefix, "testWhileIdle"), "true"))); cfg.setTimeBetweenEvictionRunsMillis( Integer.valueOf((String) props.getOrDefault(key(prefix, "timeBetweenEvictionRunsMillis"), "300000"))); cfg.setBlockWhenExhausted(Boolean.valueOf(props.getProperty(key(prefix, "blockWhenExhausted"), "false"))); return cfg; }
Example 3
Source File: ObjectPoolFactory.java From Thunder with Apache License 2.0 | 6 votes |
public static GenericObjectPoolConfig createFSTObjectPoolConfig() { GenericObjectPoolConfig config = new GenericObjectPoolConfig(); try { config.setMaxTotal(ThunderConstant.CPUS * properties.getInteger(ThunderConstant.FST_OBJECT_POOL_MAX_TOTAL_ATTRIBUTE_NAME)); config.setMaxIdle(ThunderConstant.CPUS * properties.getInteger(ThunderConstant.FST_OBJECT_POOL_MAX_IDLE_ATTRIBUTE_NAME)); config.setMinIdle(ThunderConstant.CPUS * properties.getInteger(ThunderConstant.FST_OBJECT_POOL_MIN_IDLE_ATTRIBUTE_NAME)); config.setMaxWaitMillis(properties.getLong(ThunderConstant.FST_OBJECT_POOL_MAX_WAIT_MILLIS_ATTRIBUTE_NAME)); config.setTimeBetweenEvictionRunsMillis(properties.getLong(ThunderConstant.FST_OBJECT_POOL_TIME_BETWEEN_EVICTION_RUN_MILLIS_ATTRIBUTE_NAME)); config.setMinEvictableIdleTimeMillis(properties.getLong(ThunderConstant.FST_OBJECT_POOL_MIN_EVICTABLE_IDLE_TIME_MILLIS_ATTRIBUTE_NAME)); config.setSoftMinEvictableIdleTimeMillis(properties.getLong(ThunderConstant.FST_OBJECT_POOL_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS_ATTRIBUTE_NAME)); config.setBlockWhenExhausted(properties.getBoolean(ThunderConstant.FST_OBJECT_POOL_BLOCK_WHEN_EXHAUSTED_ATTRIBUTE_NAME)); config.setLifo(properties.getBoolean(ThunderConstant.FST_OBJECT_POOL_LIFO_ATTRIBUTE_NAME)); config.setFairness(properties.getBoolean(ThunderConstant.FST_OBJECT_POOL_FAIRNESS_ATTRIBUTE_NAME)); config.setTestOnBorrow(false); config.setTestOnReturn(false); config.setTestOnCreate(false); config.setTestWhileIdle(false); config.setNumTestsPerEvictionRun(-1); } catch (Exception e) { throw new IllegalArgumentException("Properties maybe isn't initialized"); } return config; }
Example 4
Source File: ShardedJedisPoolTest.java From cachecloud with Apache License 2.0 | 6 votes |
@Test public void checkResourceIsCloseable() throws URISyntaxException { GenericObjectPoolConfig config = new GenericObjectPoolConfig(); config.setMaxTotal(1); config.setBlockWhenExhausted(false); List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>(); shards.add(new JedisShardInfo(new URI("redis://:foobared@localhost:6380"))); shards.add(new JedisShardInfo(new URI("redis://:foobared@localhost:6379"))); ShardedJedisPool pool = new ShardedJedisPool(config, shards); ShardedJedis jedis = pool.getResource(); try { jedis.set("hello", "jedis"); } finally { jedis.close(); } ShardedJedis jedis2 = pool.getResource(); try { assertEquals(jedis, jedis2); } finally { jedis2.close(); } }
Example 5
Source File: DefaultSessionPool.java From cyberduck with GNU General Public License v3.0 | 6 votes |
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<Session> configuration = new GenericObjectPoolConfig<Session>(); 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); }
Example 6
Source File: ObjectPoolFactory.java From Thunder with Apache License 2.0 | 6 votes |
public static GenericObjectPoolConfig createRedisObjectPoolConfig() { GenericObjectPoolConfig config = new GenericObjectPoolConfig(); try { config.setMaxTotal(ThunderConstant.CPUS * properties.getInteger(ThunderConstant.REDIS_OBJECT_POOL_MAX_TOTAL_ATTRIBUTE_NAME)); config.setMaxIdle(ThunderConstant.CPUS * properties.getInteger(ThunderConstant.REDIS_OBJECT_POOL_MAX_IDLE_ATTRIBUTE_NAME)); config.setMinIdle(ThunderConstant.CPUS * properties.getInteger(ThunderConstant.REDIS_OBJECT_POOL_MIN_IDLE_ATTRIBUTE_NAME)); config.setMaxWaitMillis(properties.getLong(ThunderConstant.REDIS_OBJECT_POOL_MAX_WAIT_MILLIS_ATTRIBUTE_NAME)); config.setTimeBetweenEvictionRunsMillis(properties.getLong(ThunderConstant.REDIS_OBJECT_POOL_TIME_BETWEEN_EVICTION_RUN_MILLIS_ATTRIBUTE_NAME)); config.setMinEvictableIdleTimeMillis(properties.getLong(ThunderConstant.REDIS_OBJECT_POOL_MIN_EVICTABLE_IDLE_TIME_MILLIS_ATTRIBUTE_NAME)); config.setSoftMinEvictableIdleTimeMillis(properties.getLong(ThunderConstant.REDIS_OBJECT_POOL_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS_ATTRIBUTE_NAME)); config.setBlockWhenExhausted(properties.getBoolean(ThunderConstant.REDIS_OBJECT_POOL_BLOCK_WHEN_EXHAUSTED_ATTRIBUTE_NAME)); config.setLifo(properties.getBoolean(ThunderConstant.REDIS_OBJECT_POOL_LIFO_ATTRIBUTE_NAME)); config.setFairness(properties.getBoolean(ThunderConstant.REDIS_OBJECT_POOL_FAIRNESS_ATTRIBUTE_NAME)); config.setTestOnBorrow(false); config.setTestOnReturn(false); config.setTestOnCreate(false); config.setTestWhileIdle(false); config.setNumTestsPerEvictionRun(-1); } catch (Exception e) { throw new IllegalArgumentException("Properties maybe isn't initialized"); } return config; }
Example 7
Source File: JedisSentinelPoolTest.java From cachecloud with Apache License 2.0 | 6 votes |
@Test public void checkResourceIsCloseable() { GenericObjectPoolConfig config = new GenericObjectPoolConfig(); config.setMaxTotal(1); config.setBlockWhenExhausted(false); JedisSentinelPool pool = new JedisSentinelPool(MASTER_NAME, sentinels, config, 1000, "foobared", 2); Jedis jedis = pool.getResource(); try { jedis.set("hello", "jedis"); } finally { jedis.close(); } Jedis jedis2 = pool.getResource(); try { assertEquals(jedis, jedis2); } finally { jedis2.close(); } }
Example 8
Source File: JedisHelper.java From netty.book.kor with MIT License | 5 votes |
/** * 제디스 연결풀 생성을 위한 도우미 클래스 내부 생성자. 싱글톤 패턴이므로 외부에서 호출할 수 없다. */ private JedisHelper() { GenericObjectPoolConfig config = new GenericObjectPoolConfig(); config.setMaxTotal(20); config.setBlockWhenExhausted(true); this.pool = new JedisPool(config, REDIS_HOST, REDIS_PORT); }
Example 9
Source File: CommonsPool2TargetSource.java From spring-analysis-note with MIT License | 5 votes |
/** * 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 * @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); }
Example 10
Source File: ShardedJedisPoolTest.java From cachecloud with Apache License 2.0 | 5 votes |
@Test public void returnResourceShouldResetState() throws URISyntaxException { GenericObjectPoolConfig config = new GenericObjectPoolConfig(); config.setMaxTotal(1); config.setBlockWhenExhausted(false); List<JedisShardInfo> shards = new ArrayList<JedisShardInfo>(); shards.add(new JedisShardInfo(new URI("redis://:foobared@localhost:6380"))); shards.add(new JedisShardInfo(new URI("redis://:foobared@localhost:6379"))); ShardedJedisPool pool = new ShardedJedisPool(config, shards); ShardedJedis jedis = pool.getResource(); jedis.set("pipelined", String.valueOf(0)); jedis.set("pipelined2", String.valueOf(0)); ShardedJedisPipeline pipeline = jedis.pipelined(); pipeline.incr("pipelined"); pipeline.incr("pipelined2"); jedis.resetState(); pipeline = jedis.pipelined(); pipeline.incr("pipelined"); pipeline.incr("pipelined2"); List<Object> results = pipeline.syncAndReturnAll(); assertEquals(2, results.size()); jedis.close(); pool.destroy(); }
Example 11
Source File: ShardedJedisPoolTest.java From cachecloud with Apache License 2.0 | 5 votes |
@Test(expected = JedisConnectionException.class) public void checkPoolOverflow() { GenericObjectPoolConfig config = new GenericObjectPoolConfig(); config.setMaxTotal(1); config.setBlockWhenExhausted(false); ShardedJedisPool pool = new ShardedJedisPool(config, shards); ShardedJedis jedis = pool.getResource(); jedis.set("foo", "0"); ShardedJedis newJedis = pool.getResource(); newJedis.incr("foo"); }
Example 12
Source File: JedisSentinelPoolTest.java From cachecloud with Apache License 2.0 | 5 votes |
@Test public void returnResourceShouldResetState() { GenericObjectPoolConfig config = new GenericObjectPoolConfig(); config.setMaxTotal(1); config.setBlockWhenExhausted(false); JedisSentinelPool pool = new JedisSentinelPool(MASTER_NAME, sentinels, config, 1000, "foobared", 2); Jedis jedis = pool.getResource(); Jedis jedis2 = null; try { jedis.set("hello", "jedis"); Transaction t = jedis.multi(); t.set("hello", "world"); jedis.close(); jedis2 = pool.getResource(); assertTrue(jedis == jedis2); assertEquals("jedis", jedis2.get("hello")); } catch (JedisConnectionException e) { if (jedis2 != null) { jedis2 = null; } } finally { jedis2.close(); pool.destroy(); } }
Example 13
Source File: TestCEFParser.java From datacollector with Apache License 2.0 | 5 votes |
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); }
Example 14
Source File: JedisPoolTest.java From cachecloud with Apache License 2.0 | 5 votes |
@Test public void returnResourceShouldResetState() { GenericObjectPoolConfig config = new GenericObjectPoolConfig(); config.setMaxTotal(1); config.setBlockWhenExhausted(false); JedisPool pool = new JedisPool(config, hnp.getHost(), hnp.getPort(), 2000, "foobared"); Jedis jedis = pool.getResource(); try { jedis.set("hello", "jedis"); Transaction t = jedis.multi(); t.set("hello", "world"); } finally { jedis.close(); } Jedis jedis2 = pool.getResource(); try { assertTrue(jedis == jedis2); assertEquals("jedis", jedis2.get("hello")); } finally { jedis2.close(); } pool.destroy(); assertTrue(pool.isClosed()); }
Example 15
Source File: JedisPoolTest.java From cachecloud with Apache License 2.0 | 5 votes |
@Test(expected = JedisConnectionException.class) public void checkPoolOverflow() { GenericObjectPoolConfig config = new GenericObjectPoolConfig(); config.setMaxTotal(1); config.setBlockWhenExhausted(false); JedisPool pool = new JedisPool(config, hnp.getHost(), hnp.getPort()); Jedis jedis = pool.getResource(); jedis.auth("foobared"); jedis.set("foo", "0"); Jedis newJedis = pool.getResource(); newJedis.auth("foobared"); newJedis.incr("foo"); }
Example 16
Source File: BasicHerdDBDataSource.java From herddb with Apache License 2.0 | 5 votes |
protected synchronized void ensureClient() throws SQLException { if (client == null) { ClientConfiguration clientConfiguration = new ClientConfiguration(properties); Properties propsNoPassword = new Properties(); propsNoPassword.putAll(properties); propsNoPassword.setProperty("password", "---"); LOGGER.log(Level.INFO, "Booting HerdDB Client, url:" + url + ", properties:" + propsNoPassword + " clientConfig " + clientConfiguration); try { clientConfiguration.readJdbcUrl(url); } catch (RuntimeException err) { throw new SQLException(err); } if (properties.containsKey("discoverTableSpaceFromQuery")) { this.discoverTableSpaceFromQuery = clientConfiguration.getBoolean("discoverTableSpaceFromQuery", true); } client = new HDBClient(clientConfiguration); } if (pool == null) { if (properties.containsKey("maxActive")) { this.maxActive = Integer.parseInt(properties.get("maxActive").toString()); } GenericObjectPoolConfig config = new GenericObjectPoolConfig(); config.setBlockWhenExhausted(true); config.setMaxTotal(maxActive); config.setMaxIdle(maxActive); config.setMinIdle(maxActive / 2); config.setJmxNamePrefix("HerdDBClient"); pool = new GenericObjectPool<>(new ConnectionsFactory(), config); } }
Example 17
Source File: CommonsPool2TargetSource.java From lams with GNU General Public License v2.0 | 5 votes |
/** * 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 * @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); }
Example 18
Source File: BaseTest.java From lite-pool with Apache License 2.0 | 5 votes |
public GenericObjectPool<TestObject> createCommonsPool2(int minimum, int maximum, long timeout) { GenericObjectPoolConfig config = new GenericObjectPoolConfig(); config.setMaxTotal(maximum); config.setMinIdle(minimum); config.setMaxIdle(minimum); config.setFairness(false); config.setJmxEnabled(false); config.setBlockWhenExhausted(true); config.setTestOnBorrow(false); config.setMaxWaitMillis(timeout); config.setTestOnCreate(false); config.setTestOnReturn(false); config.setTestWhileIdle(false); return new GenericObjectPool<>( new CommonsPool2Factory(), config); }
Example 19
Source File: LinstorConfigTool.java From linstor-server with GNU General Public License v3.0 | 5 votes |
private static PoolingDataSource<PoolableConnection> initConnectionProvider( final String connUrl, final String user, final String password) { Properties dbProps = new Properties(); if (user != null) { dbProps.setProperty("user", user); } if (password != null) { dbProps.setProperty("password", password); } ConnectionFactory connFactory = new DriverManagerConnectionFactory( connUrl, dbProps ); PoolableConnectionFactory poolConnFactory = new PoolableConnectionFactory(connFactory, null); GenericObjectPoolConfig<PoolableConnection> poolConfig = new GenericObjectPoolConfig<PoolableConnection>(); poolConfig.setBlockWhenExhausted(true); poolConfig.setFairness(true); GenericObjectPool<PoolableConnection> connPool = new GenericObjectPool<>(poolConnFactory, poolConfig); poolConnFactory.setPool(connPool); return new PoolingDataSource<>(connPool); }
Example 20
Source File: DefaultRedisModuleCfg.java From ymate-platform-v2 with Apache License 2.0 | 4 votes |
private RedisDataSourceCfgMeta __doParserDataSourceCfgMeta(String dsName, Map<String, String> dataSourceCfgs) throws Exception { IConfigReader _dataSourceCfg = MapSafeConfigReader.bind(dataSourceCfgs); // IRedis.ConnectionType _connectionType; try { _connectionType = IRedis.ConnectionType.valueOf(_dataSourceCfg.getString(CONNECTION_TYPE, IConfig.DEFAULT_STR).toUpperCase()); } catch (IllegalArgumentException e) { throw new UnsupportedOperationException("Redis connection type unsupported."); } String _masterServerName = _dataSourceCfg.getString(MASTER_SERVER_NAME, IConfig.DEFAULT_STR); List<ServerMeta> _servers = new ArrayList<ServerMeta>(); String[] _serverNames = StringUtils.split(_dataSourceCfg.getString(SERVER_NAME_LIST, IConfig.DEFAULT_STR), "|"); if (_serverNames != null) { for (String _serverName : _serverNames) { IConfigReader _serverCfg = MapSafeConfigReader.bind(_dataSourceCfg.getMap("server." + _serverName + ".")); if (!_serverCfg.toMap().isEmpty()) { ServerMeta _servMeta = new ServerMeta(); _servMeta.setName(_serverName); _servMeta.setHost(_serverCfg.getString(HOST, "localhost")); _servMeta.setPort(_serverCfg.getInt(PORT, 6379)); _servMeta.setTimeout(_serverCfg.getInt(TIMEOUT, 2000)); _servMeta.setSocketTimeout(_serverCfg.getInt(SOCKET_TIMEOUT, 2000)); _servMeta.setMaxAttempts(_serverCfg.getInt(MAX_ATTEMPTS, 3)); _servMeta.setWeight(_serverCfg.getInt(WEIGHT, 1)); _servMeta.setDatabase(_serverCfg.getInt(DATABASE, 0)); _servMeta.setClientName(_serverCfg.getString(CLIENT_NAME)); _servMeta.setPassword(_serverCfg.getString(PASSWORD)); // boolean _isPwdEncrypted = _dataSourceCfg.getBoolean(PASSWORD_ENCRYPTED); // if (_isPwdEncrypted && StringUtils.isNotBlank(_servMeta.getPassword())) { IPasswordProcessor _proc = _serverCfg.getClassImpl(PASSWORD_CLASS, IPasswordProcessor.class); if (_proc == null) { _proc = __owner.getConfig().getDefaultPasswordClass().newInstance(); } if (_proc != null) { _servMeta.setPassword(_proc.decrypt(_servMeta.getPassword())); } } // _servers.add(_servMeta); } } } // GenericObjectPoolConfig _poolConfig = new GenericObjectPoolConfig(); IConfigReader _poolCfg = MapSafeConfigReader.bind(_dataSourceCfg.getMap("pool.")); if (!_poolCfg.toMap().isEmpty()) { _poolConfig.setMinIdle(_poolCfg.getInt(MIN_IDLE, GenericObjectPoolConfig.DEFAULT_MIN_IDLE)); _poolConfig.setMaxIdle(_poolCfg.getInt(MAX_IDLE, GenericObjectPoolConfig.DEFAULT_MAX_IDLE)); _poolConfig.setMaxTotal(_poolCfg.getInt(MAX_TOTAL, GenericObjectPoolConfig.DEFAULT_MAX_TOTAL)); _poolConfig.setBlockWhenExhausted(_poolCfg.getBoolean(BLOCK_WHEN_EXHAUSTED, GenericObjectPoolConfig.DEFAULT_BLOCK_WHEN_EXHAUSTED)); _poolConfig.setFairness(_poolCfg.getBoolean(FAIRNESS, GenericObjectPoolConfig.DEFAULT_FAIRNESS)); _poolConfig.setJmxEnabled(_poolCfg.getBoolean(JMX_ENABLE, GenericObjectPoolConfig.DEFAULT_JMX_ENABLE)); _poolConfig.setJmxNameBase(_poolCfg.getString(JMX_NAME_BASE, GenericObjectPoolConfig.DEFAULT_JMX_NAME_BASE)); _poolConfig.setJmxNamePrefix(_poolCfg.getString(JMX_NAME_PREFIX, GenericObjectPoolConfig.DEFAULT_JMX_NAME_PREFIX)); _poolConfig.setEvictionPolicyClassName(_poolCfg.getString(EVICTION_POLICY_CLASS_NAME, GenericObjectPoolConfig.DEFAULT_EVICTION_POLICY_CLASS_NAME)); _poolConfig.setLifo(_poolCfg.getBoolean(LIFO, GenericObjectPoolConfig.DEFAULT_LIFO)); _poolConfig.setMaxWaitMillis(_poolCfg.getLong(MAX_WAIT_MILLIS, GenericObjectPoolConfig.DEFAULT_MAX_WAIT_MILLIS)); _poolConfig.setMinEvictableIdleTimeMillis(_poolCfg.getLong(MIN_EVICTABLE_IDLE_TIME_MILLIS, GenericObjectPoolConfig.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS)); _poolConfig.setSoftMinEvictableIdleTimeMillis(_poolCfg.getLong(SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS, GenericObjectPoolConfig.DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS)); _poolConfig.setTestOnBorrow(_poolCfg.getBoolean(TEST_ON_BORROW, GenericObjectPoolConfig.DEFAULT_TEST_ON_BORROW)); _poolConfig.setTestOnReturn(_poolCfg.getBoolean(TEST_ON_RETURN, GenericObjectPoolConfig.DEFAULT_TEST_ON_RETURN)); _poolConfig.setTestOnCreate(_poolCfg.getBoolean(TEST_ON_CREATE, GenericObjectPoolConfig.DEFAULT_TEST_ON_CREATE)); _poolConfig.setTestWhileIdle(_poolCfg.getBoolean(TEST_WHILE_IDLE, GenericObjectPoolConfig.DEFAULT_TEST_WHILE_IDLE)); _poolConfig.setNumTestsPerEvictionRun(_poolCfg.getInt(NUM_TESTS_PER_EVICTION_RUN, GenericObjectPoolConfig.DEFAULT_NUM_TESTS_PER_EVICTION_RUN)); _poolConfig.setTimeBetweenEvictionRunsMillis(_poolCfg.getLong(TIME_BETWEEN_EVICTION_RUNS_MILLIS, GenericObjectPoolConfig.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS)); } return new RedisDataSourceCfgMeta(dsName, _connectionType, _masterServerName, _servers, _poolConfig); }