hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/ContainerStateMachine.java
@Override
  public CompletableFuture<Message> applyTransaction(TransactionContext trx) {
    try {
      ContainerCommandRequestProto requestProto =
          getRequestProto(trx.getSMLogEntry().getData());
      Type cmdType = requestProto.getCmdType();

      if (cmdType == Type.WriteChunk) {
        WriteChunkRequestProto write = requestProto.getWriteChunk();
        // the data field has already been removed in start Transaction
        Preconditions.checkArgument(!write.hasData());
        CompletableFuture<Message> stateMachineFuture =
            writeChunkFutureMap.remove(trx.getLogEntry().getIndex());
        return stateMachineFuture
            .thenComposeAsync(v ->
                CompletableFuture.completedFuture(runCommand(requestProto)));
      } else {
        Message message = runCommand(requestProto);
        if (cmdType == Type.CreateContainer) {
          long containerID = requestProto.getContainerID();
          createContainerFutureMap.remove(containerID).complete(message);
        }
        return CompletableFuture.completedFuture(message);
      }
    } catch (IOException e) {
      return completeExceptionally(e);
    }
  }
/*
   * ApplyTransaction calls in Ratis are sequential.
   */
ApplyTransaction calls in Ratis are sequential.
ApplyTransaction calls in Ratis are sequential .
@Override
  public CompletableFuture<Message> applyTransaction(TransactionContext trx) {
    try {
      ContainerCommandRequestProto requestProto =
          getRequestProto(trx.getSMLogEntry().getData());
      Type cmdType = requestProto.getCmdType();
      if (cmdType == Type.WriteChunk) {
        WriteChunkRequestProto write = requestProto.getWriteChunk();
        Preconditions.checkArgument(!write.hasData());
        CompletableFuture<Message> stateMachineFuture =
            writeChunkFutureMap.remove(trx.getLogEntry().getIndex());
        return stateMachineFuture
            .thenComposeAsync(v ->
                CompletableFuture.completedFuture(runCommand(requestProto)));
      } else {
        Message message = runCommand(requestProto);
        if (cmdType == Type.CreateContainer) {
          long containerID = requestProto.getContainerID();
          createContainerFutureMap.remove(containerID).complete(message);
        }
        return CompletableFuture.completedFuture(message);
      }
    } catch (IOException e) {
      return completeExceptionally(e);
    }
  }
@ Override public CompletableFuture < Message > applyTransaction ( TransactionContext trx ) { try { ContainerCommandRequestProto requestProto = getRequestProto ( trx . getSMLogEntry ( ) . getData ( ) ) ; Type cmdType = requestProto . getCmdType ( ) ; if ( cmdType == Type . WriteChunk ) { WriteChunkRequestProto write = requestProto . getWriteChunk ( ) ; Preconditions . checkArgument ( ! write . hasData ( ) ) ; CompletableFuture < Message > stateMachineFuture = writeChunkFutureMap . remove ( trx . getLogEntry ( ) . getIndex ( ) ) ; return stateMachineFuture . thenComposeAsync ( v -> CompletableFuture . completedFuture ( runCommand ( requestProto ) ) ) ; } else { Message message = runCommand ( requestProto ) ; if ( cmdType == Type . CreateContainer ) { long containerID = requestProto . getContainerID ( ) ; createContainerFutureMap . remove ( containerID ) . complete ( message ) ; } return CompletableFuture . completedFuture ( message ) ; } } catch ( IOException e ) { return completeExceptionally ( e ) ; } }
ApplyTransaction calls in Ratis are sequential.
ApplyTransaction calls in Ratis are sequential .
// the data field has already been removed in start Transaction