private void processResponse()

in hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/states/endpoint/HeartbeatEndpointTask.java [269:390]


  private void processResponse(SCMHeartbeatResponseProto response,
      final DatanodeDetailsProto datanodeDetails) {
    Preconditions.checkState(response.getDatanodeUUID()
            .equalsIgnoreCase(datanodeDetails.getUuid()),
        "Unexpected datanode ID in the response.");
    if (response.hasTerm()) {
      context.updateTermOfLeaderSCM(response.getTerm());
    }
    // Verify the response is indeed for this datanode.
    for (SCMCommandProto commandResponseProto : response.getCommandsList()) {
      switch (commandResponseProto.getCommandType()) {
      case reregisterCommand:
        processReregisterCommand();
        break;
      case deleteBlocksCommand:
        DeleteBlocksCommand deleteBlocksCommand = DeleteBlocksCommand
            .getFromProtobuf(
                commandResponseProto.getDeleteBlocksCommandProto());
        if (!deleteBlocksCommand.blocksTobeDeleted().isEmpty()) {
          if (LOG.isDebugEnabled()) {
            LOG.debug(DeletedContainerBlocksSummary
                .getFrom(deleteBlocksCommand.blocksTobeDeleted())
                .toString());
          }
          processCommonCommand(commandResponseProto, deleteBlocksCommand);
        }
        break;
      case closeContainerCommand:
        CloseContainerCommand closeContainer =
            CloseContainerCommand.getFromProtobuf(
                commandResponseProto.getCloseContainerCommandProto());
        if (LOG.isDebugEnabled()) {
          LOG.debug("Received SCM container close request for container {}",
              closeContainer.getContainerID());
        }
        processCommonCommand(commandResponseProto, closeContainer);
        break;
      case replicateContainerCommand:
        ReplicateContainerCommand replicateContainerCommand =
            ReplicateContainerCommand.getFromProtobuf(
                commandResponseProto.getReplicateContainerCommandProto());
        if (LOG.isDebugEnabled()) {
          LOG.debug("Received SCM container replicate request for container {}",
              replicateContainerCommand.getContainerID());
        }
        processCommonCommand(commandResponseProto, replicateContainerCommand);
        break;
      case reconstructECContainersCommand:
        ReconstructECContainersCommand reccc =
            ReconstructECContainersCommand.getFromProtobuf(
                commandResponseProto.getReconstructECContainersCommandProto());
        if (LOG.isDebugEnabled()) {
          LOG.debug("Received SCM reconstruct request for container {}",
              reccc.getContainerID());
        }
        processCommonCommand(commandResponseProto, reccc);
        break;
      case deleteContainerCommand:
        DeleteContainerCommand deleteContainerCommand =
            DeleteContainerCommand.getFromProtobuf(
                commandResponseProto.getDeleteContainerCommandProto());
        if (LOG.isDebugEnabled()) {
          LOG.debug("Received SCM delete container request for container {}",
              deleteContainerCommand.getContainerID());
        }
        processCommonCommand(commandResponseProto, deleteContainerCommand);
        break;
      case createPipelineCommand:
        CreatePipelineCommand createPipelineCommand =
            CreatePipelineCommand.getFromProtobuf(
                commandResponseProto.getCreatePipelineCommandProto());
        if (LOG.isDebugEnabled()) {
          LOG.debug("Received SCM create pipeline request {}",
              createPipelineCommand.getPipelineID());
        }
        processCommonCommand(commandResponseProto, createPipelineCommand);
        break;
      case closePipelineCommand:
        ClosePipelineCommand closePipelineCommand =
            ClosePipelineCommand.getFromProtobuf(
                commandResponseProto.getClosePipelineCommandProto());
        if (LOG.isDebugEnabled()) {
          LOG.debug("Received SCM close pipeline request {}",
              closePipelineCommand.getPipelineID());
        }
        processCommonCommand(commandResponseProto, closePipelineCommand);
        break;
      case setNodeOperationalStateCommand:
        SetNodeOperationalStateCommand setNodeOperationalStateCommand =
            SetNodeOperationalStateCommand.getFromProtobuf(
                commandResponseProto.getSetNodeOperationalStateCommandProto());
        if (LOG.isDebugEnabled()) {
          LOG.debug("Received SCM set operational state command. State: {} " +
              "Expiry: {}", setNodeOperationalStateCommand.getOpState(),
              setNodeOperationalStateCommand.getStateExpiryEpochSeconds());
        }
        processCommonCommand(commandResponseProto,
            setNodeOperationalStateCommand);
        break;
      case finalizeNewLayoutVersionCommand:
        FinalizeNewLayoutVersionCommand finalizeNewLayoutVersionCommand =
            FinalizeNewLayoutVersionCommand.getFromProtobuf(
                commandResponseProto.getFinalizeNewLayoutVersionCommandProto());
        if (LOG.isDebugEnabled()) {
          LOG.debug("Received SCM finalize command {}",
              finalizeNewLayoutVersionCommand.getId());
        }
        processCommonCommand(commandResponseProto,
            finalizeNewLayoutVersionCommand);
        break;
      case refreshVolumeUsageInfo:
        RefreshVolumeUsageCommand refreshVolumeUsageCommand =
            RefreshVolumeUsageCommand.getFromProtobuf(
            commandResponseProto.getRefreshVolumeUsageCommandProto());
        processCommonCommand(commandResponseProto, refreshVolumeUsageCommand);
        break;
      default:
        throw new IllegalArgumentException("Unknown response : "
            + commandResponseProto.getCommandType().name());
      }
    }
  }