Feature - onConnectFailed() and onPingFailed() methods with Throwable argument added to org.redisson.client.FailedNodeDetector

pull/6370/head
Nikita Koksharov 1 month ago
parent 386b2cea97
commit 7a7781b802

@ -65,6 +65,10 @@ public class FailedCommandsDetector implements FailedNodeDetector {
public void onConnectFailed() {
}
@Override
public void onConnectFailed(Throwable cause) {
}
@Override
public void onConnectSuccessful() {
}
@ -81,6 +85,10 @@ public class FailedCommandsDetector implements FailedNodeDetector {
public void onPingFailed() {
}
@Override
public void onPingFailed(Throwable cause) {
}
@Override
public void onCommandFailed(Throwable cause) {
failedCommands.add(System.currentTimeMillis());

@ -51,6 +51,10 @@ public class FailedConnectionDetector implements FailedNodeDetector {
@Override
public void onConnectFailed() {
}
@Override
public void onConnectFailed(Throwable cause) {
firstFailTime.compareAndSet(0, System.currentTimeMillis());
}
@ -70,6 +74,10 @@ public class FailedConnectionDetector implements FailedNodeDetector {
@Override
public void onPingFailed() {
}
@Override
public void onPingFailed(Throwable cause) {
firstFailTime.compareAndSet(0, System.currentTimeMillis());
}

@ -26,12 +26,22 @@ public interface FailedNodeDetector {
void onConnectSuccessful();
@Deprecated
void onConnectFailed();
default void onConnectFailed(Throwable cause) {
onConnectFailed();
}
void onPingSuccessful();
@Deprecated
void onPingFailed();
default void onPingFailed(Throwable cause) {
onPingFailed();
}
void onCommandSuccessful();
void onCommandFailed(Throwable cause);

@ -98,7 +98,7 @@ public class PingConnectionHandler extends ChannelInboundHandlerAdapter {
log.debug("channel: {} closed due to PING response timeout set in {} ms", ctx.channel(), config.getPingConnectionInterval());
ctx.channel().close();
connection.getRedisClient().getConfig().getFailedNodeDetector().onPingFailed();
connection.getRedisClient().getConfig().getFailedNodeDetector().onPingFailed(cause);
} else {
connection.getRedisClient().getConfig().getFailedNodeDetector().onPingSuccessful();
sendPing(ctx);

@ -116,7 +116,7 @@ abstract class ConnectionPool<T extends RedisConnection> {
if (e != null) {
if (entry.getNodeType() == NodeType.SLAVE) {
FailedNodeDetector detector = entry.getClient().getConfig().getFailedNodeDetector();
detector.onConnectFailed();
detector.onConnectFailed(e);
if (detector.isNodeFailed()) {
log.error("Redis node {} has been marked as failed according to the detection logic defined in {}",
entry.getClient().getAddr(), detector);

Loading…
Cancel
Save