funky-eyes commented on code in PR #6326: URL: https://github.com/apache/incubator-seata/pull/6326#discussion_r1512019579
########## server/src/main/java/org/apache/seata/server/cluster/raft/RaftStateMachine.java: ########## @@ -231,21 +244,48 @@ public void onStopFollowing(final LeaderChangeContext ctx) { public void onStartFollowing(final LeaderChangeContext ctx) { LOGGER.info("groupId: {}, onStartFollowing: {}.", group, ctx); this.currentTerm.set(ctx.getTerm()); + CompletableFuture.runAsync(() -> syncCurrentNodeInfo(ctx.getLeaderId())); } @Override public void onConfigurationCommitted(Configuration conf) { LOGGER.info("groupId: {}, onConfigurationCommitted: {}.", group, conf); - syncMetadata(); RouteTable.getInstance().updateConfiguration(group, conf); + if (isLeader()) { + lock.lock(); + try { + List<PeerId> newFollowers = conf.getPeers(); + Set<PeerId> newLearners = conf.getLearners(); + List<Node> currentFollowers = raftClusterMetadata.getFollowers(); + if (CollectionUtils.isNotEmpty(newFollowers)) { + raftClusterMetadata.setFollowers(currentFollowers.stream() + .filter(node -> contains(node, newFollowers)).collect(Collectors.toList())); + } + if (CollectionUtils.isNotEmpty(newLearners)) { + raftClusterMetadata.setLearner(raftClusterMetadata.getLearner().stream() + .filter(node -> contains(node, newLearners)).collect(Collectors.toList())); + } Review Comment: > Why not just override followers and learners, e.g., `raftClusterMetadata.setFollowers(newFollowers)` Because the peerid in the raft is the port on which only the raft is elected and synchronized, and no other port information for the server exists, it cannot be used directly and needs to be identified -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@seata.apache.org For additional commands, e-mail: notifications-h...@seata.apache.org