private void checkSanity(CompactionDetails details) {
    List<LogSegmentName> segmentsUnderCompaction = details.getLogSegmentsUnderCompaction();
    // 1. all segments should be available
    // 2. all segments should be in order
    // 3. all segments should be a list of continuous log segments without skipping anyone in the middle
    // 4. all segments should not have anything in the journal
    LogSegmentName prevSegmentName = null;
    for (LogSegmentName segmentName : segmentsUnderCompaction) {
      LogSegment segment = srcLog.getSegment(segmentName);
      if (segment == null) {
        throw new IllegalArgumentException(segmentName + " does not exist in the log");
      }
      if (prevSegmentName != null && prevSegmentName.compareTo(segmentName) >= 0) {
        throw new IllegalArgumentException("Ordering of " + segmentsUnderCompaction + " is incorrect");
      }
      if (prevSegmentName != null && !prevSegmentName.equals(srcLog.getPrevSegment(segment).getName())) {
        throw new IllegalArgumentException(
            segmentsUnderCompaction + " is incorrect because it's not continuous. " + segment.getName()
                + "'s previous log segment should be " + srcLog.getPrevSegment(segment).getName() + " not "
                + prevSegmentName);
      }
      // should be outside the range of the journal
      Offset segmentEndOffset = new Offset(segment.getName(), segment.getEndOffset());
      Offset journalFirstOffset = srcIndex.journal.getFirstOffset();
      if (journalFirstOffset != null && segmentEndOffset.compareTo(journalFirstOffset) >= 0) {
        throw new IllegalArgumentException("Some of the offsets provided for compaction are within the journal");
      }
      prevSegmentName = segment.getName();
    }
  }
Checks the sanity of the provided {@code details}
@param details the {@link CompactionDetails} to use for compaction.
@throws IllegalArgumentException if any of the provided segments doesn't exist in the log or if one or more offsets
in the segments to compact are in the journal.
ambry-store/src/main/java/com/github/ambry/store/BlobStoreCompactor.java