Skip to content

Commit

Permalink
Do not require CLIENT LIST in cluster topology refresh #973
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mp911de committed Jan 28, 2019
1 parent 83a5afc commit 61f2ea3
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -69,11 +69,19 @@ static NodeTopologyView from(RedisURI redisURI, Requests clusterNodesRequests, R
TimedAsyncCommand<String, String, String> 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> T optionallyGet(TimedAsyncCommand<?, ?, T> command) throws ExecutionException, InterruptedException {

if (command.isCompletedExceptionally()) {
return null;
}
return command.get();
}

static boolean resultAvailable(RedisFuture<?> redisFuture) {

if (redisFuture != null && redisFuture.isDone() && !redisFuture.isCancelled()) {
Expand Down

0 comments on commit 61f2ea3

Please sign in to comment.