@Override
  public synchronized void handleExit() {
    if (writingFileWriter != null) {
      try {
        writingFileWriter.close();
        LOGGER.info(
            "Receiver id = {}: Handling exit: Writing file writer was closed.", receiverId.get());
      } catch (Exception e) {
        LOGGER.warn(
            "Receiver id = {}: Handling exit: Close writing file writer error.",
            receiverId.get(),
            e);
      }
      writingFileWriter = null;
    } else {
      if (LOGGER.isDebugEnabled()) {
        LOGGER.debug(
            "Receiver id = {}: Handling exit: Writing file writer is null. No need to close.",
            receiverId.get());
      }
    }

    if (writingFile != null) {
      try {
        RetryUtils.retryOnException(() -> FileUtils.delete(writingFile));
        LOGGER.info(
            "Receiver id = {}: Handling exit: Writing file {} was deleted.",
            receiverId.get(),
            writingFile.getPath());
      } catch (Exception e) {
        LOGGER.warn(
            "Receiver id = {}: Handling exit: Delete writing file {} error.",
            receiverId.get(),
            writingFile.getPath(),
            e);
      }
      writingFile = null;
    } else {
      if (LOGGER.isDebugEnabled()) {
        LOGGER.debug(
            "Receiver id = {}: Handling exit: Writing file is null. No need to delete.",
            receiverId.get());
      }
    }

    // Clear the original receiver file dir if exists
    if (receiverFileDirWithIdSuffix.get() != null) {
      if (receiverFileDirWithIdSuffix.get().exists()) {
        try {
          RetryUtils.retryOnException(
              () -> {
                FileUtils.deleteDirectory(receiverFileDirWithIdSuffix.get());
                return null;
              });
          LOGGER.info(
              "Receiver id = {}: Handling exit: Original receiver file dir {} was deleted.",
              receiverId.get(),
              receiverFileDirWithIdSuffix.get().getPath());
        } catch (Exception e) {
          LOGGER.warn(
              "Receiver id = {}: Handling exit: Delete original receiver file dir {} error.",
              receiverId.get(),
              receiverFileDirWithIdSuffix.get().getPath(),
              e);
        }
      } else {
        if (LOGGER.isDebugEnabled()) {
          LOGGER.debug(
              "Receiver id = {}: Handling exit: Original receiver file dir {} does not exist. No need to delete.",
              receiverId.get(),
              receiverFileDirWithIdSuffix.get().getPath());
        }
      }
      receiverFileDirWithIdSuffix.set(null);
    } else {
      if (LOGGER.isDebugEnabled()) {
        LOGGER.debug(
            "Receiver id = {}: Handling exit: Original receiver file dir is null. No need to delete.",
            receiverId.get());
      }
    }

    // Close the session
    closeSession();

    LOGGER.info("Receiver id = {}: Handling exit: Receiver exited.", receiverId.get());
  }
{@link IoTDBFileReceiver} is the parent class of receiver on both configNode and DataNode,
handling all the logic of parallel file receiving.
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/pipe/receiver/IoTDBFileReceiver.java