Skip to content

Commit

Permalink
Improve: add the node ip and port for cluster exception
Browse files Browse the repository at this point in the history
fixes #3466
  • Loading branch information
yangbodong22011 committed Jun 16, 2023
1 parent c33bdf7 commit f955473
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private Socket connectToFirstSuccessfulHost(HostAndPort hostAndPort) throws Exce
Collections.shuffle(hosts);
}

JedisConnectionException jce = new JedisConnectionException("Failed to connect to any host resolved for DNS name.");
JedisConnectionException jce = new JedisConnectionException("Failed to connect to host " + hostAndPort);
for (InetAddress host : hosts) {
try {
Socket socket = new Socket();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ public final <T> T executeCommand(CommandObject<T> commandObject) {
} catch (JedisClusterOperationException jnrcne) {
throw jnrcne;
} catch (JedisConnectionException jce) {
lastException = jce;
lastException = new JedisConnectionException(
"Cluster retry failed to " + (connection != null ? connection.toString() : ""), jce);
++consecutiveConnectionFailures;
log.debug("Failed connecting to Redis: {}", connection, jce);
// "- 1" because we just did one, but the attemptsLeft counter hasn't been decremented yet
Expand All @@ -122,7 +123,9 @@ public final <T> T executeCommand(CommandObject<T> commandObject) {
IOUtils.closeQuietly(connection);
}
if (Instant.now().isAfter(deadline)) {
throw new JedisClusterOperationException("Cluster retry deadline exceeded.");
throw new JedisClusterOperationException(
"Cluster retry to " + (connection != null ? connection.toString() : "")
+ " deadline exceeded.");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public final <T> T executeCommand(CommandObject<T> commandObject) {
return execute(connection, commandObject);

} catch (JedisConnectionException jce) {
lastException = jce;
lastException = new JedisConnectionException(
"Retry failed to " + (connection != null ? connection.toString() : ""), jce);
++consecutiveConnectionFailures;
log.debug("Failed connecting to Redis: {}", connection, jce);
// "- 1" because we just did one, but the attemptsLeft counter hasn't been decremented yet
Expand All @@ -62,7 +63,8 @@ public final <T> T executeCommand(CommandObject<T> commandObject) {
}
}
if (Instant.now().isAfter(deadline)) {
throw new JedisException("Retry deadline exceeded.");
throw new JedisException("Retry to " + (connection != null ? connection.toString() : "")
+ " deadline exceeded.");
}
}

Expand Down

0 comments on commit f955473

Please sign in to comment.