Class BlockManagerImpl
java.lang.Object
org.apache.hadoop.ozone.container.keyvalue.impl.BlockManagerImpl
- All Implemented Interfaces:
BlockManager
This class is for performing block related operations on the KeyValue
Container.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBlockManagerImpl(org.apache.hadoop.hdds.conf.ConfigurationSource conf) Constructs a Block Manager. -
Method Summary
Modifier and TypeMethodDescriptionbooleanblockExists(Container container, org.apache.hadoop.hdds.client.BlockID blockID) Check if a block exists in the container.voiddeleteBlock(Container container, org.apache.hadoop.hdds.client.BlockID blockID) Deletes an existing block.voidfinalizeBlock(Container container, org.apache.hadoop.hdds.client.BlockID blockId) org.apache.hadoop.ozone.container.common.helpers.BlockDataGets an existing block.longgetCommittedBlockLength(Container container, org.apache.hadoop.hdds.client.BlockID blockID) Returns last committed length of the block.intintintbooleanList<org.apache.hadoop.ozone.container.common.helpers.BlockData> List blocks in a container.longpersistPutBlock(KeyValueContainer container, org.apache.hadoop.ozone.container.common.helpers.BlockData data, boolean endOfBlock) longPuts or overwrites a block.longputBlock(Container container, org.apache.hadoop.ozone.container.common.helpers.BlockData data, boolean endOfBlock) Puts or overwrites a block.longputBlockForClosedContainer(Container container, org.apache.hadoop.ozone.container.common.helpers.BlockData data, boolean overwriteBcsId) Persists the block data for a closed container.voidshutdown()Shutdown KeyValueContainerManager.
-
Field Details
-
FULL_CHUNK
- See Also:
-
-
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:BlockManagerPuts or overwrites a block.- Specified by:
putBlockin interfaceBlockManager- 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:BlockManagerPuts or overwrites a block.- Specified by:
putBlockin interfaceBlockManager- 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 withChunkManager.writeChunk(Container, BlockID, ChunkInfo, ByteBuffer, DispatcherContext).- Specified by:
putBlockForClosedContainerin interfaceBlockManager- 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:
finalizeBlockin interfaceBlockManager- 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:BlockManagerGets an existing block.- Specified by:
getBlockin interfaceBlockManager- 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:BlockManagerReturns last committed length of the block.- Specified by:
getCommittedBlockLengthin interfaceBlockManager- 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:
getDefaultReadBufferCapacityin interfaceBlockManager
-
getReadMappedBufferThreshold
public int getReadMappedBufferThreshold()- Specified by:
getReadMappedBufferThresholdin interfaceBlockManager- Returns:
- the threshold to read using memory mapped buffers.
-
getReadMappedBufferMaxCount
public int getReadMappedBufferMaxCount()- Specified by:
getReadMappedBufferMaxCountin interfaceBlockManager- Returns:
- the max count of memory mapped buffers to read.
-
isReadNettyChunkedNioFile
public boolean isReadNettyChunkedNioFile()- Specified by:
isReadNettyChunkedNioFilein interfaceBlockManager- 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:
deleteBlockin interfaceBlockManager- 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:BlockManagerList blocks in a container.- Specified by:
listBlockin interfaceBlockManager- 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:BlockManagerCheck if a block exists in the container.- Specified by:
blockExistsin interfaceBlockManager- 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:
shutdownin interfaceBlockManager
-