Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Koksharov committed Apr 22, 2024
1 parent 1ce1864 commit 3b9508d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -626,8 +626,11 @@ protected void handleError(CompletableFuture<RedisConnection> connectionFuture,
}

RedisClient client = connectionFuture.join().getRedisClient();
client.getConfig().getFailedNodeDetector().onCommandFailed(cause);
if (client.getConfig().getFailedNodeDetector().isNodeFailed()) {
FailedNodeDetector detector = client.getConfig().getFailedNodeDetector();
detector.onCommandFailed(cause);
if (detector.isNodeFailed()) {
log.error("Redis node {} has been marked as failed as failed according to the detection logic defined in {}",
entry.getClient().getAddr(), detector);
entry.shutdownAndReconnectAsync(client, cause);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.redisson.connection.pool;

import org.redisson.api.NodeType;
import org.redisson.client.FailedNodeDetector;
import org.redisson.client.RedisConnection;
import org.redisson.client.RedisConnectionException;
import org.redisson.client.protocol.RedisCommand;
Expand Down Expand Up @@ -114,8 +115,11 @@ protected final CompletableFuture<T> acquireConnection(RedisCommand<?> command,
result.whenComplete((r, e) -> {
if (e != null) {
if (entry.getNodeType() == NodeType.SLAVE) {
entry.getClient().getConfig().getFailedNodeDetector().onConnectFailed();
if (entry.getClient().getConfig().getFailedNodeDetector().isNodeFailed()) {
FailedNodeDetector detector = entry.getClient().getConfig().getFailedNodeDetector();
detector.onConnectFailed();
if (detector.isNodeFailed()) {
log.error("Redis node {} has been marked as failed according to the detection logic defined in {}",
entry.getClient().getAddr(), detector);
masterSlaveEntry.shutdownAndReconnectAsync(entry.getClient(), e);
}
}
Expand Down

0 comments on commit 3b9508d

Please sign in to comment.