jojochuang commented on code in PR #10745:
URL: https://github.com/apache/ozone/pull/10745#discussion_r3617929444
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java:
##########
@@ -2993,8 +2993,13 @@ public List<OmBucketInfo> listBuckets(String volumeName,
String startKey,
volumeName, null, null);
}
metrics.incNumBucketLists();
- return bucketManager.listBuckets(volumeName,
+ List<OmBucketInfo> buckets = bucketManager.listBuckets(volumeName,
Review Comment:
i don't like that the list buckets is a short lived object. it would be nice
if we can reuse this list object.
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/OzoneManager.java:
##########
@@ -3009,6 +3014,50 @@ public List<OmBucketInfo> listBuckets(String volumeName,
String startKey,
}
}
+ /**
+ * For link buckets, follows the link chain and overlays the source bucket's
+ * operational properties onto the link's {@link OmBucketInfo}. Non-link
+ * buckets and dangling links are returned unchanged.
+ */
+ private OmBucketInfo enrichLinkBucketInfo(OmBucketInfo bucketInfo)
+ throws IOException {
+ if (!bucketInfo.isLink()) {
+ return bucketInfo;
+ }
+ // We already know that `bucketInfo` is a linked one,
+ // so we skip one `getBucketInfo` and start with the known link.
+ ResolvedBucket resolvedBucket =
+ resolveBucketLink(Pair.of(
+ bucketInfo.getSourceVolume(),
+ bucketInfo.getSourceBucket()),
+ true);
+
+ // If it is a dangling link it means no real bucket exists,
+ // for example, it could have been deleted, but the links still present.
+ if (resolvedBucket.isDangling()) {
+ return bucketInfo;
+ }
+ OmBucketInfo realBucket =
+ bucketManager.getBucketInfo(
+ resolvedBucket.realVolume(),
+ resolvedBucket.realBucket());
+ // Pass the real bucket metadata in the link bucket info.
+ return bucketInfo.toBuilder()
+ .setDefaultReplicationConfig(
+ realBucket.getDefaultReplicationConfig())
+ .setIsVersionEnabled(realBucket.getIsVersionEnabled())
+ .setStorageType(realBucket.getStorageType())
+ .setQuotaInBytes(realBucket.getQuotaInBytes())
+ .setQuotaInNamespace(realBucket.getQuotaInNamespace())
+ .setUsedBytes(realBucket.getUsedBytes())
+ .setSnapshotUsedBytes(realBucket.getSnapshotUsedBytes())
+ .setSnapshotUsedNamespace(realBucket.getSnapshotUsedNamespace())
+ .setUsedNamespace(realBucket.getUsedNamespace())
+ .addAllMetadata(realBucket.getMetadata())
+ .setBucketLayout(realBucket.getBucketLayout())
+ .build();
Review Comment:
i think this is going to be hard to maintain in the future, if we add
additional fields to the bucket.
What if we instantiate a bucketInfo object from realBucket, and update
volumeName, bucketName instead.
--
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]