Search in sources :

Example 51 with JedisPoolConfig

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

the class RedisStandaloneProvider method create.

public void create() {
    LOG.debug("Starting RedisStandaloneProvider ...");
    try {
        JedisPoolConfig poolConfig = new JedisPoolConfig();
        poolConfig.setMaxTotal(1000);
        poolConfig.setMinIdle(2);
        HostAndPort hostAndPort = RedisClusterProvider.hosts(redisConfiguration.getServers()).iterator().next();
        pool = new JedisPool(poolConfig, hostAndPort.getHost(), hostAndPort.getPort());
        testConnection();
        LOG.debug("RedisStandaloneProvider started.");
    } catch (Exception e) {
        throw new IllegalStateException("Error starting RedisStandaloneProvider", e);
    }
}
Also used : HostAndPort(redis.clients.jedis.HostAndPort) JedisPool(redis.clients.jedis.JedisPool) JedisPoolConfig(redis.clients.jedis.JedisPoolConfig)

Example 52 with JedisPoolConfig

use of redis.clients.jedis.JedisPoolConfig in project warn-report by saaavsaaa.

the class JRedisPool method buildRedisPool.

private void buildRedisPool() {
    properties = new RedisProperties();
    try {
        JedisPoolConfig config = new JedisPoolConfig();
        config.setMaxTotal(properties.getMaxTotal());
        config.setMaxIdle(properties.getMaxIdle());
        config.setMaxWaitMillis(properties.getMaxWait());
        // 在获取连接的时候检查有效性, 默认false
        config.setTestOnBorrow(properties.isTestOnBorrow());
        // 在空闲时检查有效性, 默认false
        config.setTestWhileIdle(properties.isTestWhileIdle());
        jedisPool = new JedisPool(config, properties.getIp(), properties.getPort(), properties.getTimeout(), properties.getAuth());
    } catch (Exception e) {
        System.out.println("case : new JedisPoolConfig or JedisPool error, detail : " + e.getMessage());
    }
}
Also used : JedisPool(redis.clients.jedis.JedisPool) JedisPoolConfig(redis.clients.jedis.JedisPoolConfig)

Example 53 with JedisPoolConfig

use of redis.clients.jedis.JedisPoolConfig in project Network-depr by Mas281.

the class RedisNetwork method initJedis.

/**
 * Initialises Jedis connection
 */
private void initJedis() {
    log("Attempting to connect to Redis");
    RedisInfo info = new RedisInfo(core);
    pool = new JedisPool(new JedisPoolConfig(), info.getIp(), info.getPort(), Protocol.DEFAULT_TIMEOUT, info.getPassword());
    initPubSub();
    log("Redis connection established");
}
Also used : JedisPool(redis.clients.jedis.JedisPool) JedisPoolConfig(redis.clients.jedis.JedisPoolConfig)

Example 54 with JedisPoolConfig

use of redis.clients.jedis.JedisPoolConfig in project grakn by graknlabs.

the class EngineContext method redis.

public RedisCountStorage redis(String host, int port) {
    JedisPoolConfig poolConfig = new JedisPoolConfig();
    this.jedisPool = new JedisPool(poolConfig, host, port);
    MetricRegistry metricRegistry = new MetricRegistry();
    return RedisCountStorage.create(jedisPool, metricRegistry);
}
Also used : MetricRegistry(com.codahale.metrics.MetricRegistry) JedisPool(redis.clients.jedis.JedisPool) JedisPoolConfig(redis.clients.jedis.JedisPoolConfig)

Example 55 with JedisPoolConfig

use of redis.clients.jedis.JedisPoolConfig in project tomcat-cluster-redis-session-manager by ran-jit.

the class RedisDataCache method getPoolConfig.

/**
 * To get jedis pool configuration
 *
 * @param properties
 * @return
 */
private JedisPoolConfig getPoolConfig(Properties properties) {
    JedisPoolConfig poolConfig = new JedisPoolConfig();
    int maxActive = Integer.parseInt(properties.getProperty(RedisConstants.MAX_ACTIVE, RedisConstants.DEFAULT_MAX_ACTIVE_VALUE));
    poolConfig.setMaxTotal(maxActive);
    boolean testOnBorrow = Boolean.parseBoolean(properties.getProperty(RedisConstants.TEST_ONBORROW, RedisConstants.DEFAULT_TEST_ONBORROW_VALUE));
    poolConfig.setTestOnBorrow(testOnBorrow);
    boolean testOnReturn = Boolean.parseBoolean(properties.getProperty(RedisConstants.TEST_ONRETURN, RedisConstants.DEFAULT_TEST_ONRETURN_VALUE));
    poolConfig.setTestOnReturn(testOnReturn);
    int maxIdle = Integer.parseInt(properties.getProperty(RedisConstants.MAX_ACTIVE, RedisConstants.DEFAULT_MAX_ACTIVE_VALUE));
    poolConfig.setMaxIdle(maxIdle);
    int minIdle = Integer.parseInt(properties.getProperty(RedisConstants.MIN_IDLE, RedisConstants.DEFAULT_MIN_IDLE_VALUE));
    poolConfig.setMinIdle(minIdle);
    boolean testWhileIdle = Boolean.parseBoolean(properties.getProperty(RedisConstants.TEST_WHILEIDLE, RedisConstants.DEFAULT_TEST_WHILEIDLE_VALUE));
    poolConfig.setTestWhileIdle(testWhileIdle);
    int testNumPerEviction = Integer.parseInt(properties.getProperty(RedisConstants.TEST_NUMPEREVICTION, RedisConstants.DEFAULT_TEST_NUMPEREVICTION_VALUE));
    poolConfig.setNumTestsPerEvictionRun(testNumPerEviction);
    long timeBetweenEviction = Long.parseLong(properties.getProperty(RedisConstants.TIME_BETWEENEVICTION, RedisConstants.DEFAULT_TIME_BETWEENEVICTION_VALUE));
    poolConfig.setTimeBetweenEvictionRunsMillis(timeBetweenEviction);
    return poolConfig;
}
Also used : 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