You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "dombizita (via GitHub)" <gi...@apache.org> on 2023/08/23 12:38:30 UTC

[GitHub] [ozone] dombizita commented on a diff in pull request #5159: HDDS-9088 Implement logic for size calculation of a single deleted directory for OM db insights.

dombizita commented on code in PR #5159:
URL: https://github.com/apache/ozone/pull/5159#discussion_r1302953206


##########
hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/OMDBInsightEndpoint.java:
##########
@@ -520,6 +528,49 @@ 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) {
+      LOG.error("Invalid path format: {}", path);
+      return 0L;
+    }
+    /* DB key in DeletedDirectoryTable =>
+                      "/volumeId/bucketId/parentId/dirName/dirObjectId" */
+    String directoryObjectId = parts[5];
+
+    try {
+      long convertedValue = Long.parseLong(directoryObjectId);
+      NSSummary nsSummary =
+          reconNamespaceSummaryManager.getNSSummary(convertedValue);
+      if (nsSummary != null) {
+        return nsSummary.getSizeOfFiles();

Review Comment:
   @sumitagrawl is correct. just an idea: if you go through all the sub-directories and further recursively to get the correct size, wouldn't that be a bit too much to calculate here for each deleted directory? 



-- 
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: issues-unsubscribe@ozone.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org