Search in sources :

Example 61 with GenericObjectPoolConfig

use of org.apache.tomcat.dbcp.pool2.impl.GenericObjectPoolConfig in project jedis by xetorthio.

the class JedisPoolTest method checkPoolOverflow.

@Test(expected = JedisExhaustedPoolException.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");
}
Also used : Jedis(redis.clients.jedis.Jedis) GenericObjectPoolConfig(org.apache.commons.pool2.impl.GenericObjectPoolConfig) JedisPool(redis.clients.jedis.JedisPool) Test(org.junit.Test)

Example 62 with GenericObjectPoolConfig

use of org.apache.tomcat.dbcp.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 63 with GenericObjectPoolConfig

use of org.apache.tomcat.dbcp.pool2.impl.GenericObjectPoolConfig in project bigbluebutton by bigbluebutton.

the class MessageSender method start.

public void start() {
    GenericObjectPoolConfig config = new GenericObjectPoolConfig();
    config.setMaxTotal(32);
    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);
    // 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, "BbbWebPub");
    log.info("Redis message publisher starting!");
    try {
        sendMessage = true;
        Runnable messageSender = new Runnable() {

            public void run() {
                while (sendMessage) {
                    try {
                        MessageToSend msg = messages.take();
                        publish(msg.getChannel(), msg.getMessage());
                    } catch (InterruptedException e) {
                        log.warn("Failed to get message from queue.");
                    }
                }
            }
        };
        msgSenderExec.execute(messageSender);
    } catch (Exception e) {
        log.error("Error subscribing to channels: " + e.getMessage());
    }
}
Also used : GenericObjectPoolConfig(org.apache.commons.pool2.impl.GenericObjectPoolConfig) JedisPool(redis.clients.jedis.JedisPool)

Aggregations

GenericObjectPoolConfig (org.apache.commons.pool2.impl.GenericObjectPoolConfig)62 Test (org.junit.Test)50 ShardedJedis (redis.clients.jedis.ShardedJedis)26 ShardedJedisPool (redis.clients.jedis.ShardedJedisPool)26 Jedis (redis.clients.jedis.Jedis)25 JedisPool (redis.clients.jedis.JedisPool)16 JedisSentinelPool (redis.clients.jedis.JedisSentinelPool)12 ArrayList (java.util.ArrayList)10 JedisShardInfo (redis.clients.jedis.JedisShardInfo)10 URI (java.net.URI)7 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 Transaction (redis.clients.jedis.Transaction)4 BaseTest (com.sohu.tv.test.base.BaseTest)3 JedisConnectionException (redis.clients.jedis.exceptions.JedisConnectionException)3 JedisException (redis.clients.jedis.exceptions.JedisException)3 LoadingCacheTest (com.alicp.jetcache.LoadingCacheTest)2 RefreshCacheTest (com.alicp.jetcache.RefreshCacheTest)2 AbstractExternalCacheTest (com.alicp.jetcache.test.external.AbstractExternalCacheTest)2 URISyntaxException (java.net.URISyntaxException)2 HashSet (java.util.HashSet)2