code: private CompletableFuture<Long> apply(RegisterEntry entry) {
      // Allow the executor to execute any scheduled events.
      long timestamp = executor.timestamp(entry.getTimestamp());
  
      long sessionId = entry.getIndex();
      ServerSessionContext session = new ServerSessionContext(sessionId, entry.getClient(), log, executor.context(), entry.getTimeout());
  
      ServerSessionContext oldSession = executor.context().sessions().registerSession(session);
  
      // Update the session timestamp *after* executing any scheduled operations. The executor's timestamp
      // is guaranteed to be monotonically increasing, whereas the RegisterEntry may have an earlier timestamp
      // if, e.g., it was written shortly after a leader change.
      session.setTimestamp(timestamp);
  
      // Determine whether any sessions appear to be expired. This won't immediately expire the session(s),
      // but it will make them available to be unregistered by the leader.
      suspectSessions(0, timestamp);
  
      ThreadContext context = ThreadContext.currentContextOrThrow();
      long index = entry.getIndex();
  
      // Call the register() method on the user-provided state machine to allow the state machine to react to
      // a new session being registered. User state machine methods are always called in the state machine thread.
      CompletableFuture<Long> future = new ComposableFuture<>();
      executor.executor().execute(() -> registerSession(index, timestamp, session, oldSession, future, context));
      return future;
    }
docs: Applies register session entry to the state machine.
  <p>
  Register entries are applied to the state machine to create a new session. The resulting session ID is the
  index of the RegisterEntry. Once a new session is registered, we call register() on the state machine.
  In the event that the {@code synchronous} flag is set, that indicates that the registration command expects a
  response, i.e. it was applied by a leader. In that case, any events published during the execution of the
  state machine's register() method must be completed synchronously prior to the completion of the returned future.