From b9c3e9059efcdcc3230aef369d84ee088a85bb62 Mon Sep 17 00:00:00 2001 From: tanvipenumudy <46785609+tanvipenumudy@users.noreply.github.com> Date: Thu, 24 Jul 2025 12:03:08 +0530 Subject: [PATCH] HDDS-13188. Track total pending deletion size for FSO directories in OM via Recon (#8591) --- .../ozone/recon/api/OMDBInsightEndpoint.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/OMDBInsightEndpoint.java b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/OMDBInsightEndpoint.java index ae8e9bdb0b2e..af898b861506 100644 --- a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/OMDBInsightEndpoint.java +++ b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/api/OMDBInsightEndpoint.java @@ -642,6 +642,29 @@ private void getPendingForDeletionDirInfo( } } + private void calculateTotalPendingDeletedDirSizes(Map dirSummary) { + long totalDataSize = 0L; + long totalReplicatedDataSize = 0L; + + Table deletedDirTable = omMetadataManager.getDeletedDirTable(); + try (TableIterator> iterator = deletedDirTable.iterator()) { + while (iterator.hasNext()) { + Table.KeyValue kv = iterator.next(); + OmKeyInfo omKeyInfo = kv.getValue(); + if (omKeyInfo != null) { + Pair sizeInfo = fetchSizeForDeletedDirectory(omKeyInfo.getObjectID()); + totalDataSize += sizeInfo.getLeft(); + totalReplicatedDataSize += sizeInfo.getRight(); + } + } + } catch (IOException ex) { + throw new WebApplicationException(ex, Response.Status.INTERNAL_SERVER_ERROR); + } + + dirSummary.put("totalDataSize", totalDataSize); + dirSummary.put("totalReplicatedDataSize", totalReplicatedDataSize); + } + /** * Given an object ID, return total data size as a pair of Total Size, Total Replicated Size * under this object. Note:- This method is RECURSIVE. @@ -744,6 +767,28 @@ public Response getDeletedDirectorySummary() { return Response.ok(dirSummary).build(); } + /** + * Retrieves the summary of the total delete pending directory size (unreplicated and replicated). + * + * @return The HTTP response body includes a map with the following entries: + * - "totalDataSize": the total replicated size of delete pending directories. + * - "totalReplicatedDataSize": the total unreplicated size of delete pending directories. + * + * Example response: + * { + * "totalDataSize": 30000, + * "totalReplicatedDataSize": 90000 + * } + */ + @GET + @Path("/deletePending/dirs/size-summary") + public Response getTotalDeletedDirectorySizeSummary() { + Map dirSummary = new HashMap<>(); + // Create a keys summary for deleted directories + calculateTotalPendingDeletedDirSizes(dirSummary); + return Response.ok(dirSummary).build(); + } + /** * This API will list out limited 'count' number of keys after applying below filters in API parameters: * Default Values of API param filters: