@Test public void testDeleteAfterPartialCompaction() throws Exception { BlobStorageException ex = mockStorageException(BlobErrorCode.BLOB_NOT_FOUND); when(mockBlockBlobClient.getPropertiesWithResponse(any(), any(), any())).thenThrow(ex); long deletionTime = System.currentTimeMillis() - TimeUnit.DAYS.toMillis(10); CloudBlobMetadata deletedMetadata = new CloudBlobMetadata().setId(blobId.getID()).setDeletionTime(deletionTime); Observable<ResourceResponse<Document>> mockResponse = getMockedObservableForSingleResource(deletedMetadata); when(mockumentClient.readDocument(anyString(), any(RequestOptions.class))).thenReturn(mockResponse); try { assertFalse("Expected update to recover and return false", azureDest.deleteBlob(blobId, deletionTime, (short) 0, dummyCloudUpdateValidator)); } catch (CloudStorageException cex) { assertTrue(cex.getCause() instanceof BlobStorageException); assertEquals(((BlobStorageException) cex.getCause()).getErrorCode(), BlobErrorCode.BLOB_NOT_FOUND); } assertEquals("Expected recovery", 1, azureMetrics.blobUpdateRecoverCount.getCount()); verify(mockumentClient).deleteDocument(anyString(), any()); }
@Override public boolean deleteBlob(BlobId blobId, long deletionTime, short lifeVersion, CloudUpdateValidator cloudUpdateValidator) throws CloudStorageException { Map<String, Object> updateFields = new HashMap<>(); updateFields.put(CloudBlobMetadata.FIELD_LIFE_VERSION, lifeVersion); updateFields.put(CloudBlobMetadata.FIELD_DELETION_TIME, deletionTime); UpdateResponse updateResponse = updateBlobMetadata(blobId, updateFields, cloudUpdateValidator); return updateResponse.wasUpdated; }
AzureCloudDestination implements CloudDestination { @Override public boolean deleteBlob(BlobId blobId, long deletionTime, short lifeVersion, CloudUpdateValidator cloudUpdateValidator) throws CloudStorageException { Map<String, Object> updateFields = new HashMap<>(); updateFields.put(CloudBlobMetadata.FIELD_LIFE_VERSION, lifeVersion); updateFields.put(CloudBlobMetadata.FIELD_DELETION_TIME, deletionTime); UpdateResponse updateResponse = updateBlobMetadata(blobId, updateFields, cloudUpdateValidator); return updateResponse.wasUpdated; } }
AzureCloudDestination implements CloudDestination { @Override public boolean deleteBlob(BlobId blobId, long deletionTime, short lifeVersion, CloudUpdateValidator cloudUpdateValidator) throws CloudStorageException { Map<String, Object> updateFields = new HashMap<>(); updateFields.put(CloudBlobMetadata.FIELD_LIFE_VERSION, lifeVersion); updateFields.put(CloudBlobMetadata.FIELD_DELETION_TIME, deletionTime); UpdateResponse updateResponse = updateBlobMetadata(blobId, updateFields, cloudUpdateValidator); return updateResponse.wasUpdated; } AzureCloudDestination(CloudConfig cloudConfig, AzureCloudConfig azureCloudConfig, String clusterName,
      VcrMetrics vcrMetrics, AzureMetrics azureMetrics, AzureReplicationFeed.FeedType azureReplicationFeedType);   AzureCloudDestination(BlobServiceClient storageClient, BlobBatchClient blobBatchClient,
      AsyncDocumentClient asyncDocumentClient, String cosmosCollectionLink, String clusterName,
      AzureMetrics azureMetrics, AzureReplicationFeed.FeedType azureReplicationFeedType, boolean isVcr); }
AzureCloudDestination implements CloudDestination { @Override public boolean deleteBlob(BlobId blobId, long deletionTime, short lifeVersion, CloudUpdateValidator cloudUpdateValidator) throws CloudStorageException { Map<String, Object> updateFields = new HashMap<>(); updateFields.put(CloudBlobMetadata.FIELD_LIFE_VERSION, lifeVersion); updateFields.put(CloudBlobMetadata.FIELD_DELETION_TIME, deletionTime); UpdateResponse updateResponse = updateBlobMetadata(blobId, updateFields, cloudUpdateValidator); return updateResponse.wasUpdated; } AzureCloudDestination(CloudConfig cloudConfig, AzureCloudConfig azureCloudConfig, String clusterName,
      VcrMetrics vcrMetrics, AzureMetrics azureMetrics, AzureReplicationFeed.FeedType azureReplicationFeedType);   AzureCloudDestination(BlobServiceClient storageClient, BlobBatchClient blobBatchClient,
      AsyncDocumentClient asyncDocumentClient, String cosmosCollectionLink, String clusterName,
      AzureMetrics azureMetrics, AzureReplicationFeed.FeedType azureReplicationFeedType, boolean isVcr); @Override boolean uploadBlob(BlobId blobId, long inputLength, CloudBlobMetadata cloudBlobMetadata,
      InputStream blobInputStream); @Override void downloadBlob(BlobId blobId, OutputStream outputStream); @Override boolean deleteBlob(BlobId blobId, long deletionTime, short lifeVersion,
      CloudUpdateValidator cloudUpdateValidator); @Override short updateBlobExpiration(BlobId blobId, long expirationTime, CloudUpdateValidator cloudUpdateValidator); @Override short undeleteBlob(BlobId blobId, short lifeVersion, CloudUpdateValidator cloudUpdateValidator); @Override Map<String, CloudBlobMetadata> getBlobMetadata(List<BlobId> blobIds); @Override void close(); @Override void stopCompaction(); @Override FindResult findEntriesSince(String partitionPath, FindToken findToken, long maxTotalSizeOfEntries); @Override int compactPartition(String partitionPath); @Override void persistTokens(String partitionPath, String tokenFileName, InputStream inputStream); @Override boolean retrieveTokens(String partitionPath, String tokenFileName, OutputStream outputStream); int getQueryBatchSize(); }
AzureCloudDestination implements CloudDestination { @Override public boolean deleteBlob(BlobId blobId, long deletionTime, short lifeVersion, CloudUpdateValidator cloudUpdateValidator) throws CloudStorageException { Map<String, Object> updateFields = new HashMap<>(); updateFields.put(CloudBlobMetadata.FIELD_LIFE_VERSION, lifeVersion); updateFields.put(CloudBlobMetadata.FIELD_DELETION_TIME, deletionTime); UpdateResponse updateResponse = updateBlobMetadata(blobId, updateFields, cloudUpdateValidator); return updateResponse.wasUpdated; } AzureCloudDestination(CloudConfig cloudConfig, AzureCloudConfig azureCloudConfig, String clusterName,
      VcrMetrics vcrMetrics, AzureMetrics azureMetrics, AzureReplicationFeed.FeedType azureReplicationFeedType);   AzureCloudDestination(BlobServiceClient storageClient, BlobBatchClient blobBatchClient,
      AsyncDocumentClient asyncDocumentClient, String cosmosCollectionLink, String clusterName,
      AzureMetrics azureMetrics, AzureReplicationFeed.FeedType azureReplicationFeedType, boolean isVcr); @Override boolean uploadBlob(BlobId blobId, long inputLength, CloudBlobMetadata cloudBlobMetadata,
      InputStream blobInputStream); @Override void downloadBlob(BlobId blobId, OutputStream outputStream); @Override boolean deleteBlob(BlobId blobId, long deletionTime, short lifeVersion,
      CloudUpdateValidator cloudUpdateValidator); @Override short updateBlobExpiration(BlobId blobId, long expirationTime, CloudUpdateValidator cloudUpdateValidator); @Override short undeleteBlob(BlobId blobId, short lifeVersion, CloudUpdateValidator cloudUpdateValidator); @Override Map<String, CloudBlobMetadata> getBlobMetadata(List<BlobId> blobIds); @Override void close(); @Override void stopCompaction(); @Override FindResult findEntriesSince(String partitionPath, FindToken findToken, long maxTotalSizeOfEntries); @Override int compactPartition(String partitionPath); @Override void persistTokens(String partitionPath, String tokenFileName, InputStream inputStream); @Override boolean retrieveTokens(String partitionPath, String tokenFileName, OutputStream outputStream); int getQueryBatchSize();  }