fapifta commented on code in PR #6922:
URL: https://github.com/apache/ozone/pull/6922#discussion_r1676090446
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/bucket/OMBucketDeleteRequest.java:
##########
@@ -287,13 +288,17 @@ private boolean bucketContainsSnapshotInCache(
)
public static OMRequest blockBucketDeleteWithBucketLayoutFromOldClient(
OMRequest req, ValidationContext ctx) throws IOException {
- DeleteBucketRequest request = req.getDeleteBucketRequest();
-
- if (request.hasBucketName() && request.hasVolumeName()) {
- BucketLayout bucketLayout = ctx.getBucketLayout(
- request.getVolumeName(), request.getBucketName());
- bucketLayout.validateSupportedOperation();
+ if (ClientVersion.fromProtoValue(req.getVersion())
+ .compareTo(ClientVersion.BUCKET_LAYOUT_SUPPORT) < 0) {
+ DeleteBucketRequest request = req.getDeleteBucketRequest();
+
+ if (request.hasBucketName() && request.hasVolumeName()) {
+ BucketLayout bucketLayout = ctx.getBucketLayout(
+ request.getVolumeName(), request.getBucketName());
+ bucketLayout.validateSupportedOperation();
+ }
}
return req;
Review Comment:
I would even go further a bit...
What if we define a method in the ClientVersion enum, call it let's say
isNewerThan(ClientVersion), and use that instead of the compareTo?
With that this block can be reduced to an if
(ClientVersion.fromProtoValue(req.getVersion()).isNewerThan(ClientVersion.BUCKET_LAYOUT_SUPPORT))
An other option may be (though it means introducing a new method for every
version) to add a static method named like isNewerThanBucketLayout(int
version), do the proto to enum conversion in the method than the compareTo, and
return a boolen, so that the usage would look like:
if (ClientVersion.isNewerThanBucketLayout(req.getVersion()))
--
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]