devmadhuu commented on code in PR #6503:
URL: https://github.com/apache/ozone/pull/6503#discussion_r1583147434
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/handlers/FSOBucketHandler.java:
##########
@@ -146,49 +145,116 @@ public long calculateDUUnderObject(long parentId)
break;
}
OmKeyInfo keyInfo = kv.getValue();
+ if (recursive) {
+ if (stats.getLimit() == -1) {
+ populateDiskUsage(keyInfo, diskUsageList);
+ } else {
+ if (stats.getCurrentCount() < stats.getLimit()) {
+ populateDiskUsage(keyInfo, diskUsageList);
+ stats.setCurrentCount(stats.getCurrentCount() + 1);
+ stats.setLastKey(kv.getKey());
+ }
+ }
+ }
if (keyInfo != null) {
+ stats.setTotalCount(stats.getTotalCount() + 1);
totalDU += keyInfo.getReplicatedSize();
}
}
}
// handle nested keys (DFS)
NSSummary nsSummary = getReconNamespaceSummaryManager()
- .getNSSummary(parentId);
+ .getNSSummary(parentId);
// empty bucket
if (nsSummary == null) {
return 0;
}
Set<Long> subDirIds = nsSummary.getChildDir();
for (long subDirId: subDirIds) {
- totalDU += calculateDUUnderObject(subDirId);
+ totalDU += calculateDUUnderObject(subDirId, recursive, diskUsageList,
stats);
}
return totalDU;
}
+ private void populateDiskUsage(OmKeyInfo keyInfo, List<DUResponse.DiskUsage>
diskUsageList) throws IOException {
+ DUResponse.DiskUsage diskUsage = new DUResponse.DiskUsage();
+ diskUsage.setKey(keyInfo.isFile());
+ diskUsage.setSubpath(constructFullPath(keyInfo,
getReconNamespaceSummaryManager()));
+ diskUsage.setSize(keyInfo.getDataSize());
+ diskUsage.setSizeWithReplica(keyInfo.getReplicatedSize());
+
diskUsage.setReplicationType(keyInfo.getReplicationConfig().getReplicationType().name());
+ diskUsage.setCreationTime(keyInfo.getCreationTime());
+ diskUsage.setModificationTime(keyInfo.getModificationTime());
+
+ diskUsageList.add(diskUsage);
+ }
+
+ /**
+ * Constructs the full path of a key from its OmKeyInfo using a bottom-up
approach, starting from the leaf node.
+ * <p>
+ * The method begins with the leaf node (the key itself) and recursively
prepends parent directory names, fetched
+ * via NSSummary objects, until reaching the parent bucket (parentId is -1).
It effectively builds the path from
+ * bottom to top, finally prepending the volume and bucket names to complete
the full path.
+ *
+ * @param omKeyInfo The OmKeyInfo object for the key
+ * @return The constructed full path of the key as a String.
+ * @throws IOException
+ */
+ public static String constructFullPath(OmKeyInfo omKeyInfo,
Review Comment:
Yes, needs to rebase it.
--
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]