dulceanu commented on code in PR #2480:
URL: https://github.com/apache/jackrabbit-oak/pull/2480#discussion_r2307017582
##########
oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/v8/AzureArchiveManagerV8.java:
##########
@@ -131,22 +137,43 @@ public SegmentArchiveWriter create(String archiveName)
throws IOException {
@Override
public boolean delete(String archiveName) {
try {
+ uploadDeletedMarker(archiveName);
getBlobs(archiveName)
.forEach(cloudBlob -> {
try {
- writeAccessController.checkWritingAllowed();
- cloudBlob.delete();
+ String blobName = getName(cloudBlob);
+ if (!blobName.equals(DELETED_ARCHIVE_MARKER) &&
!blobName.equals(CLOSED_ARCHIVE_MARKER)) {
+ writeAccessController.checkWritingAllowed();
+ cloudBlob.delete();
+ }
} catch (StorageException e) {
log.error("Can't delete segment {}",
cloudBlob.getUri().getPath(), e);
}
});
+ deleteClosedMarker(archiveName);
+ deleteDeletedMarker(archiveName);
return true;
- } catch (IOException e) {
+ } catch (IOException | URISyntaxException | StorageException e) {
log.error("Can't delete archive {}", archiveName, e);
return false;
}
}
+ private void deleteDeletedMarker(String archiveName) throws IOException,
URISyntaxException, StorageException {
+ writeAccessController.checkWritingAllowed();
+
getDirectory(archiveName).getBlockBlobReference(DELETED_ARCHIVE_MARKER).deleteIfExists();
+ }
+
+ private void deleteClosedMarker(String archiveName) throws IOException,
URISyntaxException, StorageException {
+ writeAccessController.checkWritingAllowed();
+
getDirectory(archiveName).getBlockBlobReference(CLOSED_ARCHIVE_MARKER).deleteIfExists();
+ }
+
+ private void uploadDeletedMarker(String archiveName) throws IOException,
URISyntaxException, StorageException {
+ writeAccessController.checkWritingAllowed();
+
getDirectory(archiveName).getBlockBlobReference(DELETED_ARCHIVE_MARKER).openOutputStream().close();
+ }
Review Comment:
The method could take the marker as parameter.
##########
oak-segment-azure/src/test/java/org/apache/jackrabbit/oak/segment/azure/AzureArchiveManagerTest.java:
##########
@@ -583,6 +585,69 @@ public void testWriteAfterLosingRepoLock() throws
Exception {
rwFileStore2.close();
}
+ @Test
+ public void testListArchivesDoesNotReturnDeletedArchive() throws
IOException, BlobStorageException {
+ // The archive manager should not return the archive which has
"deleted" marker
+ SegmentArchiveManager manager =
azurePersistence.createArchiveManager(false, false, new IOMonitorAdapter(), new
FileStoreMonitorAdapter(), new RemoteStoreMonitorAdapter());
+
+ // Create an archive
+ SegmentArchiveWriter writer = manager.create("data00000a.tar");
+ UUID u = UUID.randomUUID();
+ writer.writeSegment(u.getMostSignificantBits(),
u.getLeastSignificantBits(), new byte[10], 0, 10, 0, 0, false);
+ writer.flush();
+ writer.close();
Review Comment:
These lines can be removed in favor of `createArchive(manager,
"data00000a.tar");`.
##########
oak-segment-azure/src/main/java/org/apache/jackrabbit/oak/segment/azure/AzureArchiveManager.java:
##########
@@ -138,22 +143,44 @@ public SegmentArchiveWriter create(String archiveName)
throws IOException {
@Override
public boolean delete(String archiveName) {
try {
+ uploadDeletedMarker(archiveName);
getBlobs(archiveName)
.forEach(blobItem -> {
try {
- writeAccessController.checkWritingAllowed();
-
writeBlobContainerClient.getBlobClient(blobItem.getName()).delete();
+ String blobName = getName(blobItem);
+ if (!blobName.equals(DELETED_ARCHIVE_MARKER) &&
!blobName.equals(CLOSED_ARCHIVE_MARKER)) {
+ writeAccessController.checkWritingAllowed();
+
writeBlobContainerClient.getBlobClient(blobItem.getName()).delete();
+ }
} catch (BlobStorageException e) {
log.error("Can't delete segment {}",
blobItem.getName(), e);
}
});
+ deleteClosedMarker(archiveName);
+ deleteDeletedMarker(archiveName);
return true;
- } catch (IOException e) {
+ } catch (IOException | BlobStorageException e) {
log.error("Can't delete archive {}", archiveName, e);
return false;
}
}
+ private void deleteDeletedMarker(String archiveName) throws
BlobStorageException {
+ writeAccessController.checkWritingAllowed();
+ writeBlobContainerClient.getBlobClient(getDirectory(archiveName) +
DELETED_ARCHIVE_MARKER).deleteIfExists();
+ }
+
+ private void deleteClosedMarker(String archiveName) throws
BlobStorageException {
+ writeAccessController.checkWritingAllowed();
+ writeBlobContainerClient.getBlobClient(getDirectory(archiveName) +
CLOSED_ARCHIVE_MARKER).deleteIfExists();
+ }
Review Comment:
The method could take the marker as parameter.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]