public static void flushDataRegionIfNeeded() {
    if (PROGRESS_REPORT_COUNT.get() > 0
        && PROGRESS_REPORT_COUNT.get()
            > PipeConfig.getInstance().getPipeFlushAfterTerminateCount()) {
      flushDataRegion();
      return;
    }

    if (LAST_PROGRESS_REPORT_TIME.get() > 0
        && System.currentTimeMillis() - LAST_PROGRESS_REPORT_TIME.get()
            > PipeConfig.getInstance().getPipeFlushAfterLastTerminateSeconds() * 1000L) {
      flushDataRegion();
    }
  }
The {@link PipeTerminateEvent} is an {@link EnrichedEvent} that controls the termination of pipe,
that is, when the historical {@link PipeTsFileInsertionEvent}s are all processed, this will be
reported next and mark the {@link PipeDataNodeTask} as completed. WARNING: This event shall never
be discarded.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/pipe/event/common/terminate/PipeTerminateEvent.java