void addSegment(LogSegment segment, boolean increaseUsedSegmentCount) {
    if (segment.getName().compareTo(activeSegment.getName()) >= 0) {
      throw new IllegalArgumentException(
          "Cannot add segments past the current active segment. Active segment is [" + activeSegment.getName()
              + "]. Tried to add [" + segment.getName() + "]");
    }
    segment.dropBufferForAppend();
    if (increaseUsedSegmentCount) {
      remainingUnallocatedSegments.decrementAndGet();
    }
    segmentsByName.put(segment.getName(), segment);
  }
Adds a {@link LogSegment} instance to the log.
@param segment the {@link LogSegment} instance to add.
@param increaseUsedSegmentCount {@code true} if the number of segments used has to be incremented, {@code false}
                                            otherwise.
@throws IllegalArgumentException if the {@code segment} being added is past the active segment
ambry-store/src/main/java/com/github/ambry/store/Log.java