smengcl commented on code in PR #4015:
URL: https://github.com/apache/ozone/pull/4015#discussion_r1054850416
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketDeleteRequest.java:
##########
@@ -198,6 +216,42 @@ public OMClientResponse
validateAndUpdateCache(OzoneManager ozoneManager,
}
}
+ private boolean bucketContainsSnapshot(OMMetadataManager omMetadataManager,
+ String snapshotBucketKey) throws IOException {
+ return bucketContainsSnapshotInCache(omMetadataManager, snapshotBucketKey)
+ || bucketContainsSnapshotInTable(omMetadataManager, snapshotBucketKey);
+ }
+
+ private boolean bucketContainsSnapshotInTable(
+ OMMetadataManager omMetadataManager, String snapshotBucketKey)
+ throws IOException {
+ try (
+ TableIterator<String, ? extends Table.KeyValue<String, SnapshotInfo>>
+ snapshotIterator = omMetadataManager
+ .getSnapshotInfoTable().iterator()) {
+ snapshotIterator.seek(snapshotBucketKey);
+ if (snapshotIterator.hasNext()) {
+ return snapshotIterator.next().getKey().startsWith(snapshotBucketKey);
Review Comment:
Note: Revisit this once snapshot deletion (and GC) is implemented. Because
the entry in cache could be a tombstone marker, like this one:
https://github.com/apache/ozone/blob/ddbe71d3f90ae14ecf29f51c2265f1f9c3171668/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketDeleteRequest.java#L144-L146
Therefore, we might need to check if the **value** is null as well. Just
like this:
https://github.com/apache/ozone/blob/5eead92666b374c4bb912f332488acb23f9a81df/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OmMetadataManagerImpl.java#L1047-L1050
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]