|
|
|
@ -15,7 +15,6 @@
|
|
|
|
|
*/
|
|
|
|
|
package org.redisson.client.handler;
|
|
|
|
|
|
|
|
|
|
import java.net.SocketAddress;
|
|
|
|
|
import java.util.Map.Entry;
|
|
|
|
|
import java.util.concurrent.RejectedExecutionException;
|
|
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
@ -31,9 +30,9 @@ import io.netty.bootstrap.Bootstrap;
|
|
|
|
|
import io.netty.channel.Channel;
|
|
|
|
|
import io.netty.channel.ChannelFuture;
|
|
|
|
|
import io.netty.channel.ChannelFutureListener;
|
|
|
|
|
import io.netty.channel.ChannelHandler.Sharable;
|
|
|
|
|
import io.netty.channel.ChannelHandlerContext;
|
|
|
|
|
import io.netty.channel.ChannelInboundHandlerAdapter;
|
|
|
|
|
import io.netty.channel.ChannelHandler.Sharable;
|
|
|
|
|
import io.netty.channel.group.ChannelGroup;
|
|
|
|
|
import io.netty.util.Timeout;
|
|
|
|
|
import io.netty.util.Timer;
|
|
|
|
@ -120,21 +119,26 @@ public class ConnectionWatchdog extends ChannelInboundHandlerAdapter {
|
|
|
|
|
|
|
|
|
|
if (future.isSuccess()) {
|
|
|
|
|
final Channel channel = future.channel();
|
|
|
|
|
|
|
|
|
|
RedisConnection c = RedisConnection.getFrom(channel);
|
|
|
|
|
c.getConnectionPromise().addListener(new FutureListener<RedisConnection>() {
|
|
|
|
|
@Override
|
|
|
|
|
public void operationComplete(Future<RedisConnection> future) throws Exception {
|
|
|
|
|
if (future.isSuccess()) {
|
|
|
|
|
refresh(connection, channel);
|
|
|
|
|
log.debug("{} connected to {}, command: {}", connection, connection.getRedisClient().getAddr(), connection.getCurrentCommand());
|
|
|
|
|
} else {
|
|
|
|
|
log.warn("Can't connect " + connection + " to " + connection.getRedisClient().getAddr(), future.cause());
|
|
|
|
|
if (channel.localAddress().equals(channel.remoteAddress())) {
|
|
|
|
|
channel.close();
|
|
|
|
|
log.error("local address and remote address are the same! connected to: {}, localAddress: {} remoteAddress: {}",
|
|
|
|
|
connection.getRedisClient().getAddr(), channel.localAddress(), channel.remoteAddress());
|
|
|
|
|
} else {
|
|
|
|
|
RedisConnection c = RedisConnection.getFrom(channel);
|
|
|
|
|
c.getConnectionPromise().addListener(new FutureListener<RedisConnection>() {
|
|
|
|
|
@Override
|
|
|
|
|
public void operationComplete(Future<RedisConnection> future) throws Exception {
|
|
|
|
|
if (future.isSuccess()) {
|
|
|
|
|
refresh(connection, channel);
|
|
|
|
|
log.debug("{} connected to {}, command: {}", connection, connection.getRedisClient().getAddr(), connection.getCurrentCommand());
|
|
|
|
|
} else {
|
|
|
|
|
log.warn("Can't connect " + connection + " to " + connection.getRedisClient().getAddr(), future.cause());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
reconnect(connection, nextAttempt);
|
|
|
|
|