Class BlockManagerImpl

java.lang.Object
org.apache.hadoop.ozone.container.keyvalue.impl.BlockManagerImpl
All Implemented Interfaces:
BlockManager

public class BlockManagerImpl extends Object implements BlockManager
This class is for performing block related operations on the KeyValue Container.
  • Field Details

  • Constructor Details

    • BlockManagerImpl

      public BlockManagerImpl(org.apache.hadoop.hdds.conf.ConfigurationSource conf)
      Constructs a Block Manager.
      Parameters:
      conf - - Ozone configuration
  • Method Details

    • putBlock

      public long putBlock(Container container, org.apache.hadoop.ozone.container.common.helpers.BlockData data) throws IOException
      Description copied from interface: BlockManager
      Puts or overwrites a block.
      Specified by:
      putBlock in interface BlockManager
      Parameters:
      container - - Container for which block need to be added.
      data - - Block Data.
      Returns:
      length of the Block.
      Throws:
      IOException
    • putBlock

      public long putBlock(Container container, org.apache.hadoop.ozone.container.common.helpers.BlockData data, boolean endOfBlock) throws IOException
      Description copied from interface: BlockManager
      Puts or overwrites a block.
      Specified by:
      putBlock in interface BlockManager
      Parameters:
      container - - Container for which block need to be added.
      data - - Block Data.
      endOfBlock - - The last putBlock call for this block (when all the chunks are written and stream is closed)
      Returns:
      length of the Block.
      Throws:
      IOException
    • putBlockForClosedContainer

      public long putBlockForClosedContainer(Container container, org.apache.hadoop.ozone.container.common.helpers.BlockData data, boolean overwriteBcsId) throws IOException
      Persists the block data for a closed container. The block data should have all the chunks and bcsId. Overwrites the block if it already exists, The container's used bytes should be updated by the caller with ChunkManager.writeChunk(Container, BlockID, ChunkInfo, ByteBuffer, DispatcherContext).
      Specified by:
      putBlockForClosedContainer in interface BlockManager
      Parameters:
      container - - Container for which block data need to be persisted.
      data - - Block Data to be persisted (BlockData should have the chunks).
      overwriteBcsId - - To overwrite bcsId of the container.
      Throws:
      IOException
    • persistPutBlock

      public long persistPutBlock(KeyValueContainer container, org.apache.hadoop.ozone.container.common.helpers.BlockData data, boolean endOfBlock) throws IOException
      Throws:
      IOException
    • finalizeBlock

      public void finalizeBlock(Container container, org.apache.hadoop.hdds.client.BlockID blockId) throws IOException
      Specified by:
      finalizeBlock in interface BlockManager
      Throws:
      IOException
    • getBlock

      public org.apache.hadoop.ozone.container.common.helpers.BlockData getBlock(Container container, org.apache.hadoop.hdds.client.BlockID blockID) throws IOException
      Description copied from interface: BlockManager
      Gets an existing block.
      Specified by:
      getBlock in interface BlockManager
      Parameters:
      container - - Container from which block needs to be fetched.
      blockID - - BlockID of the Block.
      Returns:
      Block Data.
      Throws:
      IOException - when BcsId is unknown or mismatched
    • getCommittedBlockLength

      public long getCommittedBlockLength(Container container, org.apache.hadoop.hdds.client.BlockID blockID) throws IOException
      Description copied from interface: BlockManager
      Returns last committed length of the block.
      Specified by:
      getCommittedBlockLength in interface BlockManager
      Parameters:
      container - - Container from which block need to be fetched.
      blockID - - BlockID of the block.
      Returns:
      length of the block.
      Throws:
      IOException - in case, the block key does not exist in db.
    • getDefaultReadBufferCapacity

      public int getDefaultReadBufferCapacity()
      Specified by:
      getDefaultReadBufferCapacity in interface BlockManager
    • getReadMappedBufferThreshold

      public int getReadMappedBufferThreshold()
      Specified by:
      getReadMappedBufferThreshold in interface BlockManager
      Returns:
      the threshold to read using memory mapped buffers.
    • getReadMappedBufferMaxCount

      public int getReadMappedBufferMaxCount()
      Specified by:
      getReadMappedBufferMaxCount in interface BlockManager
      Returns:
      the max count of memory mapped buffers to read.
    • isReadNettyChunkedNioFile

      public boolean isReadNettyChunkedNioFile()
      Specified by:
      isReadNettyChunkedNioFile in interface BlockManager
      Returns:
      true iff Netty ChunkedNioFile read is enabled.
    • deleteBlock

      public void deleteBlock(Container container, org.apache.hadoop.hdds.client.BlockID blockID) throws IOException
      Deletes an existing block. As Deletion is handled by BlockDeletingService, UnsupportedOperationException is thrown always
      Specified by:
      deleteBlock in interface BlockManager
      Parameters:
      container - - Container from which block need to be deleted.
      blockID - - ID of the block.
      Throws:
      IOException
    • listBlock

      public List<org.apache.hadoop.ozone.container.common.helpers.BlockData> listBlock(Container container, long startLocalID, int count) throws IOException
      Description copied from interface: BlockManager
      List blocks in a container.
      Specified by:
      listBlock in interface BlockManager
      Parameters:
      container - - Container from which blocks need to be listed.
      startLocalID - - Block to start from, 0 to begin.
      count - - Number of blocks to return.
      Returns:
      List of Blocks that match the criteria.
      Throws:
      IOException
    • blockExists

      public boolean blockExists(Container container, org.apache.hadoop.hdds.client.BlockID blockID) throws IOException
      Description copied from interface: BlockManager
      Check if a block exists in the container.
      Specified by:
      blockExists in interface BlockManager
      Parameters:
      container - - Container from which blocks need to be listed.
      blockID - - BlockID of the Block.
      Returns:
      True if block exists, false otherwise.
      Throws:
      IOException
    • shutdown

      public void shutdown()
      Shutdown KeyValueContainerManager.
      Specified by:
      shutdown in interface BlockManager