Class KeyValueContainerData
java.lang.Object
org.apache.hadoop.ozone.container.common.impl.ContainerData
org.apache.hadoop.ozone.container.keyvalue.KeyValueContainerData
This class represents the KeyValueContainer metadata, which is the
in-memory representation of container metadata and is represented on disk
by the .container file.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.hadoop.ozone.container.common.impl.ContainerData
ContainerData.BlockByteAndCounts, ContainerData.Statistics -
Field Summary
FieldsFields inherited from class org.apache.hadoop.ozone.container.common.impl.ContainerData
CHARSET_ENCODING, YAML_FIELDS, ZERO_CHECKSUM -
Constructor Summary
ConstructorsConstructorDescriptionKeyValueContainerData(long id, ContainerLayoutVersion layoutVersion, long size, String originPipelineId, String originNodeId) Constructs KeyValueContainerData object. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddToFinalizedBlockSet(long localID) Add the given localID of a block to the finalizedBlockSet.voidSchema v3 use containerID as key prefix, for other schemas just return null.longReturns the blockCommitSequenceId.getBlockKey(long localID) Returns the DBType used for the container.Returns the path to base dir of the container.Returns container DB file.longReturn the latest deleteTransactionId of the container.getDeleteTxnKey(long txnID) getDeletingBlockKey(long localID) org.apache.hadoop.hdds.utils.MetadataKeyFilters.KeyPrefixFilterReturns container metadata path.longGet the number of pending deletion blocks.org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerDataProtoReturns a ProtoBuf Message from ContainerData.Returns schema version or the default value when theschemaVersionis null.org.apache.hadoop.hdds.utils.MetadataKeyFilters.KeyPrefixFilterbooleanvoidincrPendingDeletionBlocks(long numBlocks) Increase the count of pending deletion blocks.booleanisFinalizedBlockExist(long localID) voidvoidsetContainerDBType(String containerDBType) Sets the DBType used for the container.voidSets Container dbFile.voidsetMetadataPath(String path) Sets container metadata path.voidsetSchemaVersion(String version) Schema v3 use a prefix as startKey, for other schemas just return null.voidupdateAndCommitDBCounters(DBHandle db, org.apache.hadoop.hdds.utils.db.BatchOperation batchOperation, int deletedBlockCount, long releasedBytes) Update DB counters related to block metadata.voidupdateBlockCommitSequenceId(long id) updates the blockCommitSequenceId.voidupdateDeleteTransactionId(long transactionId) Sets deleteTransactionId to latest delete transactionId for the container.Methods inherited from class org.apache.hadoop.ozone.container.common.impl.ContainerData
addMetadata, closeContainer, commitSpace, computeAndSetContainerFileChecksum, getBlockCount, getBytesUsed, getChunksPath, getContainerFileChecksum, getContainerID, getContainerType, getDataChecksum, getDataScanTimestamp, getImmediateCloseActionSent, getLayoutVersion, getMaxSize, getMetadata, getOriginNodeId, getOriginPipelineId, getReplicaIndex, getState, getStatistics, getVolume, isClosed, isClosing, isCommittedSpace, isEmpty, isOpen, isQuasiClosed, isUnhealthy, isValid, lastDataScanTime, markAsEmpty, needsDataChecksum, quasiCloseContainer, releaseCommitSpace, setChunksPath, setCommittedSpace, setContainerFileChecksum, setDataChecksum, setDataScanTimestamp, setMetadata, setReplicaIndex, setState, setVolume, toString, updateDataScanTime, updateWriteStats
-
Field Details
-
KEYVALUE_YAML_TAG
public static final org.yaml.snakeyaml.nodes.Tag KEYVALUE_YAML_TAG
-
-
Constructor Details
-
KeyValueContainerData
public KeyValueContainerData(long id, ContainerLayoutVersion layoutVersion, long size, String originPipelineId, String originNodeId) Constructs KeyValueContainerData object.- Parameters:
id- - ContainerIdlayoutVersion- container layoutsize- - maximum size of the container in bytes
-
KeyValueContainerData
-
-
Method Details
-
setSchemaVersion
- Parameters:
version- The schema version indicating the table layout of the container's database.
-
getSchemaVersion
- Returns:
- The schema version describing the container database's table layout.
-
getSupportedSchemaVersionOrDefault
Returns schema version or the default value when theschemaVersionis null. The default value can be referred toKeyValueContainerUtil.isSameSchemaVersion(java.lang.String, java.lang.String).- Returns:
- Schema version as a string.
- Throws:
UnsupportedOperationException- If no valid schema version is found.
-
setDbFile
Sets Container dbFile. This should be called only during creation of KeyValue container.- Parameters:
containerDbFile-
-
getDbFile
Returns container DB file.- Returns:
- dbFile
-
getMetadataPath
Returns container metadata path.- Specified by:
getMetadataPathin classContainerData- Returns:
- - Physical path where container file and checksum is stored.
-
setMetadataPath
Sets container metadata path.- Parameters:
path- - String.
-
getContainerPath
Returns the path to base dir of the container.- Specified by:
getContainerPathin classContainerData- Returns:
- Path to base dir
-
getBlockCommitSequenceId
public long getBlockCommitSequenceId()Returns the blockCommitSequenceId.- Specified by:
getBlockCommitSequenceIdin classContainerData
-
updateBlockCommitSequenceId
public void updateBlockCommitSequenceId(long id) updates the blockCommitSequenceId. -
getContainerDBType
Returns the DBType used for the container.- Returns:
- containerDBType
-
setContainerDBType
Sets the DBType used for the container.- Parameters:
containerDBType-
-
incrPendingDeletionBlocks
public void incrPendingDeletionBlocks(long numBlocks) Increase the count of pending deletion blocks.- Parameters:
numBlocks- increment number
-
getNumPendingDeletionBlocks
public long getNumPendingDeletionBlocks()Get the number of pending deletion blocks. -
updateDeleteTransactionId
public void updateDeleteTransactionId(long transactionId) Sets deleteTransactionId to latest delete transactionId for the container.- Parameters:
transactionId- latest transactionId of the container.
-
getDeleteTransactionId
public long getDeleteTransactionId()Return the latest deleteTransactionId of the container. -
addToFinalizedBlockSet
public void addToFinalizedBlockSet(long localID) Add the given localID of a block to the finalizedBlockSet. -
getFinalizedBlockSet
-
isFinalizedBlockExist
public boolean isFinalizedBlockExist(long localID) -
clearFinalizedBlock
- Throws:
IOException
-
getProtoBufMessage
public org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerDataProto getProtoBufMessage()Returns a ProtoBuf Message from ContainerData.- Specified by:
getProtoBufMessagein classContainerData- Returns:
- Protocol Buffer Message
-
getYamlFields
-
updateAndCommitDBCounters
public void updateAndCommitDBCounters(DBHandle db, org.apache.hadoop.hdds.utils.db.BatchOperation batchOperation, int deletedBlockCount, long releasedBytes) throws IOException Update DB counters related to block metadata.- Parameters:
db- - Reference to container DB.batchOperation- - Batch Operation to batch DB operations.deletedBlockCount- - Number of blocks deleted.releasedBytes- - Number of bytes released.- Throws:
IOException
-
resetPendingDeleteBlockCount
- Throws:
IOException
-
getBlockKey
-
getDeletingBlockKey
-
getDeleteTxnKey
-
getLatestDeleteTxnKey
-
getBcsIdKey
-
getBlockCountKey
-
getBytesUsedKey
-
getPendingDeleteBlockCountKey
-
getContainerDataChecksumKey
-
getDeletingBlockKeyPrefix
-
getUnprefixedKeyFilter
public org.apache.hadoop.hdds.utils.MetadataKeyFilters.KeyPrefixFilter getUnprefixedKeyFilter() -
getDeletingBlockKeyFilter
public org.apache.hadoop.hdds.utils.MetadataKeyFilters.KeyPrefixFilter getDeletingBlockKeyFilter() -
startKeyEmpty
Schema v3 use a prefix as startKey, for other schemas just return null. -
containerPrefix
Schema v3 use containerID as key prefix, for other schemas just return null. -
hasSchema
-