public void insertTablets(InsertMultiTabletsNode insertMultiTabletsNode)
      throws BatchProcessException, WriteProcessRejectException {

    StorageEngine.blockInsertionIfReject();
    long startTime = System.nanoTime();
    writeLock("insertTablets");
    PERFORMANCE_OVERVIEW_METRICS.recordScheduleLockCost(System.nanoTime() - startTime);
    try {
      if (deleted) {
        logger.info(
            "Won't insert tablets {}, because region is deleted",
            insertMultiTabletsNode.getSearchIndex());
        return;
      }
      long[] infoForMetrics = new long[5];
      // infoForMetrics[0]: CreateMemtableBlockTimeCost
      // infoForMetrics[1]: ScheduleMemoryBlockTimeCost
      // infoForMetrics[2]: ScheduleWalTimeCost
      // infoForMetrics[3]: ScheduleMemTableTimeCost
      // infoForMetrics[4]: InsertedPointsNumber
      for (int i = 0; i < insertMultiTabletsNode.getInsertTabletNodeList().size(); i++) {
        InsertTabletNode insertTabletNode = insertMultiTabletsNode.getInsertTabletNodeList().get(i);
        TSStatus[] results = new TSStatus[insertTabletNode.getRowCount()];
        Arrays.fill(results, RpcUtils.SUCCESS_STATUS);
        boolean noFailure = false;
        try {
          noFailure = executeInsertTablet(insertTabletNode, results, infoForMetrics);
        } catch (WriteProcessException e) {
          insertMultiTabletsNode
              .getResults()
              .put(i, RpcUtils.getStatus(e.getErrorCode(), e.getMessage()));
        }
        if (!noFailure) {
          // for each error
          TSStatus firstStatus = null;
          for (TSStatus status : results) {
            if (status.getCode() != TSStatusCode.SUCCESS_STATUS.getStatusCode()) {
              firstStatus = status;
            }
            // return WRITE_PROCESS_REJECT directly for the consensus retry logic
            if (status.getCode() == TSStatusCode.WRITE_PROCESS_REJECT.getStatusCode()) {
              insertMultiTabletsNode.getResults().put(i, status);
              throw new BatchProcessException("Rejected inserting multi tablets");
            }
          }
          insertMultiTabletsNode.getResults().put(i, firstStatus);
        }
      }
      updateTsFileProcessorMetric(insertMultiTabletsNode, infoForMetrics);

    } finally {
      writeUnlock();
    }

    if (!insertMultiTabletsNode.getResults().isEmpty()) {
      throw new BatchProcessException("Partial failed inserting multi tablets");
    }
  }
Insert batch of tablets belongs to multiple devices

@param insertMultiTabletsNode batch of tablets belongs to multiple devices
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/DataRegion.java