Class KeyValueHandler

java.lang.Object
org.apache.hadoop.ozone.container.common.interfaces.Handler
org.apache.hadoop.ozone.container.keyvalue.KeyValueHandler

public class KeyValueHandler extends Handler
Handler for KeyValue Container type.
  • Constructor Details

  • Method Details

    • getStreamDataChannel

      public 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
      Specified by:
      getStreamDataChannel in class Handler
      Throws:
      org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
    • stop

      public void stop()
      Description copied from class: Handler
      Stop the Handler.
      Specified by:
      stop in class Handler
    • handle

      public org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandResponseProto handle(org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandRequestProto request, Container container, DispatcherContext dispatcherContext)
      Specified by:
      handle in class Handler
    • getChunkManager

      public ChunkManager getChunkManager()
    • getBlockManager

      public BlockManager getBlockManager()
    • getChecksumManager

      public ContainerChecksumTreeManager getChecksumManager()
    • writeChunkForClosedContainer

      public void writeChunkForClosedContainer(org.apache.hadoop.ozone.container.common.helpers.ChunkInfo chunkInfo, org.apache.hadoop.hdds.client.BlockID blockID, org.apache.hadoop.ozone.common.ChunkBuffer data, KeyValueContainer kvContainer) throws IOException
      Handle Write Chunk operation for closed container. Calls ChunkManager to process the request.
      Throws:
      IOException
    • putBlockForClosedContainer

      public void putBlockForClosedContainer(KeyValueContainer kvContainer, org.apache.hadoop.ozone.container.common.helpers.BlockData blockData, long blockCommitSequenceId, boolean overwriteBscId) throws IOException
      Handle Put Block operation for closed container. Calls BlockManager to process the request. This is primarily used by container reconciliation process to persist the block data for closed container.
      Parameters:
      kvContainer - - Container for which block data need to be persisted.
      blockData - - Block Data to be persisted (BlockData should have the chunks).
      blockCommitSequenceId - - Block Commit Sequence ID for the block.
      overwriteBscId - - To overwrite bcsId in the block data and container. In case of chunk failure during reconciliation, we do not want to overwrite the bcsId as this block/container is incomplete in its current state.
      Throws:
      IOException
    • importContainer

      public Container importContainer(ContainerData originalContainerData, InputStream rawContainerStream, TarContainerPacker packer) throws IOException
      Description copied from class: Handler
      Imports container from a raw input stream.
      Specified by:
      importContainer in class Handler
      Throws:
      IOException
    • exportContainer

      public void exportContainer(Container container, OutputStream outputStream, TarContainerPacker packer) throws IOException
      Description copied from class: Handler
      Exports container to the output stream.
      Specified by:
      exportContainer in class Handler
      Throws:
      IOException
    • markContainerForClose

      public void markContainerForClose(Container container) throws IOException
      Description copied from class: Handler
      Marks the container for closing. Moves the container to CLOSING state.
      Specified by:
      markContainerForClose in class Handler
      Parameters:
      container - container to update
      Throws:
      IOException - in case of exception
    • updateContainerChecksum

      public void updateContainerChecksum(Container container, ContainerMerkleTreeWriter treeWriter) throws IOException
      Description copied from class: Handler
      Updates the container checksum information on disk and in memory and sends an ICR if the container checksum was changed from its previous value.
      Specified by:
      updateContainerChecksum in class Handler
      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.
    • updateAndGetContainerChecksumFromMetadata

      public org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerChecksumInfo updateAndGetContainerChecksumFromMetadata(KeyValueContainer container) throws IOException
      Updates the container merkle tree based on the RocksDb's block metadata and returns the updated checksum info. This method does not send an ICR with the updated checksum info.
      Parameters:
      container - - Container for which the container merkle tree needs to be updated.
      Throws:
      IOException
    • markContainerUnhealthy

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

      public void quasiCloseContainer(Container container, String reason) throws IOException
      Description copied from class: Handler
      Moves the Container to QUASI_CLOSED state.
      Specified by:
      quasiCloseContainer in class Handler
      Parameters:
      container - container to be quasi closed
      reason - The reason the container was quasi closed, for logging purposes.
      Throws:
      IOException
    • closeContainer

      public void closeContainer(Container container) throws IOException
      Description copied from class: Handler
      Moves the Container to CLOSED state.
      Specified by:
      closeContainer in class Handler
      Parameters:
      container - container to be closed
      Throws:
      IOException
    • deleteContainer

      public void deleteContainer(Container container, boolean force) throws IOException
      Description copied from class: Handler
      Deletes the given container.
      Specified by:
      deleteContainer in class Handler
      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 void reconcileContainer(DNContainerOperationClient dnClient, Container<?> container, Collection<org.apache.hadoop.hdds.protocol.DatanodeDetails> peers) throws IOException
      Description copied from class: Handler
      Triggers reconciliation of this container replica's data with its peers.
      Specified by:
      reconcileContainer in class Handler
      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 void deleteBlock(Container container, org.apache.hadoop.ozone.container.common.helpers.BlockData blockData) throws IOException
      Called by BlockDeletingService to delete all the chunks in a block before proceeding to delete the block info from DB.
      Specified by:
      deleteBlock in class Handler
      Parameters:
      container - container whose block is to be deleted
      blockData - block to be deleted
      Throws:
      IOException
    • deleteUnreferenced

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

      public void addFinalizedBlock(Container container, long localID)
      Specified by:
      addFinalizedBlock in class Handler
    • isFinalizedBlockExist

      public boolean isFinalizedBlockExist(Container container, long localID)
      Specified by:
      isFinalizedBlockExist in class Handler
    • getInjector

      public static org.apache.hadoop.hdds.utils.FaultInjector getInjector()
    • setInjector

      public static void setInjector(org.apache.hadoop.hdds.utils.FaultInjector instance)