code: private void executeCommand(long index, long sequence, long timestamp, ServerCommit commit, ServerSessionContext session, CompletableFuture<Result> future, ThreadContext context) {
      if (!log.isOpen()) {
        context.executor().execute(() -> future.completeExceptionally(new IllegalStateException("log closed")));
        return;
      }
  
      // If the session is already in an inactive state, complete the future exceptionally.
      if (!session.state().active()) {
        context.executor().execute(() -> future.completeExceptionally(new UnknownSessionException("inactive session: " + session.id())));
        return;
      }
  
      // Trigger scheduled callbacks in the state machine.
      executor.tick(index, timestamp);
  
      // Update the state machine context with the commit index and local server context. The synchronous flag
      // indicates whether the server expects linearizable completion of published events. Events will be published
      // based on the configured consistency level for the context.
      executor.init(commit.index(), commit.time(), ServerStateMachineContext.Type.COMMAND);
  
      // Store the event index to return in the command response.
      long eventIndex = session.getEventIndex();
  
      try {
        // Execute the state machine operation and get the result.
        Object output = executor.executeOperation(commit);
  
        // Once the operation has been applied to the state machine, commit events published by the command.
        // The state machine context will build a composite future for events published to all sessions.
        executor.commit();
  
        // Store the result for linearizability and complete the command.
        Result result = new Result(index, eventIndex, output);
        session.registerResult(sequence, result);
        context.executor().execute(() -> future.complete(result));
      } catch (Exception e) {
        // If an exception occurs during execution of the command, store the exception.
        Result result = new Result(index, eventIndex, e);
        session.registerResult(sequence, result);
        context.executor().execute(() -> future.complete(result));
      }
    }
docs: Executes a state machine command.