|
|
@ -166,14 +166,19 @@ public class ReplicatedConnectionManager extends MasterSlaveConnectionManager {
|
|
|
|
private void checkNode(AsyncCountDownLatch latch, RedisURI uri, ReplicatedServersConfig cfg, Set<InetSocketAddress> slaveIPs) {
|
|
|
|
private void checkNode(AsyncCountDownLatch latch, RedisURI uri, ReplicatedServersConfig cfg, Set<InetSocketAddress> slaveIPs) {
|
|
|
|
CompletionStage<RedisConnection> connectionFuture = connectToNode(cfg, uri, uri.getHost());
|
|
|
|
CompletionStage<RedisConnection> connectionFuture = connectToNode(cfg, uri, uri.getHost());
|
|
|
|
connectionFuture
|
|
|
|
connectionFuture
|
|
|
|
.thenCompose(c -> resolveIP(uri))
|
|
|
|
.thenCompose(c -> {
|
|
|
|
|
|
|
|
if (cfg.isMonitorIPChanges()) {
|
|
|
|
|
|
|
|
return resolveIP(uri);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return CompletableFuture.completedFuture(uri);
|
|
|
|
|
|
|
|
})
|
|
|
|
.thenCompose(ip -> {
|
|
|
|
.thenCompose(ip -> {
|
|
|
|
if (isShuttingDown()) {
|
|
|
|
if (isShuttingDown()) {
|
|
|
|
return CompletableFuture.completedFuture(null);
|
|
|
|
return CompletableFuture.completedFuture(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
RedisConnection connection = connectionFuture.toCompletableFuture().join();
|
|
|
|
RedisConnection connection = connectionFuture.toCompletableFuture().join();
|
|
|
|
if (!ip.equals(connection.getRedisClient().getAddr())) {
|
|
|
|
if (cfg.isMonitorIPChanges() && !ip.equals(connection.getRedisClient().getAddr())) {
|
|
|
|
disconnectNode(uri);
|
|
|
|
disconnectNode(uri);
|
|
|
|
log.info("Hostname: {} has changed IP from: {} to {}", uri, connection.getRedisClient().getAddr(), ip);
|
|
|
|
log.info("Hostname: {} has changed IP from: {} to {}", uri, connection.getRedisClient().getAddr(), ip);
|
|
|
|
return CompletableFuture.<Map<String, String>>completedFuture(null);
|
|
|
|
return CompletableFuture.<Map<String, String>>completedFuture(null);
|
|
|
|