Class HddsDispatcher

java.lang.Object
org.apache.hadoop.ozone.container.common.impl.HddsDispatcher
All Implemented Interfaces:
org.apache.hadoop.ozone.audit.Auditor, ContainerDispatcher

public class HddsDispatcher extends Object implements ContainerDispatcher, org.apache.hadoop.ozone.audit.Auditor
Ozone Container dispatcher takes a call from the netty server and routes it to the right handler function.
  • Constructor Summary

    Constructors
    Constructor
    Description
    HddsDispatcher(org.apache.hadoop.hdds.conf.ConfigurationSource config, ContainerSet contSet, VolumeSet volumes, Map<org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerType,Handler> handlers, StateContext context, ContainerMetrics metrics, org.apache.hadoop.hdds.security.token.TokenVerifier tokenVerifier)
    Constructs an OzoneContainer that receives calls from XceiverServerHandler.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.apache.hadoop.ozone.audit.AuditMessage
    buildAuditMessageForFailure(org.apache.hadoop.ozone.audit.AuditAction op, Map<String,String> auditMap, Throwable throwable)
     
    org.apache.hadoop.ozone.audit.AuditMessage
    buildAuditMessageForPerformance(org.apache.hadoop.ozone.audit.AuditAction op, Map<String,String> auditMap, org.apache.hadoop.ozone.audit.AuditLogger.PerformanceStringBuilder performance)
     
    org.apache.hadoop.ozone.audit.AuditMessage
    buildAuditMessageForSuccess(org.apache.hadoop.ozone.audit.AuditAction op, Map<String,String> auditMap)
     
    void
    finds and builds the missing containers in case of a lost disk etc in the ContainerSet.
    org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandResponseProto
    dispatch(org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandRequestProto msg, DispatcherContext dispatcherContext)
    Dispatches commands to container layer.
    getContainer(long containerID)
     
    getHandler(org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerType containerType)
    Returns the handler for the specified containerType.
     
    org.apache.ratis.statemachine.StateMachine.DataChannel
    getStreamDataChannel(org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandRequestProto msg)
    When uploading using stream, get StreamDataChannel.
    void
    Initialize the Dispatcher.
    void
    setClusterId(String clusterId)
    If cluster ID is not set, this will set cluster ID, otherwise it is a no-op.
    void
     
    void
    Shutdown Dispatcher services.
    void
    validateContainerCommand(org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandRequestProto msg)
    This will be called as a part of creating the log entry during startTransaction in Ratis on the leader node.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • HddsDispatcher

      public HddsDispatcher(org.apache.hadoop.hdds.conf.ConfigurationSource config, ContainerSet contSet, VolumeSet volumes, Map<org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerType,Handler> handlers, StateContext context, ContainerMetrics metrics, org.apache.hadoop.hdds.security.token.TokenVerifier tokenVerifier)
      Constructs an OzoneContainer that receives calls from XceiverServerHandler.
  • Method Details

    • init

      public void init()
      Description copied from interface: ContainerDispatcher
      Initialize the Dispatcher.
      Specified by:
      init in interface ContainerDispatcher
    • shutdown

      public void shutdown()
      Description copied from interface: ContainerDispatcher
      Shutdown Dispatcher services.
      Specified by:
      shutdown in interface ContainerDispatcher
    • buildMissingContainerSetAndValidate

      public void buildMissingContainerSetAndValidate(Map<Long,Long> container2BCSIDMap)
      Description copied from interface: ContainerDispatcher
      finds and builds the missing containers in case of a lost disk etc in the ContainerSet. It also validates the BCSID of the containers found.
      Specified by:
      buildMissingContainerSetAndValidate in interface ContainerDispatcher
    • dispatch

      public org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandResponseProto dispatch(org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandRequestProto msg, DispatcherContext dispatcherContext)
      Description copied from interface: ContainerDispatcher
      Dispatches commands to container layer.
      Specified by:
      dispatch in interface ContainerDispatcher
      Parameters:
      msg - - Command Request
      dispatcherContext - - Context info related to ContainerStateMachine
      Returns:
      Command Response
    • validateContainerCommand

      public void validateContainerCommand(org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandRequestProto msg) throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
      This will be called as a part of creating the log entry during startTransaction in Ratis on the leader node. In such cases, if the container is not in open state for writing we should just fail. Leader will propagate the exception to client.
      Specified by:
      validateContainerCommand in interface ContainerDispatcher
      Parameters:
      msg - container command proto
      Throws:
      org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException - In case container state is open for write requests and in invalid state for read requests.
    • getHandler

      public Handler getHandler(org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerType containerType)
      Description copied from interface: ContainerDispatcher
      Returns the handler for the specified containerType.
      Specified by:
      getHandler in interface ContainerDispatcher
      Parameters:
      containerType -
    • setClusterId

      public void setClusterId(String clusterId)
      Description copied from interface: ContainerDispatcher
      If cluster ID is not set, this will set cluster ID, otherwise it is a no-op.
      Specified by:
      setClusterId in interface ContainerDispatcher
      Parameters:
      clusterId -
    • getContainer

      public Container getContainer(long containerID)
    • getMissingContainerSet

      public Set<Long> getMissingContainerSet()
    • setMetricsForTesting

      public void setMetricsForTesting(ContainerMetrics containerMetrics)
    • buildAuditMessageForPerformance

      public org.apache.hadoop.ozone.audit.AuditMessage buildAuditMessageForPerformance(org.apache.hadoop.ozone.audit.AuditAction op, Map<String,String> auditMap, org.apache.hadoop.ozone.audit.AuditLogger.PerformanceStringBuilder performance)
    • buildAuditMessageForSuccess

      public org.apache.hadoop.ozone.audit.AuditMessage buildAuditMessageForSuccess(org.apache.hadoop.ozone.audit.AuditAction op, Map<String,String> auditMap)
      Specified by:
      buildAuditMessageForSuccess in interface org.apache.hadoop.ozone.audit.Auditor
    • buildAuditMessageForFailure

      public org.apache.hadoop.ozone.audit.AuditMessage buildAuditMessageForFailure(org.apache.hadoop.ozone.audit.AuditAction op, Map<String,String> auditMap, Throwable throwable)
      Specified by:
      buildAuditMessageForFailure in interface org.apache.hadoop.ozone.audit.Auditor
    • getStreamDataChannel

      public org.apache.ratis.statemachine.StateMachine.DataChannel getStreamDataChannel(org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandRequestProto msg) throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
      Description copied from interface: ContainerDispatcher
      When uploading using stream, get StreamDataChannel.
      Specified by:
      getStreamDataChannel in interface ContainerDispatcher
      Throws:
      org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException