hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/states/endpoint/HeartbeatEndpointTask.java
private void processResponse(SCMHeartbeatResponseProto response,
      final DatanodeDetailsProto datanodeDetails) {
    for (SCMCommandResponseProto commandResponseProto : response
        .getCommandsList()) {
      // Verify the response is indeed for this datanode.
      Preconditions.checkState(commandResponseProto.getDatanodeUUID()
          .equalsIgnoreCase(datanodeDetails.getUuid()),
          "Unexpected datanode ID in the response.");
      switch (commandResponseProto.getCmdType()) {
      case sendContainerReport:
        this.context.addCommand(SendContainerCommand.getFromProtobuf(
            commandResponseProto.getSendReport()));
        break;
      case reregisterCommand:
        if (rpcEndpoint.getState() == EndPointStates.HEARTBEAT) {
          if (LOG.isDebugEnabled()) {
            LOG.debug("Received SCM notification to register."
                + " Interrupt HEARTBEAT and transit to REGISTER state.");
          }
          rpcEndpoint.setState(EndPointStates.REGISTER);
        } else {
          if (LOG.isDebugEnabled()) {
            LOG.debug("Illegal state {} found, expecting {}.",
                rpcEndpoint.getState().name(), EndPointStates.HEARTBEAT);
          }
        }
        break;
      case deleteBlocksCommand:
        DeleteBlocksCommand db = DeleteBlocksCommand
            .getFromProtobuf(commandResponseProto.getDeleteBlocksProto());
        if (!db.blocksTobeDeleted().isEmpty()) {
          if (LOG.isDebugEnabled()) {
            LOG.debug(DeletedContainerBlocksSummary
                .getFrom(db.blocksTobeDeleted())
                .toString());
          }
          this.context.addCommand(db);
        }
        break;
      case closeContainerCommand:
        CloseContainerCommand closeContainer =
            CloseContainerCommand.getFromProtobuf(
                commandResponseProto.getCloseContainerProto());
        if (LOG.isDebugEnabled()) {
          LOG.debug("Received SCM container close request for container {}",
              closeContainer.getContainerName());
        }
        this.context.addCommand(closeContainer);
        break;
      default:
        throw new IllegalArgumentException("Unknown response : "
            + commandResponseProto.getCmdType().name());
      }
    }
  }
/**
   * Add this command to command processing Queue.
   *
   * @param response - SCMHeartbeat response.
   */
Add this command to command processing Queue.
@param response - SCMHeartbeat response.
Add this command to command processing Queue . @param response - SCMHeartbeat response .
private void processResponse(SCMHeartbeatResponseProto response,
      final DatanodeDetailsProto datanodeDetails) {
    for (SCMCommandResponseProto commandResponseProto : response
        .getCommandsList()) {
      Preconditions.checkState(commandResponseProto.getDatanodeUUID()
          .equalsIgnoreCase(datanodeDetails.getUuid()),
          "Unexpected datanode ID in the response.");
      switch (commandResponseProto.getCmdType()) {
      case sendContainerReport:
        this.context.addCommand(SendContainerCommand.getFromProtobuf(
            commandResponseProto.getSendReport()));
        break;
      case reregisterCommand:
        if (rpcEndpoint.getState() == EndPointStates.HEARTBEAT) {
          if (LOG.isDebugEnabled()) {
            LOG.debug("Received SCM notification to register."
                + " Interrupt HEARTBEAT and transit to REGISTER state.");
          }
          rpcEndpoint.setState(EndPointStates.REGISTER);
        } else {
          if (LOG.isDebugEnabled()) {
            LOG.debug("Illegal state {} found, expecting {}.",
                rpcEndpoint.getState().name(), EndPointStates.HEARTBEAT);
          }
        }
        break;
      case deleteBlocksCommand:
        DeleteBlocksCommand db = DeleteBlocksCommand
            .getFromProtobuf(commandResponseProto.getDeleteBlocksProto());
        if (!db.blocksTobeDeleted().isEmpty()) {
          if (LOG.isDebugEnabled()) {
            LOG.debug(DeletedContainerBlocksSummary
                .getFrom(db.blocksTobeDeleted())
                .toString());
          }
          this.context.addCommand(db);
        }
        break;
      case closeContainerCommand:
        CloseContainerCommand closeContainer =
            CloseContainerCommand.getFromProtobuf(
                commandResponseProto.getCloseContainerProto());
        if (LOG.isDebugEnabled()) {
          LOG.debug("Received SCM container close request for container {}",
              closeContainer.getContainerName());
        }
        this.context.addCommand(closeContainer);
        break;
      default:
        throw new IllegalArgumentException("Unknown response : "
            + commandResponseProto.getCmdType().name());
      }
    }
  }
private void processResponse ( SCMHeartbeatResponseProto response , final DatanodeDetailsProto datanodeDetails ) { for ( SCMCommandResponseProto commandResponseProto : response . getCommandsList ( ) ) { Preconditions . checkState ( commandResponseProto . getDatanodeUUID ( ) . equalsIgnoreCase ( datanodeDetails . getUuid ( ) ) , "Unexpected datanode ID in the response." ) ; switch ( commandResponseProto . getCmdType ( ) ) { case sendContainerReport : this . context . addCommand ( SendContainerCommand . getFromProtobuf ( commandResponseProto . getSendReport ( ) ) ) ; break ; case reregisterCommand : if ( rpcEndpoint . getState ( ) == EndPointStates . HEARTBEAT ) { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Received SCM notification to register." + " Interrupt HEARTBEAT and transit to REGISTER state." ) ; } rpcEndpoint . setState ( EndPointStates . REGISTER ) ; } else { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Illegal state {} found, expecting {}." , rpcEndpoint . getState ( ) . name ( ) , EndPointStates . HEARTBEAT ) ; } } break ; case deleteBlocksCommand : DeleteBlocksCommand db = DeleteBlocksCommand . getFromProtobuf ( commandResponseProto . getDeleteBlocksProto ( ) ) ; if ( ! db . blocksTobeDeleted ( ) . isEmpty ( ) ) { if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( DeletedContainerBlocksSummary . getFrom ( db . blocksTobeDeleted ( ) ) . toString ( ) ) ; } this . context . addCommand ( db ) ; } break ; case closeContainerCommand : CloseContainerCommand closeContainer = CloseContainerCommand . getFromProtobuf ( commandResponseProto . getCloseContainerProto ( ) ) ; if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Received SCM container close request for container {}" , closeContainer . getContainerName ( ) ) ; } this . context . addCommand ( closeContainer ) ; break ; default : throw new IllegalArgumentException ( "Unknown response : " + commandResponseProto . getCmdType ( ) . name ( ) ) ; } } }
Add this command to command processing Queue.
Add this command to command processing Queue .
// Verify the response is indeed for this datanode.