@Override
  public void resetPeerList(ConsensusGroupId groupId, List<Peer> correctPeers)
      throws ConsensusException {
    final RaftGroupId raftGroupId = Utils.fromConsensusGroupIdToRaftGroupId(groupId);
    final RaftGroup group = getGroupInfo(raftGroupId);

    if (group == null) {
      throw new ConsensusGroupNotExistException(groupId);
    }

    boolean myselfInCorrectPeers =
        correctPeers.stream()
            .map(
                peer ->
                    Utils.fromNodeInfoAndPriorityToRaftPeer(
                        peer.getNodeId(), peer.getEndpoint(), DEFAULT_PRIORITY))
            .anyMatch(
                raftPeer ->
                    myself.getId().equals(raftPeer.getId())
                        && myself.getAddress().equals(raftPeer.getAddress()));
    if (!myselfInCorrectPeers) {
      logger.info(
          "[RESET PEER LIST] Local peer is not in the correct peer list, delete local peer {}",
          groupId);
      deleteLocalPeer(groupId);
      return;
    }

    final List<RaftPeer> newGroupPeers =
        Utils.fromPeersAndPriorityToRaftPeers(correctPeers, DEFAULT_PRIORITY);
    final RaftGroup newGroup = RaftGroup.valueOf(raftGroupId, newGroupPeers);

    Set<RaftPeer> localRaftPeerSet = new HashSet<>(group.getPeers());
    Set<RaftPeer> correctRaftPeerSet = new HashSet<>(newGroupPeers);
    if (localRaftPeerSet.equals(correctRaftPeerSet)) {
      // configurations are the same
      logger.info(
          "[RESET PEER LIST] The current peer list is correct, nothing need to be reset: {}",
          localRaftPeerSet);
      return;
    }

    logger.info(
        "[RESET PEER LIST] Peer list will be reset from {} to {}",
        localRaftPeerSet,
        correctRaftPeerSet);
    RaftClientReply reply = sendReconfiguration(newGroup);
    if (reply.isSuccess()) {
      logger.info("[RESET PEER LIST] Peer list has been reset to {}", newGroupPeers);
    } else {
      logger.warn(
          "[RESET PEER LIST] Peer list failed to reset to {}, reply is {}", newGroup, reply);
    }
  }
Remove IConsensus Peer from ConsensusGroup with groupId

<p>underlying Ratis will 1. call the AdminApi to notify group leader of this configuration
change
iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/ratis/RatisConsensus.java