use of com.frameworkset.commons.pool2.impl.GenericObjectPoolConfig in project springboot-demo by small-rose.
the class JedisConfig method jedisPoolConfig.
/**
* 初始化jedis连接池
*/
@Bean
public ShardedJedisPool jedisPoolConfig() {
// 创建jedis池配置实例
GenericObjectPoolConfig jedisPoolConfig = new JedisPoolConfig();
// 设连接池最大连接数
jedisPoolConfig.setMaxTotal(Integer.parseInt(maxActive));
// 连接池中的最大空闲连接
jedisPoolConfig.setMaxIdle(Integer.parseInt(maxIdle));
// 连接池最大阻塞等待时间
// jedisPoolConfig.setMaxWaitMillis(Long.valueOf(maxWait.substring(0, maxWait.length() - 2)));
jedisPoolConfig.setMaxWaitMillis(Long.valueOf(maxWait));
// #jedis调用borrowObject方法时,是否进行有效检查
jedisPoolConfig.setTestOnBorrow(Boolean.valueOf(true));
// #jedis调用returnObject方法时,是否进行有效检查
jedisPoolConfig.setTestOnReturn(Boolean.valueOf(true));
List<JedisShardInfo> jdsInfoList = new ArrayList<JedisShardInfo>(2);
JedisShardInfo jedisShardInfo = new JedisShardInfo(host, port);
jdsInfoList.add(jedisShardInfo);
ShardedJedisPool pool = new ShardedJedisPool(jedisPoolConfig, jdsInfoList, Hashing.MURMUR_HASH, Sharded.DEFAULT_KEY_TAG_PATTERN);
return pool;
}
use of com.frameworkset.commons.pool2.impl.GenericObjectPoolConfig in project yuzhouwan by asdf2014.
the class JedisListHashTest method init.
private void init() {
List<JedisShardInfo> shards = new ArrayList<>();
JedisShardInfo si = new JedisShardInfo("localhost", 6379);
si.setPassword("asdf");
shards.add(si);
si = new JedisShardInfo("localhost", 6380);
si.setPassword("asdf");
shards.add(si);
pool = new ShardedJedisPool(new GenericObjectPoolConfig(), shards);
}
use of com.frameworkset.commons.pool2.impl.GenericObjectPoolConfig in project LinkAgent by shulieTech.
the class JedisSentinelFactory method createMediator.
@Override
public RedisClientMediator createMediator(Object obj, ShadowRedisConfig shadowConfig) {
model.cachePressureNode(shadowConfig);
RedisClientMediator mediator = null;
if (Jedis.class.isAssignableFrom(obj.getClass())) {
Object datasource = Reflect.on(obj).get("dataSource");
if (datasource != null && JedisSentinelPool.class.isAssignableFrom(datasource.getClass())) {
JedisSentinelPool pressureJedisPool = null;
String masterName = shadowConfig.getMaster();
Set nodes = new HashSet(shadowConfig.getNodeNums());
String password = shadowConfig.getPassword();
GenericObjectPoolConfig poolConfig = Reflect.on(datasource).get("poolConfig");
password = StringUtil.isEmpty(password) ? null : password;
int database = shadowConfig.getDatabase() == null ? 0 : shadowConfig.getDatabase();
pressureJedisPool = new JedisSentinelPool(masterName, nodes, poolConfig, 2000, password, database);
/* else if (StringUtil.isEmpty(password)) {
pressureJedisPool = new JedisSentinelPool(masterName, nodes, poolConfig);
} else {
pressureJedisPool = new JedisSentinelPool(masterName, nodes, poolConfig, password);
}*/
mediator = new RedisClientMediator<JedisSentinelPool>(pressureJedisPool, (JedisSentinelPool) datasource, true);
}
}
return mediator;
}
use of com.frameworkset.commons.pool2.impl.GenericObjectPoolConfig in project flink-connector-redis by jeff-zou.
the class RedisCommandsContainerBuilder method build.
/**
* Builds container for Redis Cluster environment.
*
* @param jedisClusterConfig configuration for JedisCluster
* @return container for Redis Cluster environment
* @throws NullPointerException if jedisClusterConfig is null
*/
public static RedisCommandsContainer build(FlinkJedisClusterConfig jedisClusterConfig) {
Objects.requireNonNull(jedisClusterConfig, "Redis cluster config should not be Null");
GenericObjectPoolConfig genericObjectPoolConfig = new GenericObjectPoolConfig();
genericObjectPoolConfig.setMaxIdle(jedisClusterConfig.getMaxIdle());
genericObjectPoolConfig.setMaxTotal(jedisClusterConfig.getMaxTotal());
genericObjectPoolConfig.setMinIdle(jedisClusterConfig.getMinIdle());
JedisCluster jedisCluster = new JedisCluster(jedisClusterConfig.getNodes(), jedisClusterConfig.getConnectionTimeout(), jedisClusterConfig.getConnectionTimeout(), jedisClusterConfig.getMaxRedirections(), jedisClusterConfig.getPassword(), genericObjectPoolConfig);
return new RedisClusterContainer(jedisCluster);
}
use of com.frameworkset.commons.pool2.impl.GenericObjectPoolConfig in project flink-connector-redis by jeff-zou.
the class RedisCommandsContainerBuilder method build.
/**
* Builds container for Redis Sentinel environment.
*
* @param jedisSentinelConfig configuration for JedisSentinel
* @return container for Redis sentinel environment
* @throws NullPointerException if jedisSentinelConfig is null
*/
public static RedisCommandsContainer build(FlinkJedisSentinelConfig jedisSentinelConfig) {
Objects.requireNonNull(jedisSentinelConfig, "Redis sentinel config should not be Null");
GenericObjectPoolConfig genericObjectPoolConfig = new GenericObjectPoolConfig();
genericObjectPoolConfig.setMaxIdle(jedisSentinelConfig.getMaxIdle());
genericObjectPoolConfig.setMaxTotal(jedisSentinelConfig.getMaxTotal());
genericObjectPoolConfig.setMinIdle(jedisSentinelConfig.getMinIdle());
JedisSentinelPool jedisSentinelPool = new JedisSentinelPool(jedisSentinelConfig.getMasterName(), jedisSentinelConfig.getSentinels(), genericObjectPoolConfig, jedisSentinelConfig.getConnectionTimeout(), jedisSentinelConfig.getSoTimeout(), jedisSentinelConfig.getPassword(), jedisSentinelConfig.getDatabase());
return new RedisContainer(jedisSentinelPool);
}
Aggregations