Merge pull request #1835 from sKabYY/master

Fix loop redirect error while "CLUSTER FAILOVER"
pull/1888/head
Nikita Koksharov 6 years ago committed by GitHub
commit b9843a50b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -495,7 +495,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;
}
@ -562,6 +562,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();
}
@ -488,6 +488,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