Class KeyValueContainerData

java.lang.Object
org.apache.hadoop.ozone.container.common.impl.ContainerData
org.apache.hadoop.ozone.container.keyvalue.KeyValueContainerData

public class KeyValueContainerData extends ContainerData
This class represents the KeyValueContainer metadata, which is the in-memory representation of container metadata and is represented on disk by the .container file.
  • 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 - - ContainerId
      layoutVersion - container layout
      size - - maximum size of the container in bytes
    • KeyValueContainerData

      public KeyValueContainerData(KeyValueContainerData source)
  • Method Details

    • setSchemaVersion

      public void setSchemaVersion(String version)
      Parameters:
      version - The schema version indicating the table layout of the container's database.
    • getSchemaVersion

      public String getSchemaVersion()
      Returns:
      The schema version describing the container database's table layout.
    • getSupportedSchemaVersionOrDefault

      public String getSupportedSchemaVersionOrDefault()
      Returns schema version or the default value when the schemaVersion is null. The default value can be referred to KeyValueContainerUtil.isSameSchemaVersion(java.lang.String, java.lang.String).
      Returns:
      Schema version as a string.
      Throws:
      UnsupportedOperationException - If no valid schema version is found.
    • setDbFile

      public void setDbFile(File containerDbFile)
      Sets Container dbFile. This should be called only during creation of KeyValue container.
      Parameters:
      containerDbFile -
    • getDbFile

      public File getDbFile()
      Returns container DB file.
      Returns:
      dbFile
    • getMetadataPath

      public String getMetadataPath()
      Returns container metadata path.
      Specified by:
      getMetadataPath in class ContainerData
      Returns:
      - Physical path where container file and checksum is stored.
    • setMetadataPath

      public void setMetadataPath(String path)
      Sets container metadata path.
      Parameters:
      path - - String.
    • getContainerPath

      public String getContainerPath()
      Returns the path to base dir of the container.
      Specified by:
      getContainerPath in class ContainerData
      Returns:
      Path to base dir
    • getBlockCommitSequenceId

      public long getBlockCommitSequenceId()
      Returns the blockCommitSequenceId.
      Specified by:
      getBlockCommitSequenceId in class ContainerData
    • updateBlockCommitSequenceId

      public void updateBlockCommitSequenceId(long id)
      updates the blockCommitSequenceId.
    • getContainerDBType

      public String getContainerDBType()
      Returns the DBType used for the container.
      Returns:
      containerDBType
    • setContainerDBType

      public void setContainerDBType(String containerDBType)
      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

      public Set<Long> getFinalizedBlockSet()
    • isFinalizedBlockExist

      public boolean isFinalizedBlockExist(long localID)
    • clearFinalizedBlock

      public void clearFinalizedBlock(DBHandle db) throws IOException
      Throws:
      IOException
    • getProtoBufMessage

      public org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerDataProto getProtoBufMessage()
      Returns a ProtoBuf Message from ContainerData.
      Specified by:
      getProtoBufMessage in class ContainerData
      Returns:
      Protocol Buffer Message
    • getYamlFields

      public static List<String> 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

      public void resetPendingDeleteBlockCount(DBHandle db) throws IOException
      Throws:
      IOException
    • getBlockKey

      public String getBlockKey(long localID)
    • getDeletingBlockKey

      public String getDeletingBlockKey(long localID)
    • getDeleteTxnKey

      public String getDeleteTxnKey(long txnID)
    • getLatestDeleteTxnKey

      public String getLatestDeleteTxnKey()
    • getBcsIdKey

      public String getBcsIdKey()
    • getBlockCountKey

      public String getBlockCountKey()
    • getBytesUsedKey

      public String getBytesUsedKey()
    • getPendingDeleteBlockCountKey

      public String getPendingDeleteBlockCountKey()
    • getContainerDataChecksumKey

      public String getContainerDataChecksumKey()
    • getDeletingBlockKeyPrefix

      public String getDeletingBlockKeyPrefix()
    • getUnprefixedKeyFilter

      public org.apache.hadoop.hdds.utils.MetadataKeyFilters.KeyPrefixFilter getUnprefixedKeyFilter()
    • getDeletingBlockKeyFilter

      public org.apache.hadoop.hdds.utils.MetadataKeyFilters.KeyPrefixFilter getDeletingBlockKeyFilter()
    • startKeyEmpty

      public String startKeyEmpty()
      Schema v3 use a prefix as startKey, for other schemas just return null.
    • containerPrefix

      public String containerPrefix()
      Schema v3 use containerID as key prefix, for other schemas just return null.
    • hasSchema

      public boolean hasSchema(String version)