Class CloudBlobMetadata


  • public class CloudBlobMetadata
    extends java.lang.Object
    Blob metadata document POJO class.
    • Constructor Detail

      • CloudBlobMetadata

        public CloudBlobMetadata()
        Default constructor (for JSONSerializer).
      • CloudBlobMetadata

        public CloudBlobMetadata​(com.github.ambry.commons.BlobId blobId,
                                 long creationTime,
                                 long expirationTime,
                                 long size,
                                 CloudBlobMetadata.EncryptionOrigin encryptionOrigin)
        Constructor from BlobId.
        Parameters:
        blobId - The BlobId for metadata record.
        creationTime - The blob creation time.
        expirationTime - The blob expiration time.
        size - The blob size.
        encryptionOrigin - The blob's encryption origin.
      • CloudBlobMetadata

        public CloudBlobMetadata​(com.github.ambry.commons.BlobId blobId,
                                 long creationTime,
                                 long expirationTime,
                                 long size,
                                 CloudBlobMetadata.EncryptionOrigin encryptionOrigin,
                                 short lifeVersion)
        Constructor from BlobId.
        Parameters:
        blobId - The BlobId for metadata record.
        creationTime - The blob creation time.
        expirationTime - The blob expiration time.
        size - The blob size.
        encryptionOrigin - The blob's encryption origin.
        lifeVersion - The life version.
      • CloudBlobMetadata

        public CloudBlobMetadata​(com.github.ambry.commons.BlobId blobId,
                                 long creationTime,
                                 long expirationTime,
                                 long size,
                                 CloudBlobMetadata.EncryptionOrigin encryptionOrigin,
                                 java.lang.String vcrKmsContext,
                                 java.lang.String cryptoAgentFactory,
                                 long encryptedSize,
                                 short lifeVersion)
        Constructor from BlobId.
        Parameters:
        blobId - The BlobId for metadata record.
        creationTime - The blob creation time.
        expirationTime - The blob expiration time.
        size - The blob size.
        encryptionOrigin - The blob's encryption origin.
        vcrKmsContext - The KMS context used to encrypt the blob. Only used when encryptionOrigin = VCR.
        cryptoAgentFactory - The class name of the CloudBlobCryptoAgentFactory used to encrypt the blob. Only used when encryptionOrigin = VCR.
        encryptedSize - The size of the uploaded blob if it was encrypted and then uploaded. Only used when encryptionOrigin = VCR.
        lifeVersion - The life version.
    • Method Detail

      • getId

        public java.lang.String getId()
        Returns:
        the blob Id.
      • getPartitionId

        public java.lang.String getPartitionId()
        Returns:
        the partition Id.
      • setPartitionId

        public CloudBlobMetadata setPartitionId​(java.lang.String partitionId)
        Set the partition Id.
        Parameters:
        partitionId - the partition Id of the blob.
        Returns:
        this instance.
      • getCreationTime

        public long getCreationTime()
        Returns:
        the blob creation time.
      • setCreationTime

        public CloudBlobMetadata setCreationTime​(long creationTime)
        Set the creation time.
        Parameters:
        creationTime - the creation time of the blob.
        Returns:
        this instance.
      • getUploadTime

        public long getUploadTime()
        Returns:
        the blob upload time.
      • setUploadTime

        public CloudBlobMetadata setUploadTime​(long uploadTime)
        Set the upload time.
        Parameters:
        uploadTime - the upload time of the blob.
        Returns:
        this instance.
      • getExpirationTime

        public long getExpirationTime()
        Returns:
        the blob expiration time.
      • setExpirationTime

        public CloudBlobMetadata setExpirationTime​(long expirationTime)
        Set the blob expiration time.
        Parameters:
        expirationTime - the expiration time of the blob.
        Returns:
        this instance.
      • getDeletionTime

        public long getDeletionTime()
        Returns:
        the blob deletion time.
      • setDeletionTime

        public CloudBlobMetadata setDeletionTime​(long deletionTime)
        Set the blob deletion time.
        Parameters:
        deletionTime - the deletion time of the blob.
        Returns:
        this instance.
      • getSize

        public long getSize()
        Returns:
        the blob size.
      • setSize

        public CloudBlobMetadata setSize​(long size)
        Set the size.
        Parameters:
        size - the size of the blob in bytes.
        Returns:
        this instance.
      • getAccountId

        public int getAccountId()
        Returns:
        the account Id.
      • setAccountId

        public CloudBlobMetadata setAccountId​(int accountId)
        Set the account Id.
        Parameters:
        accountId - the account Id of the blob.
        Returns:
        this instance.
      • getContainerId

        public int getContainerId()
        Returns:
        the container Id.
      • setContainerId

        public CloudBlobMetadata setContainerId​(int containerId)
        Set the container Id.
        Parameters:
        containerId - the container Id of the blob.
        Returns:
        this instance.
      • getVcrKmsContext

        public java.lang.String getVcrKmsContext()
        Returns:
        the VCR KMS context.
      • setVcrKmsContext

        public CloudBlobMetadata setVcrKmsContext​(java.lang.String vcrKmsContext)
        Sets the VCR KMS context.
        Parameters:
        vcrKmsContext - the KMS context used for encryption.
        Returns:
        this instance.
      • getNameSchemeVersion

        public int getNameSchemeVersion()
        Returns:
        the blob naming scheme version.
      • setNameSchemeVersion

        public CloudBlobMetadata setNameSchemeVersion​(int nameSchemeVersion)
        Sets the blob naming scheme version.
        Parameters:
        nameSchemeVersion - the version of blob naming scheme.
        Returns:
        this instance.
      • getCryptoAgentFactory

        public java.lang.String getCryptoAgentFactory()
        Returns:
        the VCR crypto agent factory class name.
      • setCryptoAgentFactory

        public CloudBlobMetadata setCryptoAgentFactory​(java.lang.String cryptoAgentFactory)
        Sets the VCR crypto agent factory class name.
        Parameters:
        cryptoAgentFactory - the class name of the CloudBlobCryptoAgentFactory used for encryption.
        Returns:
        this instance.
      • getEncryptedSize

        public long getEncryptedSize()
        Returns:
        the encrypted size of the blob if the blob was encrypted and uploaded to cloud, -1 otherwise
      • setEncryptedSize

        public CloudBlobMetadata setEncryptedSize​(long encryptedSize)
        Sets the encrypted size of the blob
        Parameters:
        encryptedSize -
      • getLastUpdateTime

        public long getLastUpdateTime()
        Returns:
        the last update time of the blob.
      • setLastUpdateTime

        public void setLastUpdateTime​(long lastUpdateTime)
        Sets the last update time of the blob.
        Parameters:
        lastUpdateTime - last update time.
      • getLifeVersion

        public short getLifeVersion()
        Returns:
        the life version of the blob.
      • setLifeVersion

        public void setLifeVersion​(short lifeVersion)
        Sets the life version of the blob.
        Parameters:
        lifeVersion - life version.
      • capMetadataListBySize

        public static java.util.List<CloudBlobMetadata> capMetadataListBySize​(java.util.List<CloudBlobMetadata> originalList,
                                                                              long size)
        Utility to cap specified CloudBlobMetadata list by specified size of its blobs. Always returns at least one metadata object irrespective of size.
        Parameters:
        originalList - List of CloudBlobMetadata.
        size - total size of metadata's blobs.
        Returns:
        List of CloudBlobMetadata capped by size.
      • isDeleted

        public boolean isDeleted()
        Returns:
        true if this blob is marked as deleted, false otherwise.
      • isExpired

        public boolean isExpired()
        Returns:
        true if this blob has expired, false otherwise.
      • isUndeleted

        public boolean isUndeleted()
        Returns:
        true if this blob is undeleted.
      • isCompactionCandidate

        public boolean isCompactionCandidate​(long retentionPeriod)
        Parameters:
        retentionPeriod - period for which blobs marked a deleted aren't compacted away.
        Returns:
        true if deletion time is outside retention window or blob is expired. false otherwise.
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • toMap

        public java.util.Map<java.lang.String,​java.lang.String> toMap()
        Returns:
        a HashMap of metadata key-value pairs.
      • fromMap

        public static CloudBlobMetadata fromMap​(java.util.Map<java.lang.String,​java.lang.String> properties)
        Parameters:
        properties - the key-value property map.
        Returns:
        a CloudBlobMetadata from a property map.