java.lang.Object
org.apache.hadoop.ozone.container.common.interfaces.Handler
Direct Known Subclasses:
KeyValueHandler

public abstract class Handler extends Object
Dispatcher sends ContainerCommandRequests to Handler. Each Container Type should have an implementation for Handler.
  • Field Details

    • conf

      protected final org.apache.hadoop.hdds.conf.ConfigurationSource conf
    • containerSet

      protected final ContainerSet containerSet
    • volumeSet

      protected final VolumeSet volumeSet
    • clusterId

      protected String clusterId
    • metrics

      protected final ContainerMetrics metrics
    • datanodeId

      protected String datanodeId
  • Constructor Details

  • Method Details

    • getHandlerForContainerType

      public static Handler getHandlerForContainerType(org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerType containerType, org.apache.hadoop.hdds.conf.ConfigurationSource config, String datanodeId, ContainerSet contSet, VolumeSet volumeSet, VolumeChoosingPolicy volumeChoosingPolicy, ContainerMetrics metrics, IncrementalReportSender<Container> icrSender, ContainerChecksumTreeManager checksumManager)
    • getStreamDataChannel

      public abstract org.apache.ratis.statemachine.StateMachine.DataChannel getStreamDataChannel(Container container, org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandRequestProto msg) throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
      Throws:
      org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
    • getDatanodeId

      public String getDatanodeId()
      Returns the Id of this datanode.
      Returns:
      datanode Id
    • sendICR

      protected void sendICR(Container container) throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
      This should be called whenever there is state change. It will trigger an ICR to SCM.
      Parameters:
      container - Container for which ICR has to be sent
      Throws:
      org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
    • sendDeferredICR

      protected void sendDeferredICR(Container container) throws org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
      This should be called when there is no state change. ICR will be deferred to next heartbeat.
      Parameters:
      container - Container for which deferred ICR has to be sent
      Throws:
      org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
    • handle

      public abstract org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandResponseProto handle(org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandRequestProto msg, Container container, DispatcherContext dispatcherContext)
    • importContainer

      public abstract Container importContainer(ContainerData containerData, InputStream rawContainerStream, TarContainerPacker packer) throws IOException
      Imports container from a raw input stream.
      Throws:
      IOException
    • exportContainer

      public abstract void exportContainer(Container container, OutputStream outputStream, TarContainerPacker packer) throws IOException
      Exports container to the output stream.
      Throws:
      IOException
    • stop

      public abstract void stop()
      Stop the Handler.
    • markContainerForClose

      public abstract void markContainerForClose(Container container) throws IOException
      Marks the container for closing. Moves the container to CLOSING state.
      Parameters:
      container - container to update
      Throws:
      IOException - in case of exception
    • updateContainerChecksum

      public abstract void updateContainerChecksum(Container container, ContainerMerkleTreeWriter treeWriter) throws IOException
      Updates the container checksum information on disk and in memory and sends an ICR if the container checksum was changed from its previous value.
      Parameters:
      container - The container to update
      treeWriter - The container merkle tree with the updated information about the container
      Throws:
      IOException - For errors sending an ICR or updating the container checksum on disk. If the disk update fails, the checksum in memory will not be updated and an ICR will not be sent.
    • markContainerUnhealthy

      public abstract void markContainerUnhealthy(Container container, ScanResult reason) throws IOException
      Marks the container Unhealthy. Moves the container to UNHEALTHY state.
      Parameters:
      container - container to update
      reason - The reason the container was marked unhealthy
      Throws:
      IOException - in case of exception
    • quasiCloseContainer

      public abstract void quasiCloseContainer(Container container, String reason) throws IOException
      Moves the Container to QUASI_CLOSED state.
      Parameters:
      container - container to be quasi closed
      reason - The reason the container was quasi closed, for logging purposes.
      Throws:
      IOException
    • closeContainer

      public abstract void closeContainer(Container container) throws IOException
      Moves the Container to CLOSED state.
      Parameters:
      container - container to be closed
      Throws:
      IOException
    • deleteContainer

      public abstract void deleteContainer(Container container, boolean force) throws IOException
      Deletes the given container.
      Parameters:
      container - container to be deleted
      force - if this is set to true, we delete container without checking state of the container.
      Throws:
      IOException
    • reconcileContainer

      public abstract void reconcileContainer(DNContainerOperationClient dnClient, Container<?> container, Collection<org.apache.hadoop.hdds.protocol.DatanodeDetails> peers) throws IOException
      Triggers reconciliation of this container replica's data with its peers.
      Parameters:
      container - container to be reconciled.
      peers - The other datanodes with a copy of this container whose data should be checked.
      Throws:
      IOException
    • deleteBlock

      public abstract void deleteBlock(Container container, org.apache.hadoop.ozone.container.common.helpers.BlockData blockData) throws IOException
      Deletes the given files associated with a block of the container.
      Parameters:
      container - container whose block is to be deleted
      blockData - block to be deleted
      Throws:
      IOException
    • deleteUnreferenced

      public abstract void deleteUnreferenced(Container container, long localID) throws IOException
      Deletes the possible onDisk but unreferenced blocks/chunks with localID in the container.
      Parameters:
      container - container whose block/chunk is to be deleted
      localID - localId of the block/chunk
      Throws:
      IOException
    • addFinalizedBlock

      public abstract void addFinalizedBlock(Container container, long localID)
    • isFinalizedBlockExist

      public abstract boolean isFinalizedBlockExist(Container container, long localID)
    • setClusterID

      public void setClusterID(String clusterID)