devmadhuu commented on code in PR #5159:
URL: https://github.com/apache/ozone/pull/5159#discussion_r1286926216
##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/OMDBInsightEndpoint.java:
##########
@@ -520,6 +530,48 @@ private void getPendingForDeletionDirInfo(
}
}
+ /**
+ * Fetches the size of a deleted directory identified by the given path.
+ * The size is obtained from the NSSummary table using the directory
objectID.
+ * The path is expected to be in the format :-
+ * "volumeId/bucketId/parentId/dirName/dirObjectId".
+ *
+ * @param path The path of the deleted directory.
+ * @return The size of the deleted directory.
+ * @throws IOException If an I/O error occurs while retrieving the size.
+ */
+ public long fetchSizeForDeletedDirectory(String path)
+ throws IOException {
+ if (Strings.isNullOrEmpty(path)) {
+ LOG.error("Invalid path: Path is null or empty");
+ return 0L;
+ }
+
+ String[] parts = path.split("/");
+ if (parts.length < 6) {
Review Comment:
Pls check if need to cover length range between 5 & 6. Ideally should be
length as 5.
##########
hadoop-ozone/recon/src/test/java/org/apache/hadoop/ozone/recon/api/TestOmDBInsightEndPoint.java:
##########
@@ -693,4 +694,58 @@ public void testGetDeletedDirInfo() throws Exception {
Assertions.assertEquals("/sampleVol/bucketOne/dir_two",
keyInsightInfoResp.getLastKey());
}
+
+ @Test
+ public void testGetDirectorySizeInfo() throws Exception {
+
+ OmKeyInfo omKeyInfo1 =
+ getOmKeyInfo("sampleVol", "bucketOne", "dir1", false);
+ OmKeyInfo omKeyInfo2 =
+ getOmKeyInfo("sampleVol", "bucketTwo", "dir2", false);
+ OmKeyInfo omKeyInfo3 =
+ getOmKeyInfo("sampleVol", "bucketThree", "dir3", false);
+
+ // Add 3 entries to deleted dir table for directory dir1, dir2 and dir3
+ // having object id 1, 2 and 3 respectively
+ reconOMMetadataManager.getDeletedDirTable()
+ .put("/18/28/22/dir1/1", omKeyInfo1);
Review Comment:
@ArafatKhan2198 thanks for working on this patch. Pls update minor change
to correct parent Id same as bucket Id based on test data we are inserting.
--
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]