public List<TSStatus> setConfiguration(TSetConfigurationReq req) {
    List<TSStatus> responseList = new ArrayList<>();

    Map<Integer, TDataNodeLocation> dataNodeLocationMap =
        configManager.getNodeManager().getRegisteredDataNodeLocations();
    Map<Integer, TDataNodeLocation> targetDataNodes = new HashMap<>();
    int nodeId = req.getNodeId();
    // send to datanode
    if (dataNodeLocationMap.containsKey(nodeId)) {
      targetDataNodes.put(nodeId, dataNodeLocationMap.get(nodeId));
    } else if (nodeId < 0) {
      targetDataNodes.putAll(dataNodeLocationMap);
    }
    if (!targetDataNodes.isEmpty()) {
      DataNodeAsyncRequestContext<Object, TSStatus> clientHandler =
          new DataNodeAsyncRequestContext<>(
              CnToDnAsyncRequestType.SET_CONFIGURATION, req, dataNodeLocationMap);
      CnToDnInternalServiceAsyncRequestManager.getInstance()
          .sendAsyncRequestWithRetry(clientHandler);
      responseList.addAll(clientHandler.getResponseList());
    }

    // send to config node
    List<TConfigNodeLocation> configNodes = getRegisteredConfigNodes();
    for (TConfigNodeLocation configNode : configNodes) {
      if (configNode.getConfigNodeId() == CONF.getConfigNodeId()) {
        continue;
      }
      if (nodeId >= 0 && nodeId != configNode.getConfigNodeId()) {
        continue;
      }
      TSStatus status = null;
      try {
        status =
            (TSStatus)
                SyncConfigNodeClientPool.getInstance()
                    .sendSyncRequestToConfigNodeWithRetry(
                        configNode.getInternalEndPoint(),
                        new TSetConfigurationReq(req.getConfigs(), configNode.getConfigNodeId()),
                        CnToCnNodeRequestType.SET_CONFIGURATION);
      } catch (Exception e) {
        status =
            RpcUtils.getStatus(
                TSStatusCode.EXECUTE_STATEMENT_ERROR.getStatusCode(), e.getMessage());
      }
      responseList.add(status);
    }
    return responseList;
  }
Only leader use this interface, check the ConfigNode before remove it.

@param removeConfigNodePlan RemoveConfigNodePlan
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java