public TDataNodeRestartResp updateDataNodeIfNecessary(TDataNodeRestartReq req) {
    final String clusterId =
        configManager
            .getClusterManager()
            .getClusterIdWithRetry(
                CommonDescriptor.getInstance().getConfig().getCnConnectionTimeoutInMS() / 2);
    TDataNodeRestartResp resp = new TDataNodeRestartResp();
    resp.setConfigNodeList(getRegisteredConfigNodes());
    if (clusterId == null) {
      resp.setStatus(
          new TSStatus(TSStatusCode.GET_CLUSTER_ID_ERROR.getStatusCode())
              .setMessage("clusterId has not generated"));
      return resp;
    }

    int nodeId = req.getDataNodeConfiguration().getLocation().getDataNodeId();
    TDataNodeConfiguration dataNodeConfiguration = getRegisteredDataNode(nodeId);
    if (!req.getDataNodeConfiguration().equals(dataNodeConfiguration)) {
      // Update DataNodeConfiguration when modified during restart
      UpdateDataNodePlan updateDataNodePlan =
          new UpdateDataNodePlan(req.getDataNodeConfiguration());
      try {
        getConsensusManager().write(updateDataNodePlan);
      } catch (ConsensusException e) {
        LOGGER.warn(CONSENSUS_WRITE_ERROR, e);
      }
    }
    TNodeVersionInfo versionInfo = nodeInfo.getVersionInfo(nodeId);
    if (!req.getVersionInfo().equals(versionInfo)) {
      // Update versionInfo when modified during restart
      UpdateVersionInfoPlan updateVersionInfoPlan =
          new UpdateVersionInfoPlan(req.getVersionInfo(), nodeId);
      try {
        getConsensusManager().write(updateVersionInfoPlan);
      } catch (ConsensusException e) {
        LOGGER.warn(CONSENSUS_WRITE_ERROR, e);
      }
    }

    resp.setStatus(ClusterNodeStartUtils.ACCEPT_NODE_RESTART);
    resp.setRuntimeConfiguration(getRuntimeConfiguration());

    resp.setCorrectConsensusGroups(getPartitionManager().getAllReplicaSets(nodeId));
    return resp;
  }
Register DataNode.

@param req TDataNodeRegisterReq
@return DataNodeConfigurationDataSet. The {@link TSStatus} will be set to {@link
    TSStatusCode#SUCCESS_STATUS} when register success.
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/node/NodeManager.java