Fix loop redirect error while "CLUSTER FAILOVER"

pull/1835/head
skabyy
parent ceda83ae58
commit 8a8105522a

@ -490,7 +490,7 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
for (MasterSlaveEntry entry : client2entry.values()) {
if (URIBuilder.compare(entry.getClient().getAddr(), addr)) {
return entry;
}
}
if (entry.hasSlave(addr)) {
return entry;
}
@ -557,6 +557,11 @@ public class MasterSlaveConnectionManager implements ConnectionManager {
RedisNodeNotFoundException ex = new RedisNodeNotFoundException("Node: " + source + " hasn't been discovered yet");
return RedissonPromise.newFailedFuture(ex);
}
if (source.getRedirect() != null &&
!URIBuilder.compare(entry.getClient().getAddr(), source.getAddr()) &&
entry.hasSlave(source.getAddr())) {
return entry.redirectedConnectionWriteOp(command, source.getAddr());
}
return entry.connectionWriteOp(command);
}

@ -285,7 +285,7 @@ public class MasterSlaveEntry {
public boolean hasSlave(URI addr) {
return slaveBalancer.contains(addr);
}
public int getAvailableClients() {
return slaveBalancer.getAvailableClients();
}
@ -482,6 +482,10 @@ public class MasterSlaveEntry {
return writeConnectionPool.get(command);
}
public RFuture<RedisConnection> redirectedConnectionWriteOp(RedisCommand<?> command, URI addr) {
return slaveBalancer.getConnection(command, addr);
}
public RFuture<RedisConnection> connectionReadOp(RedisCommand<?> command) {
if (config.getReadMode() == ReadMode.MASTER) {
return connectionWriteOp(command);

Loading…
Cancel
Save