ashishkumar50 commented on code in PR #4655:
URL: https://github.com/apache/ozone/pull/4655#discussion_r1187255006


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/helpers/KeyValueContainerUtil.java:
##########
@@ -392,6 +397,24 @@ private static void 
initializeUsedBytesAndBlockCount(DatanodeStore store,
     kvData.setBlockCount(blockCount);
   }
 
+  /**
+   * A container is empty if:
+   * - The container is closed
+   * - There are no blocks in its block table.
+   *
+   * Empty containers are eligible for deletion.
+   */
+  public static boolean isEmpty(DatanodeStore store,
+      KeyValueContainerData container) throws IOException {
+    if (container.isOpen()) {
+      return false;
+    }
+    try (BlockIterator<BlockData> blockIterator =

Review Comment:
   We keep block count metadata information separately about container, which 
can go wrong sometime due to various reasons. Now we decouple metadata 
information to judge if container is empty or not by checking directly block 
table if any block exists or not for the particular container.



-- 
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]

Reply via email to