private void recover() {
    if (CONFIG.getLoadTsFileDirs() != LOAD_BASE_DIRS.get()) {
      synchronized (FOLDER_MANAGER) {
        if (CONFIG.getLoadTsFileDirs() != LOAD_BASE_DIRS.get()) {
          LOAD_BASE_DIRS.set(CONFIG.getLoadTsFileDirs());
        }
      }
    }

    final File[] baseDirs = Arrays.stream(LOAD_BASE_DIRS.get()).map(File::new).toArray(File[]::new);
    final File[] files =
        Arrays.stream(baseDirs)
            .filter(File::exists)
            .flatMap(
                dir -> {
                  final File[] listedFiles = dir.listFiles();
                  return listedFiles != null ? Arrays.stream(listedFiles) : Stream.empty();
                })
            .toArray(File[]::new);

    Arrays.stream(files)
        .parallel()
        .forEach(
            taskDir -> {
              final String uuid = taskDir.getName();
              final TsFileWriterManager writerManager = new TsFileWriterManager(taskDir);

              uuid2WriterManager.put(uuid, writerManager);
              writerManager.close();

              synchronized (uuid2CleanupTask) {
                final CleanupTask cleanupTask =
                    new CleanupTask(
                        uuid, CONFIG.getLoadCleanupTaskExecutionDelayTimeSeconds() * 1000);
                uuid2CleanupTask.put(uuid, cleanupTask);
                cleanupTaskQueue.add(cleanupTask);
              }
            });
  }
{@link LoadTsFileManager} is used for dealing with {@link LoadTsFilePieceNode} and {@link
LoadCommand}. This class turn the content of a piece of loading TsFile into a new TsFile. When
DataNode finish transfer pieces, this class will flush all TsFile and load them into IoTDB, or
delete all.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/load/LoadTsFileManager.java