private void setActiveSegment(long writeSize, boolean isAutoClosed) throws StoreException {
    // this cannot be null since capacity has either been ensured or has thrown.
    LogSegment nextActiveSegment = segmentsByName.higherEntry(activeSegment.getName()).getValue();
    if (isAutoClosed) {
      logger.info("DataDir: {}, Auto close last log segment: {} and create new active segment : {}", dataDir,
          activeSegment.getName(), nextActiveSegment.getName());
    } else {
      logger.info(
          "DataDir: {}, Rolling over writes to {} from {} on write of data of size {}. End offset was {} and capacity is {}",
          dataDir, nextActiveSegment.getName(), activeSegment.getName(), writeSize, activeSegment.getEndOffset(),
          activeSegment.getCapacityInBytes());
    }
    activeSegment.dropBufferForAppend();
    nextActiveSegment.initBufferForAppend();
    activeSegment = nextActiveSegment;
  }
Set the last log segment as active segment and init buffer for append.
@param writeSize the size of the incoming write.
@param isAutoClosed {@code True} if the log segment is closed automatically during compaction. {@code False} otherwise.
@throws StoreException
ambry-store/src/main/java/com/github/ambry/store/Log.java