Package com.github.ambry.cloud
Class CloudBlobMetadata
- java.lang.Object
-
- com.github.ambry.cloud.CloudBlobMetadata
-
public class CloudBlobMetadata extends java.lang.Object
Blob metadata document POJO class.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CloudBlobMetadata.EncryptionOrigin
Possible values of encryption origin for cloud stored blobs.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
FIELD_ACCOUNT_ID
static java.lang.String
FIELD_CONTAINER_ID
static java.lang.String
FIELD_CREATION_TIME
static java.lang.String
FIELD_CRYPTO_AGENT_FACTORY
static java.lang.String
FIELD_DELETION_TIME
static java.lang.String
FIELD_ENCRYPTED_SIZE
static java.lang.String
FIELD_ENCRYPTION_ORIGIN
static java.lang.String
FIELD_EXPIRATION_TIME
static java.lang.String
FIELD_ID
static java.lang.String
FIELD_LIFE_VERSION
static java.lang.String
FIELD_NAME_SCHEME_VERSION
static java.lang.String
FIELD_PARTITION_ID
static java.lang.String
FIELD_SIZE
static java.lang.String
FIELD_UPLOAD_TIME
static java.lang.String
FIELD_VCR_KMS_CONTEXT
-
Constructor Summary
Constructors Constructor Description CloudBlobMetadata()
Default constructor (for JSONSerializer).CloudBlobMetadata(com.github.ambry.commons.BlobId blobId, long creationTime, long expirationTime, long size, CloudBlobMetadata.EncryptionOrigin encryptionOrigin)
Constructor fromBlobId
.CloudBlobMetadata(com.github.ambry.commons.BlobId blobId, long creationTime, long expirationTime, long size, CloudBlobMetadata.EncryptionOrigin encryptionOrigin, short lifeVersion)
Constructor fromBlobId
.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 fromBlobId
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.util.List<CloudBlobMetadata>
capMetadataListBySize(java.util.List<CloudBlobMetadata> originalList, long size)
Utility to cap specifiedCloudBlobMetadata
list by specified size of its blobs.boolean
equals(java.lang.Object o)
static CloudBlobMetadata
fromMap(java.util.Map<java.lang.String,java.lang.String> properties)
int
getAccountId()
int
getContainerId()
long
getCreationTime()
java.lang.String
getCryptoAgentFactory()
long
getDeletionTime()
long
getEncryptedSize()
CloudBlobMetadata.EncryptionOrigin
getEncryptionOrigin()
long
getExpirationTime()
java.lang.String
getId()
long
getLastUpdateTime()
short
getLifeVersion()
int
getNameSchemeVersion()
java.lang.String
getPartitionId()
long
getSize()
long
getUploadTime()
java.lang.String
getVcrKmsContext()
boolean
isCompactionCandidate(long retentionPeriod)
boolean
isDeleted()
boolean
isExpired()
boolean
isUndeleted()
CloudBlobMetadata
setAccountId(int accountId)
Set the account Id.CloudBlobMetadata
setContainerId(int containerId)
Set the container Id.CloudBlobMetadata
setCreationTime(long creationTime)
Set the creation time.CloudBlobMetadata
setCryptoAgentFactory(java.lang.String cryptoAgentFactory)
Sets the VCR crypto agent factory class name.CloudBlobMetadata
setDeletionTime(long deletionTime)
Set the blob deletion time.CloudBlobMetadata
setEncryptedSize(long encryptedSize)
Sets the encrypted size of the blobCloudBlobMetadata
setEncryptionOrigin(CloudBlobMetadata.EncryptionOrigin encryptionOrigin)
Sets the encryption origin.CloudBlobMetadata
setExpirationTime(long expirationTime)
Set the blob expiration time.CloudBlobMetadata
setId(java.lang.String id)
void
setLastUpdateTime(long lastUpdateTime)
Sets the last update time of the blob.void
setLifeVersion(short lifeVersion)
Sets the life version of the blob.CloudBlobMetadata
setNameSchemeVersion(int nameSchemeVersion)
Sets the blob naming scheme version.CloudBlobMetadata
setPartitionId(java.lang.String partitionId)
Set the partition Id.CloudBlobMetadata
setSize(long size)
Set the size.CloudBlobMetadata
setUploadTime(long uploadTime)
Set the upload time.CloudBlobMetadata
setVcrKmsContext(java.lang.String vcrKmsContext)
Sets the VCR KMS context.java.util.Map<java.lang.String,java.lang.String>
toMap()
-
-
-
Field Detail
-
FIELD_ID
public static final java.lang.String FIELD_ID
- See Also:
- Constant Field Values
-
FIELD_PARTITION_ID
public static final java.lang.String FIELD_PARTITION_ID
- See Also:
- Constant Field Values
-
FIELD_ACCOUNT_ID
public static final java.lang.String FIELD_ACCOUNT_ID
- See Also:
- Constant Field Values
-
FIELD_CONTAINER_ID
public static final java.lang.String FIELD_CONTAINER_ID
- See Also:
- Constant Field Values
-
FIELD_SIZE
public static final java.lang.String FIELD_SIZE
- See Also:
- Constant Field Values
-
FIELD_CREATION_TIME
public static final java.lang.String FIELD_CREATION_TIME
- See Also:
- Constant Field Values
-
FIELD_UPLOAD_TIME
public static final java.lang.String FIELD_UPLOAD_TIME
- See Also:
- Constant Field Values
-
FIELD_DELETION_TIME
public static final java.lang.String FIELD_DELETION_TIME
- See Also:
- Constant Field Values
-
FIELD_EXPIRATION_TIME
public static final java.lang.String FIELD_EXPIRATION_TIME
- See Also:
- Constant Field Values
-
FIELD_ENCRYPTION_ORIGIN
public static final java.lang.String FIELD_ENCRYPTION_ORIGIN
- See Also:
- Constant Field Values
-
FIELD_VCR_KMS_CONTEXT
public static final java.lang.String FIELD_VCR_KMS_CONTEXT
- See Also:
- Constant Field Values
-
FIELD_CRYPTO_AGENT_FACTORY
public static final java.lang.String FIELD_CRYPTO_AGENT_FACTORY
- See Also:
- Constant Field Values
-
FIELD_ENCRYPTED_SIZE
public static final java.lang.String FIELD_ENCRYPTED_SIZE
- See Also:
- Constant Field Values
-
FIELD_NAME_SCHEME_VERSION
public static final java.lang.String FIELD_NAME_SCHEME_VERSION
- See Also:
- Constant Field Values
-
FIELD_LIFE_VERSION
public static final java.lang.String FIELD_LIFE_VERSION
- See Also:
- Constant Field Values
-
-
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 fromBlobId
.- 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 fromBlobId
.- 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 fromBlobId
.- 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 theCloudBlobCryptoAgentFactory
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.
-
setId
public CloudBlobMetadata setId(java.lang.String 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.
-
getEncryptionOrigin
public CloudBlobMetadata.EncryptionOrigin getEncryptionOrigin()
- Returns:
- the
CloudBlobMetadata.EncryptionOrigin
.
-
setEncryptionOrigin
public CloudBlobMetadata setEncryptionOrigin(CloudBlobMetadata.EncryptionOrigin encryptionOrigin)
Sets the encryption origin.- Parameters:
encryptionOrigin
- theCloudBlobMetadata.EncryptionOrigin
.- 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 theCloudBlobCryptoAgentFactory
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 specifiedCloudBlobMetadata
list by specified size of its blobs. Always returns at least one metadata object irrespective of size.- Parameters:
originalList
- List ofCloudBlobMetadata
.size
- total size of metadata's blobs.- Returns:
List
ofCloudBlobMetadata
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 classjava.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.
-
-