use of redis.clients.jedis.HostAndPort in project jeesuite-libs by vakinge.
the class JedisClusterProvider method parseHostAndPort.
private Set<HostAndPort> parseHostAndPort(String[] servers) {
try {
Set<HostAndPort> haps = new HashSet<HostAndPort>();
for (String part : servers) {
String[] ipAndPort = part.split(":");
HostAndPort hap = new HostAndPort(ipAndPort[0], Integer.parseInt(ipAndPort[1]));
haps.add(hap);
}
return haps;
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
use of redis.clients.jedis.HostAndPort in project duangframework by tcrct.
the class JedisClusterPoolUtils method createJedisPool.
/**
* 建立连接池 真实环境,一般把配置参数缺抽取出来。
*/
private static void createJedisPool() {
try {
String[] ipArray = getClusterIps();
if (ToolsKit.isEmpty(ipArray)) {
throw new EmptyNullException("ipArray is null");
}
// 只给集群里一个实例就可以
Set<HostAndPort> jedisClusterNodes = new HashSet<HostAndPort>();
for (int i = 0; i < ipArray.length; i++) {
String[] items = ipArray[i].split(":");
jedisClusterNodes.add(new HostAndPort(items[0], Integer.parseInt(items[1])));
}
// 配置信息
GenericObjectPoolConfig config = new GenericObjectPoolConfig();
config.setMaxTotal(10000);
config.setMaxIdle(500);
config.setMinIdle(100);
config.setMaxWaitMillis(5000);
config.setTestOnBorrow(true);
config.setTestOnReturn(true);
jedisCluster = new JedisCluster(jedisClusterNodes, config);
if (null != jedisCluster) {
logger.warn("Connent Redis Cluster: " + ToolsKit.toJsonString(jedisClusterNodes) + " is Success...");
}
} catch (Exception e) {
e.printStackTrace();
logger.info("初始化 redis 出错啦...");
}
}
use of redis.clients.jedis.HostAndPort in project incubator-skywalking by apache.
the class JedisClusterConstructorWithListHostAndPortArgInterceptorTest method setUp.
@Before
public void setUp() throws Exception {
hostAndPortSet = new LinkedHashSet<HostAndPort>();
interceptor = new JedisClusterConstructorWithListHostAndPortArgInterceptor();
hostAndPortSet.add(new HostAndPort("127.0.0.1", 6379));
hostAndPortSet.add(new HostAndPort("127.0.0.1", 16379));
}
use of redis.clients.jedis.HostAndPort in project incubator-skywalking by apache.
the class JedisClusterConstructorWithHostAndPortArgInterceptorTest method onConstruct.
@Test
public void onConstruct() throws Exception {
interceptor.onConstruct(enhancedInstance, new Object[] { new HostAndPort("127.0.0.1", 6379) });
verify(enhancedInstance, times(1)).setSkyWalkingDynamicField("127.0.0.1:6379");
}
use of redis.clients.jedis.HostAndPort in project oxCore by GluuFederation.
the class RedisClusterProvider method hosts.
public static Set<HostAndPort> hosts(String servers) {
final String[] serverWithPorts = StringUtils.split(servers.trim(), ",");
Set<HostAndPort> set = new HashSet<HostAndPort>();
for (String serverWithPort : serverWithPorts) {
final String[] split = serverWithPort.trim().split(":");
String host = split[0];
int port = Integer.parseInt(split[1].trim());
set.add(new HostAndPort(host, port));
}
return set;
}
Aggregations