You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "sarvekshayr (via GitHub)" <gi...@apache.org> on 2024/03/12 11:34:42 UTC
[PR] HDDS-10436. datanode status decommission command should have json output option [ozone]
sarvekshayr opened a new pull request, #6369:
URL: https://github.com/apache/ozone/pull/6369
## What changes were proposed in this pull request?
Added --json option for json formatted output to `ozone admin datanode status decommission` command.
## What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-10436
## How was this patch tested?
Tested the format of the output using a docker cluster.

--
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
Re: [PR] HDDS-10436. datanode status decommission command should have json output option [ozone]
Posted by "Tejaskriya (via GitHub)" <gi...@apache.org>.
Tejaskriya commented on code in PR #6369:
URL: https://github.com/apache/ozone/pull/6369#discussion_r1524716633
##########
hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/datanode/DecommissionStatusSubCommand.java:
##########
@@ -100,6 +110,22 @@ public void execute(ScmClient scmClient) throws IOException {
numDecomNodes = (totalDecom == null ? -1 : Integer.parseInt(totalDecom.toString()));
}
+ if (json) {
+ List<Map<String, Object>> decommissioningNodesDetails = new ArrayList<>();
+
+ for (HddsProtos.Node node : decommissioningNodes) {
+ DatanodeDetails datanode = DatanodeDetails.getFromProtoBuf(
+ node.getNodeID());
+ Map<String, Object> datanodeMap = new LinkedHashMap<>();
+ datanodeMap.put("datanodeDetails", getDatanodeDetails(datanode));
Review Comment:
We don't require this method `getDatanodeDetails()` to create a map. `datanode` can directly be put in the map. Although this will lead to a more verbose output, json option was also meant to be for verbose output. So it is better.
```suggestion
datanodeMap.put("datanodeDetails", datanode);
```
##########
hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/datanode/DecommissionStatusSubCommand.java:
##########
@@ -100,6 +110,22 @@ public void execute(ScmClient scmClient) throws IOException {
numDecomNodes = (totalDecom == null ? -1 : Integer.parseInt(totalDecom.toString()));
}
+ if (json) {
+ List<Map<String, Object>> decommissioningNodesDetails = new ArrayList<>();
+
+ for (HddsProtos.Node node : decommissioningNodes) {
+ DatanodeDetails datanode = DatanodeDetails.getFromProtoBuf(
+ node.getNodeID());
+ Map<String, Object> datanodeMap = new LinkedHashMap<>();
+ datanodeMap.put("datanodeDetails", getDatanodeDetails(datanode));
+ datanodeMap.put("metrics", getCounts(datanode, jsonNode, numDecomNodes));
+ datanodeMap.put("containers", getContainers(scmClient, datanode));
Review Comment:
Similarly, `getContainers()` method is also not required as the `scmClient.getContainersOnDecomNode(datanode)` API already returns a map.
```suggestion
datanodeMap.put("containers", scmClient.getContainersOnDecomNode(datanode));
```
##########
hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/datanode/DecommissionStatusSubCommand.java:
##########
@@ -134,9 +179,62 @@ private void printCounts(DatanodeDetails datanode, JsonNode counts, int numDecom
return;
}
}
- System.err.println("Error getting pipeline and container counts for " + datanode.getHostName());
- } catch (NullPointerException ex) {
- System.err.println("Error getting pipeline and container counts for " + datanode.getHostName());
+ System.err.println(errMsg);
+ } catch (IOException e) {
+ System.err.println(errMsg);
}
}
+
+ 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<>();
+ String errMsg = getErrorMessage() + datanode.getHostName();
+ try {
+ for (int i = 1; i <= numDecomNodes; i++) {
+ if (datanode.getHostName().equals(counts.get("tag.datanode." + i).asText())) {
+ JsonNode pipelinesDN = counts.get("PipelinesWaitingToCloseDN." + i);
+ JsonNode underReplicatedDN = counts.get("UnderReplicatedDN." + i);
+ JsonNode unclosedDN = counts.get("UnclosedContainersDN." + i);
+ JsonNode startTimeDN = counts.get("StartTimeDN." + i);
+ if (pipelinesDN == null || underReplicatedDN == null || unclosedDN == null || startTimeDN == null) {
+ throw new IOException(errMsg);
+ }
+
+ int pipelines = Integer.parseInt(pipelinesDN.toString());
+ double underReplicated = Double.parseDouble(underReplicatedDN.toString());
+ double unclosed = Double.parseDouble(unclosedDN.toString());
+ long startTime = Long.parseLong(startTimeDN.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", pipelines);
+ countsMap.put("numOfUnderReplicatedContainers", underReplicated);
+ countsMap.put("numOfUnclosedContainers", unclosed);
+ return countsMap;
+ }
+ }
+ System.err.println(errMsg);
+ } catch (IOException e) {
+ System.err.println(errMsg);
+ }
+ return countsMap;
+ }
+
+ private Map<String, Object> getContainers(ScmClient scmClient, DatanodeDetails datanode) throws IOException {
Review Comment:
Following previous comments, this method can also be removed.
##########
hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/datanode/DecommissionStatusSubCommand.java:
##########
@@ -134,9 +179,62 @@ private void printCounts(DatanodeDetails datanode, JsonNode counts, int numDecom
return;
}
}
- System.err.println("Error getting pipeline and container counts for " + datanode.getHostName());
- } catch (NullPointerException ex) {
- System.err.println("Error getting pipeline and container counts for " + datanode.getHostName());
+ System.err.println(errMsg);
+ } catch (IOException e) {
+ System.err.println(errMsg);
}
}
+
+ private Map<String, Object> getDatanodeDetails(DatanodeDetails datanode) {
Review Comment:
Following previous comments, this method can be removed.
##########
hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/datanode/DecommissionStatusSubCommand.java:
##########
@@ -134,9 +179,62 @@ private void printCounts(DatanodeDetails datanode, JsonNode counts, int numDecom
return;
}
}
- System.err.println("Error getting pipeline and container counts for " + datanode.getHostName());
- } catch (NullPointerException ex) {
- System.err.println("Error getting pipeline and container counts for " + datanode.getHostName());
+ System.err.println(errMsg);
+ } catch (IOException e) {
+ System.err.println(errMsg);
}
}
+
+ 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) {
Review Comment:
There is quite a bit of code duplication between `printCounts` and `getCounts`. To avoid that, we can use this `getCounts` method in `printCounts` and then display it appropriately. Something like this:
```
private void printCounts(DatanodeDetails datanode, JsonNode counts, int numDecomNodes) {
Map<String, Object> countsMap = getCounts(datanode, counts, numDecomNodes);
System.out.println("Decommission Started At : " + countsMap.get("decommissionStartTime"));
System.out.println("No. of Unclosed Pipelines: " + countsMap.get("numOfUnclosedPipelines"));
System.out.println("No. of UnderReplicated Containers: " + countsMap.get("numOfUnderReplicatedContainers"));
System.out.println("No. of Unclosed Containers: " + countsMap.get("numOfUnclosedContainers"));
}
```
--
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
Re: [PR] HDDS-10436. datanode status decommission command should have json output option [ozone]
Posted by "sarvekshayr (via GitHub)" <gi...@apache.org>.
sarvekshayr commented on code in PR #6369:
URL: https://github.com/apache/ozone/pull/6369#discussion_r1525742493
##########
hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/datanode/DecommissionStatusSubCommand.java:
##########
@@ -134,9 +179,62 @@ private void printCounts(DatanodeDetails datanode, JsonNode counts, int numDecom
return;
}
}
- System.err.println("Error getting pipeline and container counts for " + datanode.getHostName());
- } catch (NullPointerException ex) {
- System.err.println("Error getting pipeline and container counts for " + datanode.getHostName());
+ System.err.println(errMsg);
+ } catch (IOException e) {
+ System.err.println(errMsg);
}
}
+
+ 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<>();
+ String errMsg = getErrorMessage() + datanode.getHostName();
+ try {
+ for (int i = 1; i <= numDecomNodes; i++) {
+ if (datanode.getHostName().equals(counts.get("tag.datanode." + i).asText())) {
+ JsonNode pipelinesDN = counts.get("PipelinesWaitingToCloseDN." + i);
+ JsonNode underReplicatedDN = counts.get("UnderReplicatedDN." + i);
+ JsonNode unclosedDN = counts.get("UnclosedContainersDN." + i);
+ JsonNode startTimeDN = counts.get("StartTimeDN." + i);
+ if (pipelinesDN == null || underReplicatedDN == null || unclosedDN == null || startTimeDN == null) {
+ throw new IOException(errMsg);
+ }
+
+ int pipelines = Integer.parseInt(pipelinesDN.toString());
+ double underReplicated = Double.parseDouble(underReplicatedDN.toString());
+ double unclosed = Double.parseDouble(unclosedDN.toString());
+ long startTime = Long.parseLong(startTimeDN.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", pipelines);
+ countsMap.put("numOfUnderReplicatedContainers", underReplicated);
+ countsMap.put("numOfUnclosedContainers", unclosed);
+ return countsMap;
+ }
+ }
+ System.err.println(errMsg);
+ } catch (IOException e) {
+ System.err.println(errMsg);
+ }
+ return countsMap;
+ }
+
+ private Map<String, Object> getContainers(ScmClient scmClient, DatanodeDetails datanode) throws IOException {
Review Comment:
Ran into an error when I removed this method in the json output code.

--
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
Re: [PR] HDDS-10436. datanode status decommission command should have json output option [ozone]
Posted by "devmadhuu (via GitHub)" <gi...@apache.org>.
devmadhuu commented on code in PR #6369:
URL: https://github.com/apache/ozone/pull/6369#discussion_r1523301375
##########
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());
Review Comment:
```suggestion
detailsMap.put("hostname", datanode.getHostName());
```
This will match with same as we have in `org.apache.hadoop.ozone.recon.api.types.DatanodeMetadata`
--
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
Re: [PR] HDDS-10436. datanode status decommission command should have json output option [ozone]
Posted by "devmadhuu (via GitHub)" <gi...@apache.org>.
devmadhuu commented on code in PR #6369:
URL: https://github.com/apache/ozone/pull/6369#discussion_r1524385043
##########
hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/datanode/DecommissionStatusSubCommand.java:
##########
@@ -134,9 +178,61 @@ private void printCounts(DatanodeDetails datanode, JsonNode counts, int numDecom
return;
}
}
- System.err.println("Error getting pipeline and container counts for " + datanode.getHostName());
- } catch (NullPointerException ex) {
- System.err.println("Error getting pipeline and container counts for " + datanode.getHostName());
+ System.err.println(getErrorMessage() + datanode.getHostName());
+ } catch (IOException e) {
+ System.err.println(getErrorMessage() + 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())) {
+ JsonNode pipelinesDN = counts.get("PipelinesWaitingToCloseDN." + i);
+ JsonNode underReplicatedDN = counts.get("UnderReplicatedDN." + i);
+ JsonNode unclosedDN = counts.get("UnclosedContainersDN." + i);
+ JsonNode startTimeDN = counts.get("StartTimeDN." + i);
+ if (pipelinesDN == null || underReplicatedDN == null || unclosedDN == null || startTimeDN == null) {
+ throw new IOException("Error getting pipeline and container metrics for " + datanode.getHostName());
+ }
+
+ int pipelines = Integer.parseInt(pipelinesDN.toString());
+ double underReplicated = Double.parseDouble(underReplicatedDN.toString());
+ double unclosed = Double.parseDouble(unclosedDN.toString());
+ long startTime = Long.parseLong(startTimeDN.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", pipelines);
+ countsMap.put("numOfUnderReplicatedContainers", underReplicated);
+ countsMap.put("numOfUnclosedContainers", unclosed);
+ return countsMap;
+ }
+ }
+ System.err.println(getErrorMessage() + datanode.getHostName());
Review Comment:
Same here.
##########
hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/datanode/DecommissionStatusSubCommand.java:
##########
@@ -134,9 +178,61 @@ private void printCounts(DatanodeDetails datanode, JsonNode counts, int numDecom
return;
}
}
- System.err.println("Error getting pipeline and container counts for " + datanode.getHostName());
- } catch (NullPointerException ex) {
- System.err.println("Error getting pipeline and container counts for " + datanode.getHostName());
+ System.err.println(getErrorMessage() + datanode.getHostName());
+ } catch (IOException e) {
+ System.err.println(getErrorMessage() + datanode.getHostName());
Review Comment:
Complete message can be formed once for a given datanode and can be used.
String errMsg = getErrorMessage() + datanode.getHostName();
```suggestion
System.err.println(errMsg);
```
##########
hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/datanode/DecommissionStatusSubCommand.java:
##########
@@ -134,9 +178,61 @@ private void printCounts(DatanodeDetails datanode, JsonNode counts, int numDecom
return;
}
}
- System.err.println("Error getting pipeline and container counts for " + datanode.getHostName());
- } catch (NullPointerException ex) {
- System.err.println("Error getting pipeline and container counts for " + datanode.getHostName());
+ System.err.println(getErrorMessage() + datanode.getHostName());
+ } catch (IOException e) {
+ System.err.println(getErrorMessage() + 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())) {
+ JsonNode pipelinesDN = counts.get("PipelinesWaitingToCloseDN." + i);
+ JsonNode underReplicatedDN = counts.get("UnderReplicatedDN." + i);
+ JsonNode unclosedDN = counts.get("UnclosedContainersDN." + i);
+ JsonNode startTimeDN = counts.get("StartTimeDN." + i);
+ if (pipelinesDN == null || underReplicatedDN == null || unclosedDN == null || startTimeDN == null) {
+ throw new IOException("Error getting pipeline and container metrics for " + datanode.getHostName());
+ }
+
+ int pipelines = Integer.parseInt(pipelinesDN.toString());
+ double underReplicated = Double.parseDouble(underReplicatedDN.toString());
+ double unclosed = Double.parseDouble(unclosedDN.toString());
+ long startTime = Long.parseLong(startTimeDN.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", pipelines);
+ countsMap.put("numOfUnderReplicatedContainers", underReplicated);
+ countsMap.put("numOfUnclosedContainers", unclosed);
+ return countsMap;
+ }
+ }
+ System.err.println(getErrorMessage() + datanode.getHostName());
+ } catch (IOException e) {
+ System.err.println(getErrorMessage() + datanode.getHostName());
Review Comment:
Same here.
##########
hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/datanode/DecommissionStatusSubCommand.java:
##########
@@ -134,9 +178,61 @@ private void printCounts(DatanodeDetails datanode, JsonNode counts, int numDecom
return;
}
}
- System.err.println("Error getting pipeline and container counts for " + datanode.getHostName());
- } catch (NullPointerException ex) {
- System.err.println("Error getting pipeline and container counts for " + datanode.getHostName());
+ System.err.println(getErrorMessage() + datanode.getHostName());
Review Comment:
Same here.
##########
hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/datanode/DecommissionStatusSubCommand.java:
##########
@@ -120,10 +156,18 @@ private void printCounts(DatanodeDetails datanode, JsonNode counts, int numDecom
try {
for (int i = 1; i <= numDecomNodes; i++) {
if (datanode.getHostName().equals(counts.get("tag.datanode." + i).asText())) {
- int pipelines = Integer.parseInt(counts.get("PipelinesWaitingToCloseDN." + i).toString());
- double underReplicated = Double.parseDouble(counts.get("UnderReplicatedDN." + i).toString());
- double unclosed = Double.parseDouble(counts.get("UnclosedContainersDN." + i).toString());
- long startTime = Long.parseLong(counts.get("StartTimeDN." + i).toString());
+ JsonNode pipelinesDN = counts.get("PipelinesWaitingToCloseDN." + i);
+ JsonNode underReplicatedDN = counts.get("UnderReplicatedDN." + i);
+ JsonNode unclosedDN = counts.get("UnclosedContainersDN." + i);
+ JsonNode startTimeDN = counts.get("StartTimeDN." + i);
+ if (pipelinesDN == null || underReplicatedDN == null || unclosedDN == null || startTimeDN == null) {
+ throw new IOException("Error getting pipeline and container metrics for " + datanode.getHostName());
Review Comment:
We can use here as well.
##########
hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/datanode/DecommissionStatusSubCommand.java:
##########
@@ -134,9 +178,61 @@ private void printCounts(DatanodeDetails datanode, JsonNode counts, int numDecom
return;
}
}
- System.err.println("Error getting pipeline and container counts for " + datanode.getHostName());
- } catch (NullPointerException ex) {
- System.err.println("Error getting pipeline and container counts for " + datanode.getHostName());
+ System.err.println(getErrorMessage() + datanode.getHostName());
+ } catch (IOException e) {
+ System.err.println(getErrorMessage() + 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())) {
+ JsonNode pipelinesDN = counts.get("PipelinesWaitingToCloseDN." + i);
+ JsonNode underReplicatedDN = counts.get("UnderReplicatedDN." + i);
+ JsonNode unclosedDN = counts.get("UnclosedContainersDN." + i);
+ JsonNode startTimeDN = counts.get("StartTimeDN." + i);
+ if (pipelinesDN == null || underReplicatedDN == null || unclosedDN == null || startTimeDN == null) {
+ throw new IOException("Error getting pipeline and container metrics for " + datanode.getHostName());
Review Comment:
Same here
--
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
Re: [PR] HDDS-10436. datanode status decommission command should have json output option [ozone]
Posted by "devmadhuu (via GitHub)" <gi...@apache.org>.
devmadhuu merged PR #6369:
URL: https://github.com/apache/ozone/pull/6369
--
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
Re: [PR] HDDS-10436. datanode status decommission command should have json output option [ozone]
Posted by "devmadhuu (via GitHub)" <gi...@apache.org>.
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: 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
Re: [PR] HDDS-10436. datanode status decommission command should have json output option [ozone]
Posted by "devmadhuu (via GitHub)" <gi...@apache.org>.
devmadhuu commented on code in PR #6369:
URL: https://github.com/apache/ozone/pull/6369#discussion_r1524305806
##########
hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/datanode/DecommissionStatusSubCommand.java:
##########
@@ -134,9 +168,61 @@ private void printCounts(DatanodeDetails datanode, JsonNode counts, int numDecom
return;
}
}
- System.err.println("Error getting pipeline and container counts for " + datanode.getHostName());
- } catch (NullPointerException ex) {
- System.err.println("Error getting pipeline and container counts for " + datanode.getHostName());
+ System.err.println("Error getting pipeline and container metrics for " + datanode.getHostName());
+ } catch (IOException e) {
+ System.err.println("Error getting pipeline and container metrics for " + datanode.getHostName());
Review Comment:
Same error message repeated multiple times, you can save it in a variable and use.
##########
hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/datanode/DecommissionStatusSubCommand.java:
##########
@@ -134,9 +168,61 @@ private void printCounts(DatanodeDetails datanode, JsonNode counts, int numDecom
return;
}
}
- System.err.println("Error getting pipeline and container counts for " + datanode.getHostName());
- } catch (NullPointerException ex) {
- System.err.println("Error getting pipeline and container counts for " + datanode.getHostName());
+ System.err.println("Error getting pipeline and container metrics for " + datanode.getHostName());
+ } catch (IOException e) {
+ System.err.println("Error getting pipeline and container metrics 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())) {
+ JsonNode pipelinesDN = counts.get("PipelinesWaitingToCloseDN." + i);
+ JsonNode underReplicatedDN = counts.get("UnderReplicatedDN." + i);
+ JsonNode unclosedDN = counts.get("UnclosedContainersDN." + i);
+ JsonNode startTimeDN = counts.get("StartTimeDN." + i);
+ if (pipelinesDN == null || underReplicatedDN == null || unclosedDN == null || startTimeDN == null) {
+ throw new IOException("Error getting pipeline and container metrics for " + datanode.getHostName());
+ }
+
+ int pipelines = Integer.parseInt(pipelinesDN.toString());
+ double underReplicated = Double.parseDouble(underReplicatedDN.toString());
+ double unclosed = Double.parseDouble(unclosedDN.toString());
+ long startTime = Long.parseLong(startTimeDN.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", pipelines);
+ countsMap.put("numOfUnderReplicatedContainers", underReplicated);
+ countsMap.put("numOfUnclosedContainers", unclosed);
+ return countsMap;
+ }
+ }
+ System.err.println("Error getting pipeline and container metrics for " + datanode.getHostName());
+ } catch (IOException e) {
+ System.err.println("Error getting pipeline and container metrics for " + datanode.getHostName());
Review Comment:
Same error message repeated multiple times, you can save it in a variable and use.
--
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
Re: [PR] HDDS-10436. datanode status decommission command should have json output option [ozone]
Posted by "Tejaskriya (via GitHub)" <gi...@apache.org>.
Tejaskriya commented on code in PR #6369:
URL: https://github.com/apache/ozone/pull/6369#discussion_r1525757979
##########
hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/datanode/DecommissionStatusSubCommand.java:
##########
@@ -134,9 +179,62 @@ private void printCounts(DatanodeDetails datanode, JsonNode counts, int numDecom
return;
}
}
- System.err.println("Error getting pipeline and container counts for " + datanode.getHostName());
- } catch (NullPointerException ex) {
- System.err.println("Error getting pipeline and container counts for " + datanode.getHostName());
+ System.err.println(errMsg);
+ } catch (IOException e) {
+ System.err.println(errMsg);
}
}
+
+ 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<>();
+ String errMsg = getErrorMessage() + datanode.getHostName();
+ try {
+ for (int i = 1; i <= numDecomNodes; i++) {
+ if (datanode.getHostName().equals(counts.get("tag.datanode." + i).asText())) {
+ JsonNode pipelinesDN = counts.get("PipelinesWaitingToCloseDN." + i);
+ JsonNode underReplicatedDN = counts.get("UnderReplicatedDN." + i);
+ JsonNode unclosedDN = counts.get("UnclosedContainersDN." + i);
+ JsonNode startTimeDN = counts.get("StartTimeDN." + i);
+ if (pipelinesDN == null || underReplicatedDN == null || unclosedDN == null || startTimeDN == null) {
+ throw new IOException(errMsg);
+ }
+
+ int pipelines = Integer.parseInt(pipelinesDN.toString());
+ double underReplicated = Double.parseDouble(underReplicatedDN.toString());
+ double unclosed = Double.parseDouble(unclosedDN.toString());
+ long startTime = Long.parseLong(startTimeDN.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", pipelines);
+ countsMap.put("numOfUnderReplicatedContainers", underReplicated);
+ countsMap.put("numOfUnclosedContainers", unclosed);
+ return countsMap;
+ }
+ }
+ System.err.println(errMsg);
+ } catch (IOException e) {
+ System.err.println(errMsg);
+ }
+ return countsMap;
+ }
+
+ private Map<String, Object> getContainers(ScmClient scmClient, DatanodeDetails datanode) throws IOException {
Review Comment:
Okay, we can keep the current implementation instead of defining a serializer to resolve this error.
--
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
Re: [PR] HDDS-10436. datanode status decommission command should have json output option [ozone]
Posted by "sarvekshayr (via GitHub)" <gi...@apache.org>.
sarvekshayr commented on code in PR #6369:
URL: https://github.com/apache/ozone/pull/6369#discussion_r1525742493
##########
hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/datanode/DecommissionStatusSubCommand.java:
##########
@@ -134,9 +179,62 @@ private void printCounts(DatanodeDetails datanode, JsonNode counts, int numDecom
return;
}
}
- System.err.println("Error getting pipeline and container counts for " + datanode.getHostName());
- } catch (NullPointerException ex) {
- System.err.println("Error getting pipeline and container counts for " + datanode.getHostName());
+ System.err.println(errMsg);
+ } catch (IOException e) {
+ System.err.println(errMsg);
}
}
+
+ 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<>();
+ String errMsg = getErrorMessage() + datanode.getHostName();
+ try {
+ for (int i = 1; i <= numDecomNodes; i++) {
+ if (datanode.getHostName().equals(counts.get("tag.datanode." + i).asText())) {
+ JsonNode pipelinesDN = counts.get("PipelinesWaitingToCloseDN." + i);
+ JsonNode underReplicatedDN = counts.get("UnderReplicatedDN." + i);
+ JsonNode unclosedDN = counts.get("UnclosedContainersDN." + i);
+ JsonNode startTimeDN = counts.get("StartTimeDN." + i);
+ if (pipelinesDN == null || underReplicatedDN == null || unclosedDN == null || startTimeDN == null) {
+ throw new IOException(errMsg);
+ }
+
+ int pipelines = Integer.parseInt(pipelinesDN.toString());
+ double underReplicated = Double.parseDouble(underReplicatedDN.toString());
+ double unclosed = Double.parseDouble(unclosedDN.toString());
+ long startTime = Long.parseLong(startTimeDN.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", pipelines);
+ countsMap.put("numOfUnderReplicatedContainers", underReplicated);
+ countsMap.put("numOfUnclosedContainers", unclosed);
+ return countsMap;
+ }
+ }
+ System.err.println(errMsg);
+ } catch (IOException e) {
+ System.err.println(errMsg);
+ }
+ return countsMap;
+ }
+
+ private Map<String, Object> getContainers(ScmClient scmClient, DatanodeDetails datanode) throws IOException {
Review Comment:
Ran into an error when I removed this method in the json output code. Therefore I will retain it.

--
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
Re: [PR] HDDS-10436. datanode status decommission command should have json output option [ozone]
Posted by "sarvekshayr (via GitHub)" <gi...@apache.org>.
sarvekshayr commented on code in PR #6369:
URL: https://github.com/apache/ozone/pull/6369#discussion_r1525742493
##########
hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/datanode/DecommissionStatusSubCommand.java:
##########
@@ -134,9 +179,62 @@ private void printCounts(DatanodeDetails datanode, JsonNode counts, int numDecom
return;
}
}
- System.err.println("Error getting pipeline and container counts for " + datanode.getHostName());
- } catch (NullPointerException ex) {
- System.err.println("Error getting pipeline and container counts for " + datanode.getHostName());
+ System.err.println(errMsg);
+ } catch (IOException e) {
+ System.err.println(errMsg);
}
}
+
+ 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<>();
+ String errMsg = getErrorMessage() + datanode.getHostName();
+ try {
+ for (int i = 1; i <= numDecomNodes; i++) {
+ if (datanode.getHostName().equals(counts.get("tag.datanode." + i).asText())) {
+ JsonNode pipelinesDN = counts.get("PipelinesWaitingToCloseDN." + i);
+ JsonNode underReplicatedDN = counts.get("UnderReplicatedDN." + i);
+ JsonNode unclosedDN = counts.get("UnclosedContainersDN." + i);
+ JsonNode startTimeDN = counts.get("StartTimeDN." + i);
+ if (pipelinesDN == null || underReplicatedDN == null || unclosedDN == null || startTimeDN == null) {
+ throw new IOException(errMsg);
+ }
+
+ int pipelines = Integer.parseInt(pipelinesDN.toString());
+ double underReplicated = Double.parseDouble(underReplicatedDN.toString());
+ double unclosed = Double.parseDouble(unclosedDN.toString());
+ long startTime = Long.parseLong(startTimeDN.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", pipelines);
+ countsMap.put("numOfUnderReplicatedContainers", underReplicated);
+ countsMap.put("numOfUnclosedContainers", unclosed);
+ return countsMap;
+ }
+ }
+ System.err.println(errMsg);
+ } catch (IOException e) {
+ System.err.println(errMsg);
+ }
+ return countsMap;
+ }
+
+ private Map<String, Object> getContainers(ScmClient scmClient, DatanodeDetails datanode) throws IOException {
Review Comment:
Ran into an error when I removed this method in the json output code. Therefore I will retain this method.

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