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

[GitHub] [ozone] siddhantsangwan commented on a diff in pull request #4209: HDDS-7799. Add container count to datanode usage info

siddhantsangwan commented on code in PR #4209:
URL: https://github.com/apache/ozone/pull/4209#discussion_r1097061742


##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/TestContainerOperations.java:
##########
@@ -132,4 +132,30 @@ public void testDatanodeUsageInfoCompatibility() throws IOException {
           .anyMatch(port -> REPLICATION.name().equals(port.getName())));
     }
   }
+
+  @Test
+  public void testDatanodeUsageInfoContainerCount() throws IOException {
+    DatanodeDetails dn = cluster.getStorageContainerManager()
+            .getScmNodeManager()
+            .getAllNodes()
+            .get(0);
+    dn.setCurrentVersion(0);
+
+    List<HddsProtos.DatanodeUsageInfoProto> usageInfoList =
+            storageClient.getDatanodeUsageInfo(
+                    dn.getIpAddress(), dn.getUuidString());
+
+    assertEquals(1, usageInfoList.size());
+    assertEquals(0, usageInfoList.get(0).getContainerCount());
+
+    storageClient.createContainer(HddsProtos
+            .ReplicationType.STAND_ALONE, HddsProtos.ReplicationFactor
+            .ONE, OzoneConsts.OZONE);
+
+    usageInfoList = storageClient.getDatanodeUsageInfo(
+                    dn.getIpAddress(), dn.getUuidString());
+
+    assertEquals(1, usageInfoList.size());
+    assertEquals(1, usageInfoList.get(0).getContainerCount());
+  }

Review Comment:
   Is it guaranteed that this standalone container will always be created on the first DN that we got above? This test might start failing if the underlying `createContainer` implementation is changed in the future. Worth verifying.



##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java:
##########
@@ -1050,6 +1050,14 @@ private HddsProtos.DatanodeUsageInfoProto getUsageInfoFromDatanodeDetails(
       DatanodeDetails node, int clientVersion) {

Review Comment:
   The implementation of this method largely seems redundant now that some other additions have been made. NIT but we could replace its implementation with something like this:
   ```
       int containerCount = -1;
       try {
         containerCount = scm.getScmNodeManager().getContainers(node).size();
       } catch (NodeNotFoundException ex) {
         LOG.error("Received container report from unknown datanode {}.",
                 node, ex);
       }
       DatanodeUsageInfo usageInfo = scm.getScmNodeManager().getUsageInfo(node);
       usageInfo.setContainerCount(containerCount);
       return usageInfo.toProto(clientVersion);
   ```



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