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


##########
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:
   This PR is being done and added a flag due to inconsistency in block count 
data, so what brings inconsistency and why that inconsistency will not impact 
above logic ?



##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/replication/ReplicationTestUtil.java:
##########
@@ -160,6 +160,7 @@ public static ContainerReplica 
createContainerReplica(ContainerID containerID,
     builder.setDatanodeDetails(datanodeDetails);
     builder.setSequenceId(0);
     builder.setOriginNodeId(originNodeId);
+    builder.setEmpty(keyCount == 0);

Review Comment:
   Should this be keyCount or blockCount ?



##########
hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/HddsTestUtils.java:
##########
@@ -736,7 +736,8 @@ public static ContainerReplica.ContainerReplicaBuilder 
getReplicaBuilder(
             .setDatanodeDetails(datanodeDetails)
             .setOriginNodeId(originNodeId).setSequenceId(sequenceId)
             .setBytesUsed(usedBytes)
-            .setKeyCount(keyCount);
+            .setKeyCount(keyCount)

Review Comment:
   Should this be keyCount or blockCount ?



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