public TSStatus transportFile(final TSyncTransportMetaInfo metaInfo, final ByteBuffer buff)
      throws TException {
    // step1. check connection
    final SyncIdentityInfo identityInfo = getCurrentSyncIdentityInfo();
    if (identityInfo == null) {
      throw new TException("Thrift connection is not alive.");
    }
    LOGGER.debug(
        "Invoke transportData method from client ip = {}", identityInfo.getRemoteAddress());

    final String fileDir = getFileDataDir(identityInfo);
    final String fileName = metaInfo.fileName;
    final long startIndex = metaInfo.startIndex;
    final File file = new File(fileDir, fileName + PATCH_SUFFIX);

    // step2. check startIndex
    final IndexCheckResult result = checkStartIndexValid(new File(fileDir, fileName), startIndex);
    if (!result.isResult()) {
      return RpcUtils.getStatus(TSStatusCode.SYNC_FILE_REDIRECTION_ERROR, result.getIndex());
    }

    // step3. append file
    try (final RandomAccessFile randomAccessFile = new RandomAccessFile(file, "rw")) {
      final int length = buff.remaining();
      randomAccessFile.seek(startIndex);
      final byte[] byteArray = new byte[length];
      buff.get(byteArray);
      randomAccessFile.write(byteArray);
      recordStartIndex(new File(fileDir, fileName), startIndex + length);
      LOGGER.debug("Sync {} start at {} to {} is done.", fileName, startIndex, startIndex + length);
    } catch (final IOException e) {
      LOGGER.error(e.getMessage());
      return RpcUtils.getStatus(TSStatusCode.SYNC_FILE_ERROR, e.getMessage());
    }

    return RpcUtils.getStatus(TSStatusCode.SUCCESS_STATUS, "");
  }
Receive TsFile based on startIndex.

@return {@link TSStatusCode#SUCCESS_STATUS} if receive successfully; {@link
    TSStatusCode#SYNC_FILE_REDIRECTION_ERROR} if startIndex needs to rollback because
    mismatched; {@link TSStatusCode#SYNC_FILE_ERROR} if fail to receive file.
@throws TException The connection between the sender and the receiver has not been established
    by {@link IoTDBLegacyPipeReceiverAgent#handshake}
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/receiver/protocol/legacy/IoTDBLegacyPipeReceiverAgent.java