Search in sources :

Example 21 with GenericObjectPoolConfig

use of com.frameworkset.commons.pool2.impl.GenericObjectPoolConfig in project spring-data-redis by spring-projects.

the class DefaultLettucePoolTests method testGetResourcePoolExhausted.

@Test
void testGetResourcePoolExhausted() {
    GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
    poolConfig.setMaxTotal(1);
    poolConfig.setMaxWaitMillis(1);
    pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort(), poolConfig);
    pool.setClientResources(LettuceTestClientResources.getSharedClientResources());
    pool.afterPropertiesSet();
    StatefulRedisConnection<byte[], byte[]> client = (StatefulRedisConnection<byte[], byte[]>) pool.getResource();
    assertThat(client).isNotNull();
    try {
        pool.getResource();
        fail("PoolException should be thrown when pool exhausted");
    } catch (PoolException e) {
    } finally {
        client.close();
    }
}
Also used : GenericObjectPoolConfig(org.apache.commons.pool2.impl.GenericObjectPoolConfig) PoolException(org.springframework.data.redis.connection.PoolException) StatefulRedisConnection(io.lettuce.core.api.StatefulRedisConnection) Test(org.junit.jupiter.api.Test)

Example 22 with GenericObjectPoolConfig

use of com.frameworkset.commons.pool2.impl.GenericObjectPoolConfig in project spring-data-redis by spring-projects.

the class LettucePoolingClientConfigurationUnitTests method shouldConfigureReadFrom.

// DATAREDIS-956
@Test
void shouldConfigureReadFrom() {
    GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
    LettucePoolingClientConfiguration configuration = // 
    LettucePoolingClientConfiguration.builder().poolConfig(// 
    poolConfig).readFrom(// 
    ReadFrom.MASTER_PREFERRED).build();
    assertThat(configuration.getPoolConfig()).isEqualTo(poolConfig);
    assertThat(configuration.getReadFrom().orElse(ReadFrom.MASTER)).isEqualTo(ReadFrom.MASTER_PREFERRED);
}
Also used : GenericObjectPoolConfig(org.apache.commons.pool2.impl.GenericObjectPoolConfig) Test(org.junit.jupiter.api.Test)

Example 23 with GenericObjectPoolConfig

use of com.frameworkset.commons.pool2.impl.GenericObjectPoolConfig in project spring-data-redis by spring-projects.

the class LettucePoolingClientConfigurationUnitTests method shouldConfigureClientName.

// DATAREDIS-956
@Test
void shouldConfigureClientName() {
    GenericObjectPoolConfig poolConfig = new GenericObjectPoolConfig();
    LettucePoolingClientConfiguration configuration = // 
    LettucePoolingClientConfiguration.builder().poolConfig(// 
    poolConfig).clientName(// 
    "clientName").build();
    assertThat(configuration.getPoolConfig()).isEqualTo(poolConfig);
    assertThat(configuration.getClientName()).contains("clientName");
}
Also used : GenericObjectPoolConfig(org.apache.commons.pool2.impl.GenericObjectPoolConfig) Test(org.junit.jupiter.api.Test)

Example 24 with GenericObjectPoolConfig

use of com.frameworkset.commons.pool2.impl.GenericObjectPoolConfig in project atmosphere by Atmosphere.

the class PoolableBroadcasterFactoryTest method testImplementation.

@Test
public void testImplementation() {
    assertNotNull(factory.poolableProvider());
    assertNotNull(factory.poolableProvider().implementation());
    assertEquals(factory.poolableProvider().implementation().getClass(), GenericObjectPool.class);
    GenericObjectPool nativePool = (GenericObjectPool) factory.poolableProvider().implementation();
    assertTrue(nativePool.getLifo());
    GenericObjectPoolConfig c = new GenericObjectPoolConfig();
    c.setMaxTotal(1);
    nativePool.setConfig(c);
    assertEquals(1, nativePool.getMaxTotal());
}
Also used : GenericObjectPoolConfig(org.apache.commons.pool2.impl.GenericObjectPoolConfig) GenericObjectPool(org.apache.commons.pool2.impl.GenericObjectPool) Test(org.testng.annotations.Test)

Example 25 with GenericObjectPoolConfig

use of com.frameworkset.commons.pool2.impl.GenericObjectPoolConfig in project jetcache by alibaba.

the class JetCacheConfig method pool.

@Bean
public Pool<Jedis> pool() {
    GenericObjectPoolConfig pc = new GenericObjectPoolConfig();
    pc.setMinIdle(2);
    pc.setMaxIdle(10);
    pc.setMaxTotal(10);
    return new JedisPool(pc, "127.0.0.1", 6379);
}
Also used : GenericObjectPoolConfig(org.apache.commons.pool2.impl.GenericObjectPoolConfig) JedisPool(redis.clients.jedis.JedisPool) Bean(org.springframework.context.annotation.Bean)

Aggregations

GenericObjectPoolConfig (org.apache.commons.pool2.impl.GenericObjectPoolConfig)222 Test (org.junit.Test)82 Jedis (redis.clients.jedis.Jedis)44 ShardedJedisPool (redis.clients.jedis.ShardedJedisPool)43 ShardedJedis (redis.clients.jedis.ShardedJedis)41 JedisPool (redis.clients.jedis.JedisPool)37 GenericObjectPool (org.apache.commons.pool2.impl.GenericObjectPool)32 JedisSentinelPool (redis.clients.jedis.JedisSentinelPool)21 Bean (org.springframework.context.annotation.Bean)20 ArrayList (java.util.ArrayList)17 JedisShardInfo (redis.clients.jedis.JedisShardInfo)17 Test (org.junit.jupiter.api.Test)15 URI (java.net.URI)12 LettuceConnectionFactory (org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory)12 JedisConnectionException (redis.clients.jedis.exceptions.JedisConnectionException)12 RedisStandaloneConfiguration (org.springframework.data.redis.connection.RedisStandaloneConfiguration)11 IOException (java.io.IOException)10 Test (org.testng.annotations.Test)10 PooledObject (org.apache.commons.pool2.PooledObject)9 DefaultPooledObject (org.apache.commons.pool2.impl.DefaultPooledObject)9