hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/ContainerStateMachine.java
@Override
  public CompletableFuture<LogEntryProto> readStateMachineData(
      LogEntryProto entry) {
    SMLogEntryProto smLogEntryProto = entry.getSmLogEntry();
    if (!smLogEntryProto.getStateMachineData().isEmpty()) {
      return CompletableFuture.completedFuture(entry);
    }

    try {
      final ContainerCommandRequestProto requestProto =
          getRequestProto(entry.getSmLogEntry().getData());
      // readStateMachineData should only be called for "write" to Ratis.
      Preconditions.checkArgument(!HddsUtils.isReadOnly(requestProto));

      if (requestProto.getCmdType() == Type.WriteChunk) {
        return CompletableFuture.supplyAsync(() ->
                readStateMachineData(smLogEntryProto, requestProto),
            chunkExecutor);
      } else if (requestProto.getCmdType() == Type.CreateContainer) {
        LogEntryProto log =
            recreateLogEntryProto(smLogEntryProto, requestProto.toByteString());
        return CompletableFuture.completedFuture(log);
      } else {
        throw new IllegalStateException("Cmd type:" + requestProto.getCmdType()
            + " cannot have state machine data");
      }
    } catch (Exception e) {
      LOG.error("unable to read stateMachineData:" + e);
      return completeExceptionally(e);
    }
  }
/*
   * This api is used by the leader while appending logs to the follower
   * This allows the leader to read the state machine data from the
   * state machine implementation in case cached state machine data has been
   * evicted.
   */
This api is used by the leader while appending logs to the follower
This allows the leader to read the state machine data from the
state machine implementation in case cached state machine data has been
evicted.
This api is used by the leader while appending logs to the follower This allows the leader to read the state machine data from the state machine implementation in case cached state machine data has been evicted .
@Override
  public CompletableFuture<LogEntryProto> readStateMachineData(
      LogEntryProto entry) {
    SMLogEntryProto smLogEntryProto = entry.getSmLogEntry();
    if (!smLogEntryProto.getStateMachineData().isEmpty()) {
      return CompletableFuture.completedFuture(entry);
    }
    try {
      final ContainerCommandRequestProto requestProto =
          getRequestProto(entry.getSmLogEntry().getData());
      Preconditions.checkArgument(!HddsUtils.isReadOnly(requestProto));
      if (requestProto.getCmdType() == Type.WriteChunk) {
        return CompletableFuture.supplyAsync(() ->
                readStateMachineData(smLogEntryProto, requestProto),
            chunkExecutor);
      } else if (requestProto.getCmdType() == Type.CreateContainer) {
        LogEntryProto log =
            recreateLogEntryProto(smLogEntryProto, requestProto.toByteString());
        return CompletableFuture.completedFuture(log);
      } else {
        throw new IllegalStateException("Cmd type:" + requestProto.getCmdType()
            + " cannot have state machine data");
      }
    } catch (Exception e) {
      LOG.error("unable to read stateMachineData:" + e);
      return completeExceptionally(e);
    }
  }
@ Override public CompletableFuture < LogEntryProto > readStateMachineData ( LogEntryProto entry ) { SMLogEntryProto smLogEntryProto = entry . getSmLogEntry ( ) ; if ( ! smLogEntryProto . getStateMachineData ( ) . isEmpty ( ) ) { return CompletableFuture . completedFuture ( entry ) ; } try { final ContainerCommandRequestProto requestProto = getRequestProto ( entry . getSmLogEntry ( ) . getData ( ) ) ; Preconditions . checkArgument ( ! HddsUtils . isReadOnly ( requestProto ) ) ; if ( requestProto . getCmdType ( ) == Type . WriteChunk ) { return CompletableFuture . supplyAsync ( ( ) -> readStateMachineData ( smLogEntryProto , requestProto ) , chunkExecutor ) ; } else if ( requestProto . getCmdType ( ) == Type . CreateContainer ) { LogEntryProto log = recreateLogEntryProto ( smLogEntryProto , requestProto . toByteString ( ) ) ; return CompletableFuture . completedFuture ( log ) ; } else { throw new IllegalStateException ( "Cmd type:" + requestProto . getCmdType ( ) + " cannot have state machine data" ) ; } } catch ( Exception e ) { LOG . error ( "unable to read stateMachineData:" + e ) ; return completeExceptionally ( e ) ; } }
This api is used by the leader while appending logs to the follower
 This allows the leader to read the state machine data from the
 state machine implementation in case cached state machine data has been
 evicted.
This api is used by the leader while appending logs to the follower This allows the leader to read the state machine data from the state machine implementation in case cached state machine data has been evicted .
// readStateMachineData should only be called for "write" to Ratis.