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);
}
}
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());
}
}
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");
}
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);
}
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;
}
Aggregations