private TSStatus consensusWritePartitionResult(ConfigPhysicalPlan plan) {
    TSStatus status = getConsensusManager().confirmLeader();
    if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
      // Here we check the leadership second time
      // since the RegionGroup creating process might take some time
      return status;
    }
    try {
      return getConsensusManager().write(plan);
    } catch (ConsensusException e) {
      // The allocation might fail due to consensus error
      LOGGER.error("Write partition allocation result failed because: {}", status);
      TSStatus res = new TSStatus(TSStatusCode.EXECUTE_STATEMENT_ERROR.getStatusCode());
      res.setMessage(e.getMessage());
      return res;
    }
  }
Get DataPartition and create a new one if it does not exist.

@param req DataPartitionPlan with Map{@literal <}StorageGroupName, Map{@literal
    <}SeriesPartitionSlot, List{@literal <}TimePartitionSlot{@literal >}{@literal >}{@literal
    >}
@return DataPartitionResp with DataPartition and {@link TSStatus}. {@link
    TSStatusCode#SUCCESS_STATUS} if all process finish. {@link TSStatusCode#NO_ENOUGH_DATANODE}
    if the DataNodes is not enough to create new Regions. {@link
    TSStatusCode#DATABASE_NOT_EXIST} if some database does not exist.
iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java