Search in sources :

Example 86 with GenericObjectPoolConfig

use of org.datanucleus.store.rdbms.datasource.dbcp2.pool2.impl.GenericObjectPoolConfig in project spring-cloud-connectors by spring-cloud.

the class RedisLettuceClientConfigurer method configurePool.

private void configurePool(LettuceClientConfigurationBuilder clientConfiguration, PooledServiceConnectorConfig config) {
    if (config.getPoolConfig() != null) {
        GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
        BeanWrapper target = new BeanWrapperImpl(poolConfig);
        BeanWrapper source = new BeanWrapperImpl(config.getPoolConfig());
        Util.setCorrespondingProperties(target, source);
        ((LettucePoolingClientConfigurationBuilder) clientConfiguration).poolConfig(poolConfig);
    }
}
Also used : BeanWrapper(org.springframework.beans.BeanWrapper) BeanWrapperImpl(org.springframework.beans.BeanWrapperImpl) GenericObjectPoolConfig(org.apache.commons.pool2.impl.GenericObjectPoolConfig) LettucePoolingClientConfigurationBuilder(org.springframework.data.redis.connection.lettuce.LettucePoolingClientConfiguration.LettucePoolingClientConfigurationBuilder)

Example 87 with GenericObjectPoolConfig

use of org.datanucleus.store.rdbms.datasource.dbcp2.pool2.impl.GenericObjectPoolConfig in project athenz by yahoo.

the class DataSourceFactoryTest method testPoolConfigZeroValues.

@Test
public void testPoolConfigZeroValues() {
    System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_TOTAL, "0");
    System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_IDLE, "0");
    System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MIN_IDLE, "0");
    System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_WAIT, "0");
    System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_EVICT_IDLE_TIMEOUT, "0");
    System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_EVICT_IDLE_INTERVAL, "0");
    GenericObjectPoolConfig config = DataSourceFactory.setupPoolConfig();
    assertNotNull(config);
    // MaxTotal and MaxIdle are set to -1 if the value is 0
    assertEquals(config.getMaxTotal(), -1);
    assertEquals(config.getMaxIdle(), -1);
    assertEquals(config.getMinIdle(), 0);
    assertEquals(config.getMaxWaitMillis(), 0);
    assertEquals(config.getMinEvictableIdleTimeMillis(), 0);
    assertEquals(config.getTimeBetweenEvictionRunsMillis(), 0);
    assertTrue(config.getTestWhileIdle());
    assertTrue(config.getTestOnBorrow());
    System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_TOTAL);
    System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_IDLE);
    System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MIN_IDLE);
    System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_WAIT);
    System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_EVICT_IDLE_TIMEOUT);
    System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_EVICT_IDLE_INTERVAL);
}
Also used : GenericObjectPoolConfig(org.apache.commons.pool2.impl.GenericObjectPoolConfig) Test(org.testng.annotations.Test)

Example 88 with GenericObjectPoolConfig

use of org.datanucleus.store.rdbms.datasource.dbcp2.pool2.impl.GenericObjectPoolConfig in project athenz by yahoo.

the class DataSourceFactoryTest method testPoolConfigSpecifiedValues.

@Test
public void testPoolConfigSpecifiedValues() {
    System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_TOTAL, "10");
    System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_IDLE, "20");
    System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MIN_IDLE, "30");
    System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_WAIT, "40");
    System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_EVICT_IDLE_TIMEOUT, "50");
    System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_EVICT_IDLE_INTERVAL, "60");
    GenericObjectPoolConfig config = DataSourceFactory.setupPoolConfig();
    assertNotNull(config);
    assertEquals(config.getMaxTotal(), 10);
    assertEquals(config.getMaxIdle(), 20);
    assertEquals(config.getMinIdle(), 30);
    assertEquals(config.getMaxWaitMillis(), 40);
    assertEquals(config.getMinEvictableIdleTimeMillis(), 50);
    assertEquals(config.getTimeBetweenEvictionRunsMillis(), 60);
    assertTrue(config.getTestWhileIdle());
    assertTrue(config.getTestOnBorrow());
    System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_TOTAL);
    System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_IDLE);
    System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MIN_IDLE);
    System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_WAIT);
    System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_EVICT_IDLE_TIMEOUT);
    System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_EVICT_IDLE_INTERVAL);
}
Also used : GenericObjectPoolConfig(org.apache.commons.pool2.impl.GenericObjectPoolConfig) Test(org.testng.annotations.Test)

Example 89 with GenericObjectPoolConfig

use of org.datanucleus.store.rdbms.datasource.dbcp2.pool2.impl.GenericObjectPoolConfig in project athenz by yahoo.

the class DataSourceFactoryTest method testPoolConfigInvalidValues.

@Test
public void testPoolConfigInvalidValues() {
    System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_TOTAL, "a");
    System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_IDLE, "b");
    System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MIN_IDLE, "c");
    System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_WAIT, "d");
    System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_EVICT_IDLE_TIMEOUT, "e");
    System.setProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_EVICT_IDLE_INTERVAL, "f");
    GenericObjectPoolConfig config = DataSourceFactory.setupPoolConfig();
    assertNotNull(config);
    assertEquals(config.getMaxTotal(), GenericObjectPoolConfig.DEFAULT_MAX_TOTAL);
    assertEquals(config.getMaxIdle(), GenericObjectPoolConfig.DEFAULT_MAX_IDLE);
    assertEquals(config.getMinIdle(), GenericObjectPoolConfig.DEFAULT_MIN_IDLE);
    assertEquals(config.getMaxWaitMillis(), GenericObjectPoolConfig.DEFAULT_MAX_WAIT_MILLIS);
    assertEquals(config.getMinEvictableIdleTimeMillis(), BaseObjectPoolConfig.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
    assertEquals(config.getTimeBetweenEvictionRunsMillis(), BaseObjectPoolConfig.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
    assertTrue(config.getTestWhileIdle());
    assertTrue(config.getTestOnBorrow());
    System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_TOTAL);
    System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_IDLE);
    System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MIN_IDLE);
    System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_MAX_WAIT);
    System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_EVICT_IDLE_TIMEOUT);
    System.clearProperty(DataSourceFactory.ATHENZ_PROP_DBPOOL_EVICT_IDLE_INTERVAL);
}
Also used : GenericObjectPoolConfig(org.apache.commons.pool2.impl.GenericObjectPoolConfig) Test(org.testng.annotations.Test)

Example 90 with GenericObjectPoolConfig

use of org.datanucleus.store.rdbms.datasource.dbcp2.pool2.impl.GenericObjectPoolConfig in project athenz by yahoo.

the class DataSourceFactoryTest method testPoolConfigDefaultValues.

@Test
public void testPoolConfigDefaultValues() {
    GenericObjectPoolConfig config = DataSourceFactory.setupPoolConfig();
    assertNotNull(config);
    assertEquals(config.getMaxTotal(), GenericObjectPoolConfig.DEFAULT_MAX_TOTAL);
    assertEquals(config.getMaxIdle(), GenericObjectPoolConfig.DEFAULT_MAX_IDLE);
    assertEquals(config.getMinIdle(), GenericObjectPoolConfig.DEFAULT_MIN_IDLE);
    assertEquals(config.getMaxWaitMillis(), GenericObjectPoolConfig.DEFAULT_MAX_WAIT_MILLIS);
    assertEquals(config.getMinEvictableIdleTimeMillis(), BaseObjectPoolConfig.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
    assertEquals(config.getTimeBetweenEvictionRunsMillis(), BaseObjectPoolConfig.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS);
    assertTrue(config.getTestWhileIdle());
    assertTrue(config.getTestOnBorrow());
}
Also used : GenericObjectPoolConfig(org.apache.commons.pool2.impl.GenericObjectPoolConfig) Test(org.testng.annotations.Test)

Aggregations

GenericObjectPoolConfig (org.apache.commons.pool2.impl.GenericObjectPoolConfig)127 Test (org.junit.Test)77 Jedis (redis.clients.jedis.Jedis)41 ShardedJedis (redis.clients.jedis.ShardedJedis)40 ShardedJedisPool (redis.clients.jedis.ShardedJedisPool)40 JedisPool (redis.clients.jedis.JedisPool)31 JedisSentinelPool (redis.clients.jedis.JedisSentinelPool)19 ArrayList (java.util.ArrayList)15 JedisShardInfo (redis.clients.jedis.JedisShardInfo)15 URI (java.net.URI)11 GenericObjectPool (org.apache.commons.pool2.impl.GenericObjectPool)9 JedisConnectionException (redis.clients.jedis.exceptions.JedisConnectionException)9 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 BaseTest (com.sohu.tv.test.base.BaseTest)6 IOException (java.io.IOException)6 Transaction (redis.clients.jedis.Transaction)6 PoolableConnectionFactory (org.apache.commons.dbcp2.PoolableConnectionFactory)5 PooledObject (org.apache.commons.pool2.PooledObject)5 DefaultPooledObject (org.apache.commons.pool2.impl.DefaultPooledObject)5 Test (org.testng.annotations.Test)5