Fixed - update new master record in DNS monitor only if it replaced old master successfully.

pull/3209/head
Nikita Koksharov
parent 6ca346435e
commit c93865259f

@ -127,8 +127,13 @@ public class DNSMonitor {
log.error("Unable to find entry for current master {}", currentMasterAddr); log.error("Unable to find entry for current master {}", currentMasterAddr);
return; return;
} }
masterSlaveEntry.changeMaster(newMasterAddr, entry.getKey());
masters.put(entry.getKey(), newMasterAddr); RFuture<RedisClient> changeFuture = masterSlaveEntry.changeMaster(newMasterAddr, entry.getKey());
changeFuture.onComplete((r, e) -> {
if (e == null) {
masters.put(entry.getKey(), newMasterAddr);
}
});
} }
} }
}); });

@ -426,10 +426,11 @@ public class MasterSlaveEntry {
return future; return future;
} }
public void changeMaster(InetSocketAddress address, RedisURI uri) { public RFuture<RedisClient> changeMaster(InetSocketAddress address, RedisURI uri) {
ClientConnectionsEntry oldMaster = masterEntry; ClientConnectionsEntry oldMaster = masterEntry;
RFuture<RedisClient> future = setupMasterEntry(address, uri); RFuture<RedisClient> future = setupMasterEntry(address, uri);
changeMaster(uri, oldMaster, future); changeMaster(uri, oldMaster, future);
return future;
} }

Loading…
Cancel
Save