Interface CloudDestination

  • All Superinterfaces:
    java.lang.AutoCloseable, java.io.Closeable

    public interface CloudDestination
    extends java.io.Closeable
    An interface representing an interaction with a cloud destination, that allows replicating blob operations.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      int compactPartition​(java.lang.String partitionPath)
      Compact the specified partition, removing blobs that have been deleted or expired for at least the configured retention period.
      boolean deleteBlob​(com.github.ambry.commons.BlobId blobId, long deletionTime, short lifeVersion, CloudUpdateValidator cloudUpdateValidator)
      Mark a blob as deleted in the cloud destination, if lifeVersion is less than or equal to life version of the existing blob.
      void deprecateContainers​(java.util.Collection<com.github.ambry.account.Container> deprecatedContainers)
      Deprecate the specified Containers in cloud.
      void downloadBlob​(com.github.ambry.commons.BlobId blobId, java.io.OutputStream outputStream)
      Download blob from the cloud destination.
      FindResult findEntriesSince​(java.lang.String partitionPath, com.github.ambry.replication.FindToken findToken, long maxTotalSizeOfEntries)
      Returns an ordered sequenced list of blobs within the specified partition and updated FindToken, such that total size of all blobs in the list are less or equal to maxTotalSizeOfEntries
      java.util.Map<java.lang.String,​CloudBlobMetadata> getBlobMetadata​(java.util.List<com.github.ambry.commons.BlobId> blobIds)
      Query the blob metadata for the specified blobs.
      CloudContainerCompactor getContainerCompactor()  
      void persistTokens​(java.lang.String partitionPath, java.lang.String tokenFileName, java.io.InputStream inputStream)
      Upload and persist the replica tokens for the specified Ambry partition in cloud storage.
      boolean retrieveTokens​(java.lang.String partitionPath, java.lang.String tokenFileName, java.io.OutputStream outputStream)
      Retrieve the persisted replica tokens, if any, for the specified Ambry partition.
      void stopCompaction()
      Halt any compactions in progress.
      short undeleteBlob​(com.github.ambry.commons.BlobId blobId, short lifeVersion, CloudUpdateValidator cloudUpdateValidator)
      Undelete the blob from cloud destination, and update the new life version.
      short updateBlobExpiration​(com.github.ambry.commons.BlobId blobId, long expirationTime, CloudUpdateValidator cloudUpdateValidator)
      Update expiration time of blob in the cloud destination.
      boolean uploadBlob​(com.github.ambry.commons.BlobId blobId, long inputLength, CloudBlobMetadata cloudBlobMetadata, java.io.InputStream blobInputStream)
      Upload blob to the cloud destination.
      • Methods inherited from interface java.io.Closeable

        close
    • Method Detail

      • uploadBlob

        boolean uploadBlob​(com.github.ambry.commons.BlobId blobId,
                           long inputLength,
                           CloudBlobMetadata cloudBlobMetadata,
                           java.io.InputStream blobInputStream)
                    throws CloudStorageException
        Upload blob to the cloud destination.
        Parameters:
        blobId - id of the Ambry blob
        inputLength - the length of the input stream, if known, -1 if unknown.
        cloudBlobMetadata - the CloudBlobMetadata for the blob being uploaded.
        blobInputStream - the stream to read blob data
        Returns:
        flag indicating whether the blob was uploaded
        Throws:
        CloudStorageException - if the upload encounters an error.
      • downloadBlob

        void downloadBlob​(com.github.ambry.commons.BlobId blobId,
                          java.io.OutputStream outputStream)
                   throws CloudStorageException
        Download blob from the cloud destination.
        Parameters:
        blobId - id of the Ambry blob to be downloaded
        outputStream - outputstream to populate the downloaded data with
        Throws:
        CloudStorageException - if the download encounters an error.
      • deleteBlob

        boolean deleteBlob​(com.github.ambry.commons.BlobId blobId,
                           long deletionTime,
                           short lifeVersion,
                           CloudUpdateValidator cloudUpdateValidator)
                    throws CloudStorageException
        Mark a blob as deleted in the cloud destination, if lifeVersion is less than or equal to life version of the existing blob.
        Parameters:
        blobId - id of the Ambry blob
        deletionTime - time of blob deletion
        lifeVersion - life version of the blob to be deleted.
        cloudUpdateValidator - CloudUpdateValidator object passed by caller to validate the delete.
        Returns:
        flag indicating whether the blob was deleted
        Throws:
        CloudStorageException - if the deletion encounters an error.
      • undeleteBlob

        short undeleteBlob​(com.github.ambry.commons.BlobId blobId,
                           short lifeVersion,
                           CloudUpdateValidator cloudUpdateValidator)
                    throws CloudStorageException
        Undelete the blob from cloud destination, and update the new life version.
        Parameters:
        blobId - id of the Ambry blob.
        lifeVersion - new life version to update.
        cloudUpdateValidator - CloudUpdateValidator object passed by caller to validate the undelete.
        Returns:
        final live version of the undeleted blob.
        Throws:
        CloudStorageException - if the undelete encounters an error.
      • updateBlobExpiration

        short updateBlobExpiration​(com.github.ambry.commons.BlobId blobId,
                                   long expirationTime,
                                   CloudUpdateValidator cloudUpdateValidator)
                            throws CloudStorageException
        Update expiration time of blob in the cloud destination.
        Parameters:
        blobId - id of the Ambry blob
        expirationTime - the new expiration time
        cloudUpdateValidator - CloudUpdateValidator object passed by caller to validate the update.
        Returns:
        the life version of the blob if the blob was updated, otherwise -1.
        Throws:
        CloudStorageException - if the update encounters an error.
      • getBlobMetadata

        java.util.Map<java.lang.String,​CloudBlobMetadata> getBlobMetadata​(java.util.List<com.github.ambry.commons.BlobId> blobIds)
                                                                         throws CloudStorageException
        Query the blob metadata for the specified blobs.
        Parameters:
        blobIds - list of blob Ids to query.
        Returns:
        a Map of blobId strings to CloudBlobMetadata. If metadata for a blob could not be found, it will not be included in the returned map.
        Throws:
        CloudStorageException
      • findEntriesSince

        FindResult findEntriesSince​(java.lang.String partitionPath,
                                    com.github.ambry.replication.FindToken findToken,
                                    long maxTotalSizeOfEntries)
                             throws CloudStorageException
        Returns an ordered sequenced list of blobs within the specified partition and updated FindToken, such that total size of all blobs in the list are less or equal to maxTotalSizeOfEntries
        Parameters:
        partitionPath - the partition to query.
        findToken - the FindToken specifying the boundary for the query.
        maxTotalSizeOfEntries - the cumulative size limit for the list of blobs returned.
        Returns:
        FindResult instance that contains updated FindToken object which can act as a bookmark for subsequent requests, and List of CloudBlobMetadata entries referencing the blobs returned by the query.
        Throws:
        CloudStorageException
      • compactPartition

        int compactPartition​(java.lang.String partitionPath)
                      throws CloudStorageException
        Compact the specified partition, removing blobs that have been deleted or expired for at least the configured retention period.
        Parameters:
        partitionPath - the path of the partitions to compact.
        Throws:
        CloudStorageException
      • persistTokens

        void persistTokens​(java.lang.String partitionPath,
                           java.lang.String tokenFileName,
                           java.io.InputStream inputStream)
                    throws CloudStorageException
        Upload and persist the replica tokens for the specified Ambry partition in cloud storage.
        Parameters:
        partitionPath - the string form of the partitionId
        tokenFileName - the name of the token file to store in the cloud.
        inputStream - the InputStream containing the replica tokens.
        Throws:
        CloudStorageException - if the upload encounters an error.
      • retrieveTokens

        boolean retrieveTokens​(java.lang.String partitionPath,
                               java.lang.String tokenFileName,
                               java.io.OutputStream outputStream)
                        throws CloudStorageException
        Retrieve the persisted replica tokens, if any, for the specified Ambry partition.
        Parameters:
        partitionPath - the string form of the partitionId
        tokenFileName - the name of the token file stored in the cloud.
        outputStream - the OutputStream to which the replica tokens are written.
        Returns:
        true if tokens were found, otherwise false.
        Throws:
        CloudStorageException - if the upload encounters an error.
      • stopCompaction

        void stopCompaction()
        Halt any compactions in progress.
      • deprecateContainers

        void deprecateContainers​(java.util.Collection<com.github.ambry.account.Container> deprecatedContainers)
                          throws CloudStorageException
        Deprecate the specified Containers in cloud.
        Parameters:
        deprecatedContainers - Collection of deprecated Containers.
        Throws:
        CloudStorageException