@Override
  public void compactAssignedDeprecatedContainers(Collection<? extends PartitionId> assignedPartitions) {
    try {
      SortedSet<CosmosContainerDeletionEntry> containerDeletionEntrySet =
          fetchContainerDeletionEntries(assignedPartitions);
      while (!containerDeletionEntrySet.isEmpty()) {
        CosmosContainerDeletionEntry containerDeletionEntry = containerDeletionEntrySet.first();
        containerDeletionEntrySet.remove(containerDeletionEntry);
        for (String partitionId : containerDeletionEntry.getDeletePendingPartitions()) {
          try {
            logger.info("Starting compaction of container {}, account {} in partition {}",
                containerDeletionEntry.getContainerId(), containerDeletionEntry.getAccountId(), partitionId);
            int blobCompactedCount =
                compactContainer(containerDeletionEntry.getContainerId(), containerDeletionEntry.getAccountId(),
                    partitionId);
            logger.info("Compacted {} blobs of deprecated container {} account {} in partition {}", blobCompactedCount,
                containerDeletionEntry.getContainerId(), containerDeletionEntry.getAccountId(), partitionId);
            azureMetrics.deprecatedContainerCompactionSuccessCount.inc();
          } catch (CloudStorageException csEx) {
            azureMetrics.deprecatedContainerCompactionFailureCount.inc();
            logger.error("Container compaction failed for account {} container {} in partition {}",
                containerDeletionEntry.getAccountId(), containerDeletionEntry.getContainerId(), partitionId);
          }
        }
        if (containerDeletionEntrySet.isEmpty()) {
          containerDeletionEntrySet = fetchContainerDeletionEntries(assignedPartitions);
        }
      }
    } catch (CloudStorageException csEx) {
      logger.error("Container compaction failed due to {}", csEx.toString(), csEx);
    }
  }
Compact blobs of the deprecated container from cloud. This method is one of the two entry points in the
{@link AzureContainerCompactor} class along with {@link AzureContainerCompactor#deprecateContainers(Collection, Collection)}.
Note that this method is not thread safe as it is expected to run in a single thread.
@param assignedPartitions the {@link Collection} of {@link PartitionId}s assigned to this node.
ambry-cloud/src/main/java/com/github/ambry/cloud/azure/AzureContainerCompactor.java