private Pair<LogSegmentName, String> getNextSegmentNameAndFilename() {
    Pair<LogSegmentName, String> nameAndFilename;
    if (segmentNameAndFileNameIterator != null && segmentNameAndFileNameIterator.hasNext()) {
      nameAndFilename = segmentNameAndFileNameIterator.next();
    } else if (activeSegment == null) {
      // this code path gets exercised only on first startup
      LogSegmentName name = LogSegmentName.generateFirstSegmentName(isLogSegmented);
      nameAndFilename = new Pair<>(name, name.toFilename());
    } else {
      LogSegmentName name = activeSegment.getName().getNextPositionName();
      nameAndFilename = new Pair<>(name, name.toFilename());
    }
    return nameAndFilename;
  }
@return the name and filename of the segment that is to be created.
ambry-store/src/main/java/com/github/ambry/store/Log.java