public static TDataPartitionTableResp getOrCreateDataPartitionWithRetry(
      String database,
      int seriesSlotStart,
      int seriesSlotEnd,
      long timeSlotStart,
      long timeSlotEnd,
      long timePartitionInterval)
      throws InterruptedException {

    Map<String, Map<TSeriesPartitionSlot, TTimeSlotList>> partitionSlotsMap =
        ConfigNodeTestUtils.constructPartitionSlotsMap(
            database,
            seriesSlotStart,
            seriesSlotEnd,
            timeSlotStart,
            timeSlotEnd,
            timePartitionInterval);
    TDataPartitionTableResp dataPartitionTableResp;
    TDataPartitionReq dataPartitionReq = new TDataPartitionReq(partitionSlotsMap);

    for (int retry = 0; retry < 5; retry++) {
      // Build new Client since it's unstable
      try (SyncConfigNodeIServiceClient configNodeClient =
          (SyncConfigNodeIServiceClient) EnvFactory.getEnv().getLeaderConfigNodeConnection()) {
        dataPartitionTableResp = configNodeClient.getOrCreateDataPartitionTable(dataPartitionReq);
        if (dataPartitionTableResp != null
            && dataPartitionTableResp.getStatus().getCode()
                == TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
          ConfigNodeTestUtils.checkDataPartitionTable(
              database,
              seriesSlotStart,
              seriesSlotEnd,
              timeSlotStart,
              timeSlotEnd,
              timePartitionInterval,
              configNodeClient.getDataPartitionTable(dataPartitionReq).getDataPartitionTable());
          return dataPartitionTableResp;
        }
      } catch (Exception e) {
        // Retry sometimes in order to avoid request timeout
        LOGGER.error(e.getMessage());
        TimeUnit.SECONDS.sleep(1);
      }
    }
    Assert.fail("Failed to create DataPartition");
    return null;
  }
Generate a PatternTree and serialize it into a ByteBuffer
integration-test/src/test/java/org/apache/iotdb/confignode/it/utils/ConfigNodeTestUtils.java