static void cleanupCompactionLogs(String dir, String storeId, long beforeTime) {
    List<File> sortedFiles = getCompactedLogFilesInDescendingOrder(dir, storeId);
    if (sortedFiles.isEmpty()) {
      logger.info("{}: No compaction log to cleanup", storeId);
      return;
    }
    // The list is in descending order, the most recent compaction logs are in the front, we have to reverse the list
    for (int i = sortedFiles.size() - 1; i >= 0; i--) {
      File compactionFile = sortedFiles.get(i);
      long startTime = getStartTimeFromFile(compactionFile);
      if (startTime >= beforeTime) {
        break;
      } else {
        logger.info("{}: Removing compaction file: {}, cutoff time: {}", storeId, compactionFile.getName(), beforeTime);
        compactionFile.delete();
      }
    }
  }
Remove all the compaction files that are started before the given {@code beforeTime}.
@param dir The data dir that contains all the compaction log files.
@param storeId The store id.
@param beforeTime The cutoff time. Compaction log file started before this time will be removed.
ambry-store/src/main/java/com/github/ambry/store/CompactionLog.java