private void endCompaction() throws StoreException {
    if (compactionLog != null) {
      if (compactionLog.getCompactionPhase().equals(CompactionLog.Phase.DONE)) {
        logger.info("[CAPACITY] Compaction of {} finished", storeId);
        if (srcIndex != null && !srcIndex.isEmpty() && !compactionLog.cycleLogs.isEmpty()) {
          // The log segment positions after compaction
          Set<Long> logSegmentPositionsAfterCompaction = srcIndex.getLogSegments()
              .stream()
              .map(LogSegment::getName)
              .map(LogSegmentName::getPosition)
              .collect(Collectors.toSet());
          logSegmentCount.set(logSegmentPositionsAfterCompaction.size());
          // The log segment positions under compaction
          Set<Long> logSegmentPositionsUnderCompaction = new HashSet<>();
          for (CompactionLog.CycleLog clog : compactionLog.cycleLogs) {
            logSegmentPositionsUnderCompaction.addAll(clog.compactionDetails.getLogSegmentsUnderCompaction()
                .stream()
                .map(LogSegmentName::getPosition)
                .collect(Collectors.toSet()));
          }
          // If the position under compaction doesn't exist in the set after compaction, then this log segment is compacted
          // eg: log segment under compaction [0_23, 130_16, 144_3]
          //     log segment after compaction [0_24, 130_24, 155_0, 166_0]
          // log segment 144_3's position doesn't exist in the compaction log, so we have one log segment compacted.
          compactedLogCount.set((int) logSegmentPositionsUnderCompaction.stream()
              .filter(p -> !logSegmentPositionsAfterCompaction.contains(p))
              .count());

          srcIndex.updatePartialLogSegmentInfo();
        }

        if (srcIndex != null && srcIndex.hardDeleter != null) {
          srcIndex.hardDeleter.resume();
        }
      } else {
        logger.info("Compaction of {} suspended", storeId);
      }
      compactionLog.close();
      compactionLog = null;
    }
  }
Ends compaction by closing the compaction log if it exists.
ambry-store/src/main/java/com/github/ambry/store/BlobStoreCompactor.java