Search in sources :

Example 46 with JedisPoolConfig

use of redis.clients.jedis.JedisPoolConfig in project ignite by apache.

the class RedisCommonAbstractTest method beforeTestsStarted.

/**
 * {@inheritDoc}
 */
@Override
protected void beforeTestsStarted() throws Exception {
    startGrids(gridCount());
    JedisPoolConfig jedisPoolCfg = new JedisPoolConfig();
    jedisPoolCfg.setMaxWaitMillis(20000);
    jedisPoolCfg.setMaxIdle(100);
    jedisPoolCfg.setMinIdle(1);
    jedisPoolCfg.setNumTestsPerEvictionRun(10);
    jedisPoolCfg.setTestOnBorrow(true);
    jedisPoolCfg.setTestOnReturn(true);
    jedisPoolCfg.setTestWhileIdle(true);
    jedisPoolCfg.setTimeBetweenEvictionRunsMillis(30000);
    pool = new JedisPool(jedisPoolCfg, HOST, PORT, 10000);
}
Also used : JedisPool(redis.clients.jedis.JedisPool) JedisPoolConfig(redis.clients.jedis.JedisPoolConfig)

Example 47 with JedisPoolConfig

use of redis.clients.jedis.JedisPoolConfig in project leopard by tanhaichao.

the class RedisPool method getConfig.

public static GenericObjectPoolConfig getConfig() {
    JedisPoolConfig poolConfig = new JedisPoolConfig();
    // poolConfig.setMaxActive(8);// CPU数量即可
    // CPU数量即可
    poolConfig.setMaxTotal(8);
    return poolConfig;
}
Also used : JedisPoolConfig(redis.clients.jedis.JedisPoolConfig)

Example 48 with JedisPoolConfig

use of redis.clients.jedis.JedisPoolConfig in project leopard by tanhaichao.

the class JedisPoolTest method JedisPool.

@Test
public void JedisPool() {
    JedisPoolConfig poolConfig = new JedisPoolConfig();
    poolConfig.setMaxTotal(1);
    String host = "172.17.1.236";
    int port = 6311;
    int timeout = 3000;
    JedisPool pool = new JedisPool(poolConfig, host, port, timeout, null);
    {
        Jedis jedis = pool.getResource();
        pool.returnBrokenResource(jedis);
        pool.returnResource(jedis);
    }
    {
        RedisConnectionListener redisConnectionListener = Mockito.mock(RedisConnectionListener.class);
        pool.redisConnectionListener = redisConnectionListener;
        Jedis jedis = pool.getResource();
        pool.returnBrokenResource(jedis);
        pool.returnResource(jedis);
    }
}
Also used : Jedis(redis.clients.jedis.Jedis) RedisConnectionListener(io.leopard.redis.RedisConnectionListener) JedisPool(io.leopard.redis.JedisPool) JedisPoolConfig(redis.clients.jedis.JedisPoolConfig) Test(org.junit.Test)

Example 49 with JedisPoolConfig

use of redis.clients.jedis.JedisPoolConfig in project oxCore by GluuFederation.

the class RedisClusterProvider method create.

public void create() {
    try {
        LOG.debug("Starting RedisClusterProvider ... configuration:" + getRedisConfiguration());
        JedisPoolConfig poolConfig = new JedisPoolConfig();
        poolConfig.setMaxTotal(1000);
        poolConfig.setMinIdle(2);
        pool = new JedisCluster(hosts(getRedisConfiguration().getServers()), poolConfig);
        testConnection();
        LOG.debug("RedisClusterProvider started.");
    } catch (Exception e) {
        LOG.error("Failed to start RedisClusterProvider.");
        throw new IllegalStateException("Error starting RedisClusterProvider", e);
    }
}
Also used : JedisCluster(redis.clients.jedis.JedisCluster) JedisPoolConfig(redis.clients.jedis.JedisPoolConfig) IOException(java.io.IOException)

Example 50 with JedisPoolConfig

use of redis.clients.jedis.JedisPoolConfig in project oxCore by GluuFederation.

the class RedisShardedProvider method create.

public void create() {
    try {
        LOG.debug("Starting RedisShardedProvider ... configuration:" + redisConfiguration);
        JedisPoolConfig poolConfig = new JedisPoolConfig();
        poolConfig.setMaxTotal(1000);
        poolConfig.setMinIdle(2);
        pool = new ShardedJedisPool(poolConfig, shards(redisConfiguration.getServers()));
        testConnection();
        LOG.debug("RedisShardedProvider started.");
    } catch (Exception e) {
        LOG.error("Failed to start RedisShardedProvider.");
        throw new IllegalStateException("Error starting RedisShardedProvider", e);
    }
}
Also used : ShardedJedisPool(redis.clients.jedis.ShardedJedisPool) JedisPoolConfig(redis.clients.jedis.JedisPoolConfig)

Aggregations

JedisPoolConfig (redis.clients.jedis.JedisPoolConfig)55 JedisPool (redis.clients.jedis.JedisPool)40 Test (org.junit.Test)31 Jedis (redis.clients.jedis.Jedis)29 HostAndPort (redis.clients.jedis.HostAndPort)7 JedisCluster (redis.clients.jedis.JedisCluster)7 LinkedHashSet (java.util.LinkedHashSet)4 HashSet (java.util.HashSet)3 RedisTicketRegistryProperties (org.apereo.cas.configuration.model.support.redis.RedisTicketRegistryProperties)3 URISyntaxException (java.net.URISyntaxException)2 Before (org.junit.Before)2 JedisConnectionFactory (org.springframework.data.redis.connection.jedis.JedisConnectionFactory)2 InvalidURIException (redis.clients.jedis.exceptions.InvalidURIException)2 JedisException (redis.clients.jedis.exceptions.JedisException)2 MetricRegistry (com.codahale.metrics.MetricRegistry)1 JedisPool (io.leopard.redis.JedisPool)1 RedisConnectionListener (io.leopard.redis.RedisConnectionListener)1 IOException (java.io.IOException)1 BeanWrapper (org.springframework.beans.BeanWrapper)1 BeanWrapperImpl (org.springframework.beans.BeanWrapperImpl)1