private void cleanupTasks() {
    while (!cleanupTaskQueue.isEmpty()) {
      synchronized (uuid2CleanupTask) {
        if (cleanupTaskQueue.isEmpty()) {
          continue;
        }

        final CleanupTask cleanupTask = cleanupTaskQueue.peek();
        if (cleanupTask.scheduledTime <= System.currentTimeMillis()) {
          if (cleanupTask.isLoadTaskRunning) {
            cleanupTaskQueue.poll();
            cleanupTask.resetScheduledTime();
            cleanupTaskQueue.add(cleanupTask);
            continue;
          }

          cleanupTask.run();

          uuid2CleanupTask.remove(cleanupTask.uuid);
          cleanupTaskQueue.poll();
        } else {
          final long waitTimeInMs = cleanupTask.scheduledTime - System.currentTimeMillis();
          LOGGER.info(
              "Next load cleanup task {} is not ready to run, wait for at least {} ms ({}s).",
              cleanupTask.uuid,
              waitTimeInMs,
              waitTimeInMs / 1000.0);
          return;
        }
      }
    }
  }
{@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