Class Handler
java.lang.Object
org.apache.hadoop.ozone.container.common.interfaces.Handler
- Direct Known Subclasses:
KeyValueHandler
Dispatcher sends ContainerCommandRequests to Handler. Each Container Type
should have an implementation for Handler.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected final org.apache.hadoop.hdds.conf.ConfigurationSourceprotected final ContainerSetprotected Stringprotected final ContainerMetricsprotected final VolumeSet -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedHandler(org.apache.hadoop.hdds.conf.ConfigurationSource config, String datanodeId, ContainerSet contSet, VolumeSet volumeSet, ContainerMetrics containerMetrics, IncrementalReportSender<Container> icrSender) -
Method Summary
Modifier and TypeMethodDescriptionabstract voidaddFinalizedBlock(Container container, long localID) abstract voidcloseContainer(Container container) Moves the Container to CLOSED state.abstract voiddeleteBlock(Container container, org.apache.hadoop.ozone.container.common.helpers.BlockData blockData) Deletes the given files associated with a block of the container.abstract voiddeleteContainer(Container container, boolean force) Deletes the given container.abstract voiddeleteUnreferenced(Container container, long localID) Deletes the possible onDisk but unreferenced blocks/chunks with localID in the container.abstract voidexportContainer(Container container, OutputStream outputStream, TarContainerPacker packer) Exports container to the output stream.Returns the Id of this datanode.static HandlergetHandlerForContainerType(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) abstract org.apache.ratis.statemachine.StateMachine.DataChannelgetStreamDataChannel(Container container, org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandRequestProto msg) abstract org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandResponseProtohandle(org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandRequestProto msg, Container container, DispatcherContext dispatcherContext) abstract ContainerimportContainer(ContainerData containerData, InputStream rawContainerStream, TarContainerPacker packer) Imports container from a raw input stream.abstract booleanisFinalizedBlockExist(Container container, long localID) abstract voidmarkContainerForClose(Container container) Marks the container for closing.abstract voidmarkContainerUnhealthy(Container container, ScanResult reason) Marks the container Unhealthy.abstract voidquasiCloseContainer(Container container, String reason) Moves the Container to QUASI_CLOSED state.abstract voidreconcileContainer(DNContainerOperationClient dnClient, Container<?> container, Collection<org.apache.hadoop.hdds.protocol.DatanodeDetails> peers) Triggers reconciliation of this container replica's data with its peers.protected voidsendDeferredICR(Container container) This should be called when there is no state change.protected voidThis should be called whenever there is state change.voidsetClusterID(String clusterID) abstract voidstop()Stop the Handler.abstract 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.
-
Field Details
-
conf
protected final org.apache.hadoop.hdds.conf.ConfigurationSource conf -
containerSet
-
volumeSet
-
clusterId
-
metrics
-
datanodeId
-
-
Constructor Details
-
Handler
protected Handler(org.apache.hadoop.hdds.conf.ConfigurationSource config, String datanodeId, ContainerSet contSet, VolumeSet volumeSet, ContainerMetrics containerMetrics, IncrementalReportSender<Container> icrSender)
-
-
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
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
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 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.
-
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 updatereason- The reason the container was marked unhealthy- Throws:
IOException- in case of exception
-
quasiCloseContainer
Moves the Container to QUASI_CLOSED state.- Parameters:
container- container to be quasi closedreason- The reason the container was quasi closed, for logging purposes.- Throws:
IOException
-
closeContainer
Moves the Container to CLOSED state.- Parameters:
container- container to be closed- Throws:
IOException
-
deleteContainer
Deletes the given container.- 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 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 deletedblockData- block to be deleted- Throws:
IOException
-
deleteUnreferenced
Deletes the possible onDisk but unreferenced blocks/chunks with localID in the container.- Parameters:
container- container whose block/chunk is to be deletedlocalID- localId of the block/chunk- Throws:
IOException
-
addFinalizedBlock
-
isFinalizedBlockExist
-
setClusterID
-