本文整理了Java中redis.clients.jedis.Jedis.clusterNodes()
方法的一些代码示例,展示了Jedis.clusterNodes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jedis.clusterNodes()
方法的具体详情如下:
包路径:redis.clients.jedis.Jedis
类名称:Jedis
方法名:clusterNodes
暂无
代码示例来源:origin: spring-projects/spring-data-redis
@Override
public ClusterTopology getTopology() {
if (cached != null && time + 100 > System.currentTimeMillis()) {
return cached;
}
Map<String, Exception> errors = new LinkedHashMap<>();
List<Entry<String, JedisPool>> list = new ArrayList<>(cluster.getClusterNodes().entrySet());
Collections.shuffle(list);
for (Entry<String, JedisPool> entry : list) {
try (Jedis jedis = entry.getValue().getResource()) {
time = System.currentTimeMillis();
Set<RedisClusterNode> nodes = Converters.toSetOfRedisClusterNodes(jedis.clusterNodes());
synchronized (lock) {
cached = new ClusterTopology(nodes);
}
return cached;
} catch (Exception ex) {
errors.put(entry.getKey(), ex);
}
}
StringBuilder sb = new StringBuilder();
for (Entry<String, Exception> entry : errors.entrySet()) {
sb.append(String.format("\r\n\t- %s failed: %s", entry.getKey(), entry.getValue().getMessage()));
}
throw new ClusterStateFailureException(
"Could not retrieve cluster information. CLUSTER NODES returned with error." + sb.toString());
}
}
代码示例来源:origin: sohutv/cachecloud
public void discoverClusterNodesAndSlots(Jedis jedis) {
w.lock();
try {
this.nodes.clear();
this.slots.clear();
String localNodes = jedis.clusterNodes();
for (String nodeInfo : localNodes.split("\n")) {
ClusterNodeInformation clusterNodeInfo = nodeInfoParser.parse(nodeInfo, new HostAndPort(
jedis.getClient().getHost(), jedis.getClient().getPort()));
HostAndPort targetNode = clusterNodeInfo.getNode();
setNodeIfNotExist(targetNode);
assignSlotsToNode(clusterNodeInfo.getAvailableSlots(), targetNode);
}
} finally {
w.unlock();
}
}
代码示例来源:origin: io.leopard/leopard-redis
@Override
public String clusterNodes() {
return jedis.clusterNodes();
}
代码示例来源:origin: io.leopard/leopard-redis
@Override
public String clusterNodes() {
return jedis.clusterNodes();
}
代码示例来源:origin: com.netflix.spinnaker.kork/kork-jedis
@Override
public String clusterNodes() {
String command = "clusterNodes";
return instrumented(command, () -> delegated.clusterNodes());
}
代码示例来源:origin: org.nutz/nutz-integration-jedis
public String clusterNodes() {
Jedis jedis = getJedis();
try {
return jedis.clusterNodes();
} finally {Streams.safeClose(jedis);}
}
代码示例来源:origin: org.springframework.data/spring-data-redis
@Override
public ClusterTopology getTopology() {
if (cached != null && time + 100 > System.currentTimeMillis()) {
return cached;
}
Map<String, Exception> errors = new LinkedHashMap<>();
List<Entry<String, JedisPool>> list = new ArrayList<>(cluster.getClusterNodes().entrySet());
Collections.shuffle(list);
for (Entry<String, JedisPool> entry : list) {
try (Jedis jedis = entry.getValue().getResource()) {
time = System.currentTimeMillis();
Set<RedisClusterNode> nodes = Converters.toSetOfRedisClusterNodes(jedis.clusterNodes());
synchronized (lock) {
cached = new ClusterTopology(nodes);
}
return cached;
} catch (Exception ex) {
errors.put(entry.getKey(), ex);
}
}
StringBuilder sb = new StringBuilder();
for (Entry<String, Exception> entry : errors.entrySet()) {
sb.append(String.format("\r\n\t- %s failed: %s", entry.getKey(), entry.getValue().getMessage()));
}
throw new ClusterStateFailureException(
"Could not retrieve cluster information. CLUSTER NODES returned with error." + sb.toString());
}
}
代码示例来源:origin: apache/servicemix-bundles
@Override
public ClusterTopology getTopology() {
if (cached != null && time + 100 > System.currentTimeMillis()) {
return cached;
}
Map<String, Exception> errors = new LinkedHashMap<>();
List<Entry<String, JedisPool>> list = new ArrayList<>(cluster.getClusterNodes().entrySet());
Collections.shuffle(list);
for (Entry<String, JedisPool> entry : list) {
try (Jedis jedis = entry.getValue().getResource()) {
time = System.currentTimeMillis();
Set<RedisClusterNode> nodes = Converters.toSetOfRedisClusterNodes(jedis.clusterNodes());
synchronized (lock) {
cached = new ClusterTopology(nodes);
}
return cached;
} catch (Exception ex) {
errors.put(entry.getKey(), ex);
}
}
StringBuilder sb = new StringBuilder();
for (Entry<String, Exception> entry : errors.entrySet()) {
sb.append(String.format("\r\n\t- %s failed: %s", entry.getKey(), entry.getValue().getMessage()));
}
throw new ClusterStateFailureException(
"Could not retrieve cluster information. CLUSTER NODES returned with error." + sb.toString());
}
}
内容来源于网络,如有侵权,请联系作者删除!