From 61f2ea363bbc5da8d6b2c5d331f8d98bed82cc75 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Mon, 28 Jan 2019 11:10:38 +0100 Subject: [PATCH] Do not require CLIENT LIST in cluster topology refresh #973 Topology refresh now no longer requires a successful completion of CLIENT LIST during the refresh. Errors can happen if the command is disabled. Previously, an entire cluster node was disabled if the client list could not be retrieved and so the node was not considered in the routing table. Ignoring failed CLIENT LIST commands disables default connection load balancing that helped previously to use the cluster node with the least number of connections. --- .../core/cluster/topology/NodeTopologyView.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/lettuce/core/cluster/topology/NodeTopologyView.java b/src/main/java/io/lettuce/core/cluster/topology/NodeTopologyView.java index 0fd96926f9..20b07f67c4 100644 --- a/src/main/java/io/lettuce/core/cluster/topology/NodeTopologyView.java +++ b/src/main/java/io/lettuce/core/cluster/topology/NodeTopologyView.java @@ -56,7 +56,7 @@ class NodeTopologyView { this.redisURI = redisURI; this.partitions = ClusterPartitionParser.parse(clusterNodes); - this.connectedClients = getClients(clientList); + this.connectedClients = clientList != null ? getClients(clientList) : 0; this.clusterNodes = clusterNodes; this.clientList = clientList; this.latency = latency; @@ -69,11 +69,19 @@ static NodeTopologyView from(RedisURI redisURI, Requests clusterNodesRequests, R TimedAsyncCommand clients = clientListRequests.getRequest(redisURI); if (resultAvailable(nodes) && resultAvailable(clients)) { - return new NodeTopologyView(redisURI, nodes.get(), clients.get(), nodes.duration()); + return new NodeTopologyView(redisURI, nodes.get(), optionallyGet(clients), nodes.duration()); } return new NodeTopologyView(redisURI); } + private static T optionallyGet(TimedAsyncCommand command) throws ExecutionException, InterruptedException { + + if (command.isCompletedExceptionally()) { + return null; + } + return command.get(); + } + static boolean resultAvailable(RedisFuture redisFuture) { if (redisFuture != null && redisFuture.isDone() && !redisFuture.isCancelled()) {