@Override
  public OptionalLong generateId() {
    if (mustStartNewSequence) {
      initializer.accept(random);
    }
    long id = random.nextLong();
    if (id == firstIdInCurrentSequence) { // The current sequence is exhausted.
      mustStartNewSequence = true; // Remember to start a new sequence on the next call.
      return OptionalLong.empty(); // Alert the caller that this sequence is exhausted.
    }
    if (mustStartNewSequence) {
      firstIdInCurrentSequence = id;
      mustStartNewSequence = false;
    }
    return OptionalLong.of(id);
  }
Constructs an ID generator that uses {@code random} to generate IDs and {@code
randomInitializer} to set the state of the {@code random}. An initializer should attempt to
leave {@code random} in a state distinct from that produced by any other invocation of the
initializer.
geode-core/src/main/java/org/apache/geode/internal/cache/tier/sockets/RandomSubjectIdGenerator.java