adoroszlai commented on code in PR #6268:
URL: https://github.com/apache/ozone/pull/6268#discussion_r1510839456
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/PrefixManagerImpl.java:
##########
@@ -322,23 +331,53 @@ public OMPrefixAclOpResult setAcl(OzoneObj ozoneObj,
List<OzoneAcl> ozoneAcls,
prefixInfoBuilder.setUpdateID(transactionLogIndex);
}
prefixInfo = prefixInfoBuilder.build();
+ newPrefix = true;
}
boolean changed = prefixInfo.setAcls(ozoneAcls);
- inheritParentAcl(ozoneObj, prefixInfo);
+ if (newPrefix) {
+ inheritParentAcl(ozoneObj, prefixInfo);
+ }
prefixTree.insert(ozoneObj.getPath(), prefixInfo);
if (!isRatisEnabled) {
metadataManager.getPrefixTable().put(ozoneObj.getPath(), prefixInfo);
}
return new OMPrefixAclOpResult(prefixInfo, changed);
}
+ /**
+ * Get the resolved prefix object to handle prefix that is under a link
bucket.
+ * @param obj prefix object
+ * @return the resolved prefix object if the object belongs under a link
bucket.
+ * Otherwise, return the same prefix object.
+ * @throws IOException Exception thrown when resolving the bucket link.
+ */
+ private OzoneObj getResolvedPrefixObj(OzoneObj obj) throws IOException {
+ if (StringUtils.isEmpty(obj.getVolumeName()) ||
StringUtils.isEmpty(obj.getBucketName())) {
+ return obj;
+ }
+
+ ResolvedBucket resolvedBucket = ozoneManager.resolveBucketLink(
+ Pair.of(obj.getVolumeName(), obj.getBucketName()));
+ String realVolume = resolvedBucket.realVolume();
+ String realBucket = resolvedBucket.realBucket();
+ // If the bucket is not a link bucket, just return the Ozone object
+ if (realVolume.equals(obj.getVolumeName()) &&
realBucket.equals(obj.getBucketName())) {
+ return obj;
+ }
+ // If the bucket is a link bucket, return a new OzoneObj with resolved
volume and bucket name
+ return OzoneObjInfo.Builder.fromOzoneObj(obj)
+ .setVolumeName(realVolume).setBucketName(realBucket).build();
+ }
Review Comment:
We can extract this part as `ResolvedBucket#update(OzoneObj)`, similar to:
https://github.com/apache/ozone/blob/11c5eb86a4f43c4297a39a496051173e420b9edc/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ResolvedBucket.java#L105-L112
It can then be reused in:
https://github.com/apache/ozone/blob/fb1ad58359de34e44e0e9ddfca3314f369011d1a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/acl/prefix/OMPrefixAclRequest.java#L84-L91
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/PrefixManagerImpl.java:
##########
@@ -322,23 +331,53 @@ public OMPrefixAclOpResult setAcl(OzoneObj ozoneObj,
List<OzoneAcl> ozoneAcls,
prefixInfoBuilder.setUpdateID(transactionLogIndex);
}
prefixInfo = prefixInfoBuilder.build();
+ newPrefix = true;
}
boolean changed = prefixInfo.setAcls(ozoneAcls);
- inheritParentAcl(ozoneObj, prefixInfo);
+ if (newPrefix) {
+ inheritParentAcl(ozoneObj, prefixInfo);
+ }
prefixTree.insert(ozoneObj.getPath(), prefixInfo);
if (!isRatisEnabled) {
metadataManager.getPrefixTable().put(ozoneObj.getPath(), prefixInfo);
}
return new OMPrefixAclOpResult(prefixInfo, changed);
}
+ /**
+ * Get the resolved prefix object to handle prefix that is under a link
bucket.
+ * @param obj prefix object
+ * @return the resolved prefix object if the object belongs under a link
bucket.
+ * Otherwise, return the same prefix object.
+ * @throws IOException Exception thrown when resolving the bucket link.
+ */
+ private OzoneObj getResolvedPrefixObj(OzoneObj obj) throws IOException {
+ if (StringUtils.isEmpty(obj.getVolumeName()) ||
StringUtils.isEmpty(obj.getBucketName())) {
+ return obj;
+ }
+
+ ResolvedBucket resolvedBucket = ozoneManager.resolveBucketLink(
+ Pair.of(obj.getVolumeName(), obj.getBucketName()));
+ String realVolume = resolvedBucket.realVolume();
+ String realBucket = resolvedBucket.realBucket();
+ // If the bucket is not a link bucket, just return the Ozone object
+ if (realVolume.equals(obj.getVolumeName()) &&
realBucket.equals(obj.getBucketName())) {
Review Comment:
nit: `ResolvedBucket` has a method to check the same.
```suggestion
if (!resolvedBucket.isLink()) {
```
--
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]