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