Class CosmosChangeFeedBasedReplicationFeed

  • All Implemented Interfaces:
    AzureReplicationFeed, java.io.Closeable, java.lang.AutoCloseable

    public final class CosmosChangeFeedBasedReplicationFeed
    extends java.lang.Object
    implements AzureReplicationFeed
    The replication feed that provides next list of blobs to replicate from Azure and corresponding FindToken using Cosmos change feed apis.
    • Constructor Detail

      • CosmosChangeFeedBasedReplicationFeed

        public CosmosChangeFeedBasedReplicationFeed​(CosmosDataAccessor cosmosDataAccessor,
                                                    AzureMetrics azureMetrics,
                                                    int changeFeedBatchSize)
        Constructor to create a CosmosChangeFeedBasedReplicationFeed object.
        Parameters:
        cosmosDataAccessor - CosmosDataAccessor object.
        azureMetrics - {@link {@link AzureMetrics} object.
        changeFeedBatchSize - batch size for each change feed request.
    • Method Detail

      • getNextEntriesAndUpdatedToken

        public FindResult getNextEntriesAndUpdatedToken​(com.github.ambry.replication.FindToken curFindToken,
                                                        long maxTotalSizeOfEntries,
                                                        java.lang.String partitionPath)
                                                 throws com.microsoft.azure.cosmosdb.DocumentClientException
        Get next set of change feed entries for the specified partition, after the curFindToken. The number of entries is capped by maxEntriesSize. This method creates a cache for change feed entries. If the curFindToken is not valid, or if all the items in the cache are consumed, then it queries Cosmos for new entries.
        Specified by:
        getNextEntriesAndUpdatedToken in interface AzureReplicationFeed
        Parameters:
        curFindToken - FindToken after which the next entries have to be returned.
        maxTotalSizeOfEntries - maximum size of all the blobs returned.
        partitionPath - Partition for which change feed entries have to be returned.
        Returns:
        FindResult instance that contains updated FindToken object which can act as a bookmark for subsequent requests, and List of CloudBlobMetadata entries.
        Throws:
        com.microsoft.azure.cosmosdb.DocumentClientException - if any cosmos query encounters error.
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable