Class KeyValueHandler
java.lang.Object
org.apache.hadoop.ozone.container.common.interfaces.Handler
org.apache.hadoop.ozone.container.keyvalue.KeyValueHandler
Handler for KeyValue Container type.
-
Field Summary
Fields inherited from class org.apache.hadoop.ozone.container.common.interfaces.Handler
clusterId, conf, containerSet, datanodeId, metrics, volumeSet -
Constructor Summary
ConstructorsConstructorDescriptionKeyValueHandler(org.apache.hadoop.hdds.conf.ConfigurationSource config, String datanodeId, ContainerSet contSet, VolumeSet volSet, ContainerMetrics metrics, IncrementalReportSender<Container> icrSender, ContainerChecksumTreeManager checksumManager) KeyValueHandler(org.apache.hadoop.hdds.conf.ConfigurationSource config, String datanodeId, ContainerSet contSet, VolumeSet volSet, VolumeChoosingPolicy volumeChoosingPolicy, ContainerMetrics metrics, IncrementalReportSender<Container> icrSender, Clock clock, ContainerChecksumTreeManager checksumManager) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFinalizedBlock(Container container, long localID) voidcloseContainer(Container container) Moves the Container to CLOSED state.voiddeleteBlock(Container container, org.apache.hadoop.ozone.container.common.helpers.BlockData blockData) Called by BlockDeletingService to delete all the chunks in a block before proceeding to delete the block info from DB.voiddeleteContainer(Container container, boolean force) Deletes the given container.voiddeleteUnreferenced(Container container, long localID) Deletes the possible onDisk but unreferenced blocks/chunks with localID in the container.voidexportContainer(Container container, OutputStream outputStream, TarContainerPacker packer) Exports container to the output stream.static org.apache.hadoop.hdds.utils.FaultInjectororg.apache.ratis.statemachine.StateMachine.DataChannelgetStreamDataChannel(Container container, org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandRequestProto msg) org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandResponseProtohandle(org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandRequestProto request, Container container, DispatcherContext dispatcherContext) importContainer(ContainerData originalContainerData, InputStream rawContainerStream, TarContainerPacker packer) Imports container from a raw input stream.booleanisFinalizedBlockExist(Container container, long localID) voidmarkContainerForClose(Container container) Marks the container for closing.voidmarkContainerUnhealthy(Container container, ScanResult reason) Marks the container Unhealthy.voidputBlockForClosedContainer(KeyValueContainer kvContainer, org.apache.hadoop.ozone.container.common.helpers.BlockData blockData, long blockCommitSequenceId, boolean overwriteBscId) Handle Put Block operation for closed container.voidquasiCloseContainer(Container container, String reason) Moves the Container to QUASI_CLOSED state.voidreconcileContainer(DNContainerOperationClient dnClient, Container<?> container, Collection<org.apache.hadoop.hdds.protocol.DatanodeDetails> peers) Triggers reconciliation of this container replica's data with its peers.static voidsetInjector(org.apache.hadoop.hdds.utils.FaultInjector instance) voidstop()Stop the Handler.org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerChecksumInfoUpdates the container merkle tree based on the RocksDb's block metadata and returns the updated checksum info.voidupdateContainerChecksum(Container container, ContainerMerkleTreeWriter treeWriter) Updates the container checksum information on disk and in memory and sends an ICR if the container checksum was changed from its previous value.voidwriteChunkForClosedContainer(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) Handle Write Chunk operation for closed container.Methods inherited from class org.apache.hadoop.ozone.container.common.interfaces.Handler
getDatanodeId, getHandlerForContainerType, sendDeferredICR, sendICR, setClusterID
-
Constructor Details
-
KeyValueHandler
public KeyValueHandler(org.apache.hadoop.hdds.conf.ConfigurationSource config, String datanodeId, ContainerSet contSet, VolumeSet volSet, ContainerMetrics metrics, IncrementalReportSender<Container> icrSender, ContainerChecksumTreeManager checksumManager) -
KeyValueHandler
public KeyValueHandler(org.apache.hadoop.hdds.conf.ConfigurationSource config, String datanodeId, ContainerSet contSet, VolumeSet volSet, VolumeChoosingPolicy volumeChoosingPolicy, ContainerMetrics metrics, IncrementalReportSender<Container> icrSender, Clock clock, ContainerChecksumTreeManager checksumManager)
-
-
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:
getStreamDataChannelin classHandler- Throws:
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException
-
stop
public void stop()Description copied from class:HandlerStop the 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) -
getChunkManager
-
getBlockManager
-
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:HandlerImports container from a raw input stream.- Specified by:
importContainerin classHandler- Throws:
IOException
-
exportContainer
public void exportContainer(Container container, OutputStream outputStream, TarContainerPacker packer) throws IOException Description copied from class:HandlerExports container to the output stream.- Specified by:
exportContainerin classHandler- Throws:
IOException
-
markContainerForClose
Description copied from class:HandlerMarks the container for closing. Moves the container to CLOSING state.- Specified by:
markContainerForClosein classHandler- 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:HandlerUpdates 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:
updateContainerChecksumin classHandler- Parameters:
container- The container to updatetreeWriter- 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
Description copied from class:HandlerMarks the container Unhealthy. Moves the container to UNHEALTHY state.- Specified by:
markContainerUnhealthyin classHandler- Parameters:
container- container to updatereason- The reason the container was marked unhealthy- Throws:
IOException- in case of exception
-
quasiCloseContainer
Description copied from class:HandlerMoves the Container to QUASI_CLOSED state.- Specified by:
quasiCloseContainerin classHandler- Parameters:
container- container to be quasi closedreason- The reason the container was quasi closed, for logging purposes.- Throws:
IOException
-
closeContainer
Description copied from class:HandlerMoves the Container to CLOSED state.- Specified by:
closeContainerin classHandler- Parameters:
container- container to be closed- Throws:
IOException
-
deleteContainer
Description copied from class:HandlerDeletes the given container.- Specified by:
deleteContainerin classHandler- Parameters:
container- container to be deletedforce- 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:HandlerTriggers reconciliation of this container replica's data with its peers.- Specified by:
reconcileContainerin classHandler- 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:
deleteBlockin classHandler- Parameters:
container- container whose block is to be deletedblockData- block to be deleted- Throws:
IOException
-
deleteUnreferenced
Description copied from class:HandlerDeletes the possible onDisk but unreferenced blocks/chunks with localID in the container.- Specified by:
deleteUnreferencedin classHandler- Parameters:
container- container whose block/chunk is to be deletedlocalID- localId of the block/chunk- Throws:
IOException
-
addFinalizedBlock
- Specified by:
addFinalizedBlockin classHandler
-
isFinalizedBlockExist
- Specified by:
isFinalizedBlockExistin classHandler
-
getInjector
public static org.apache.hadoop.hdds.utils.FaultInjector getInjector() -
setInjector
public static void setInjector(org.apache.hadoop.hdds.utils.FaultInjector instance)
-