[bugfix](fe) fix add follower failed due to conflict socket . (#10429)
This commit is contained in:
@ -2464,10 +2464,12 @@ public class Catalog {
|
||||
|
||||
fe = new Frontend(role, nodeName, host, editLogPort);
|
||||
frontends.put(nodeName, fe);
|
||||
BDBHA bdbha = (BDBHA) haProtocol;
|
||||
if (role == FrontendNodeType.FOLLOWER || role == FrontendNodeType.REPLICA) {
|
||||
((BDBHA) getHaProtocol()).addHelperSocket(host, editLogPort);
|
||||
bdbha.addHelperSocket(host, editLogPort);
|
||||
helperNodes.add(Pair.create(host, editLogPort));
|
||||
}
|
||||
bdbha.removeConflictNodeIfExist(host, editLogPort);
|
||||
editLog.logAddFrontend(fe);
|
||||
} finally {
|
||||
unlock();
|
||||
|
||||
@ -221,4 +221,23 @@ public class BDBHA implements HAProtocol {
|
||||
LOG.info("add {}:{} to helper sockets", ip, port);
|
||||
}
|
||||
}
|
||||
|
||||
public void removeConflictNodeIfExist(String host, int port) {
|
||||
ReplicationGroupAdmin replicationGroupAdmin = environment.getReplicationGroupAdmin();
|
||||
if (replicationGroupAdmin == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> conflictNodes = Lists.newArrayList();
|
||||
Set<ReplicationNode> replicationNodes = replicationGroupAdmin.getGroup().getElectableNodes();
|
||||
for (ReplicationNode replicationNode : replicationNodes) {
|
||||
if (replicationNode.getHostName().equals(host) && replicationNode.getPort() == port) {
|
||||
conflictNodes.add(replicationNode.getName());
|
||||
}
|
||||
}
|
||||
|
||||
for (String conflictNode : conflictNodes) {
|
||||
removeElectableNode(conflictNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user