private void rollOverIfRequired(long writeSize) throws StoreException {
    if (activeSegment.getCapacityInBytes() - activeSegment.getEndOffset() < writeSize) {
      ensureCapacity(writeSize);
      setActiveSegment(writeSize, false);
    }
  }
Rolls the active log segment over if required. If rollover is required, a new segment is allocated.
@param writeSize the size of the incoming write.
@throws IllegalArgumentException if the {@code writeSize} is greater than a single segment's size
@throws IllegalStateException if there is no more capacity in the log.
@throws StoreException if any store exception occurred as part of ensuring capacity.
ambry-store/src/main/java/com/github/ambry/store/Log.java