Skip to content

Commit

Permalink
minor improvements to logging for JedisClusterTopologyRefresher
Browse files Browse the repository at this point in the history
  • Loading branch information
dmytro-landiak committed Nov 28, 2024
1 parent 305ba25 commit 4096631
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ public void refreshTopology() {
log.trace("Redis cluster configuration is not set!");
return;
}
log.trace("Redis cluster refresh topology is starting!");
try {
RedisClusterConfiguration clusterConfig = factory.getClusterConfiguration();
Set<RedisNode> currentNodes = clusterConfig.getClusterNodes();
log.trace("Current Redis cluster nodes: {}", currentNodes);
log.debug("Current Redis cluster nodes: {}", currentNodes);

for (RedisNode node : currentNodes) {
if (!node.hasValidHost()) {
Expand All @@ -67,19 +68,20 @@ public void refreshTopology() {
}
Set<RedisNode> redisNodes = getRedisNodes(node, jedis);
if (currentNodes.equals(redisNodes)) {
log.trace("Redis cluster topology is up to date!");
log.debug("Redis cluster topology is up to date!");
break;
}
clusterConfig.setClusterNodes(redisNodes);
log.trace("Successfully updated Redis cluster topology, nodes: {}", redisNodes);
log.debug("Successfully updated Redis cluster topology, nodes: {}", redisNodes);
break;
} catch (Exception e) {
log.debug("Failed to refresh cluster topology using node: {}", node.getHost(), e);
log.warn("Failed to refresh cluster topology using node: {}", node.getHost(), e);
}
}
} catch (Exception e) {
log.warn("Failed to refresh cluster topology", e);
}
log.trace("Redis cluster refresh topology has finished!");
}

private Set<RedisNode> getRedisNodes(RedisNode node, Jedis jedis) {
Expand Down

0 comments on commit 4096631

Please sign in to comment.