devmadhuu commented on code in PR #6369:
URL: https://github.com/apache/ozone/pull/6369#discussion_r1522988947
##########
hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/datanode/DecommissionStatusSubCommand.java:
##########
@@ -139,4 +165,48 @@ private void printCounts(DatanodeDetails datanode,
JsonNode counts, int numDecom
System.err.println("Error getting pipeline and container counts for " +
datanode.getHostName());
}
}
+
+ private Map<String, Object> getDatanodeDetails(DatanodeDetails datanode) {
+ Map<String, Object> detailsMap = new LinkedHashMap<>();
+ detailsMap.put("uuid", datanode.getUuid().toString());
+ detailsMap.put("networkLocation", datanode.getNetworkLocation());
+ detailsMap.put("ipAddress", datanode.getIpAddress());
+ detailsMap.put("hostName", datanode.getHostName());
+ return detailsMap;
+ }
+
+ private Map<String, Object> getCounts(DatanodeDetails datanode, JsonNode
counts, int numDecomNodes) {
+ Map<String, Object> countsMap = new LinkedHashMap<>();
+ try {
+ for (int i = 1; i <= numDecomNodes; i++) {
+ if (datanode.getHostName().equals(counts.get("tag.datanode." +
i).asText())) {
+ long startTime = Long.parseLong(counts.get("StartTimeDN." +
i).toString());
+ Date date = new Date(startTime);
+ DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss z");
+ countsMap.put("decommissionStartTime", formatter.format(date));
+ countsMap.put("numOfUnclosedPipelines",
+ Integer.parseInt(counts.get("PipelinesWaitingToCloseDN." +
i).toString()));
+ countsMap.put("numOfUnderReplicatedContainers",
+ Double.parseDouble(counts.get("UnderReplicatedDN." +
i).toString()));
+ countsMap.put("numOfUnclosedContainers",
+ Double.parseDouble(counts.get("UnclosedContainersDN." +
i).toString()));
+ return countsMap;
+ }
+ }
+ System.err.println("Error getting pipeline and container metrics for " +
datanode.getHostName());
+ } catch (NullPointerException ex) {
Review Comment:
Its not recommended to catch specific RunTimeException. Catch checked
exception and process to output the message accordingly.
--
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]