You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ta...@apache.org on 2021/04/26 09:39:14 UTC
[hadoop] branch trunk updated: HDFS-15991. Add location into
datanode info for NameNodeMXBean (#2933)
This is an automated email from the ASF dual-hosted git repository.
tasanuma pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/trunk by this push:
new b968fa0 HDFS-15991. Add location into datanode info for NameNodeMXBean (#2933)
b968fa0 is described below
commit b968fa0957ddd0f59c9adfd068507722db7207c6
Author: litao <to...@gmail.com>
AuthorDate: Mon Apr 26 17:38:43 2021 +0800
HDFS-15991. Add location into datanode info for NameNodeMXBean (#2933)
Signed-off-by: Takanobu Asanuma <ta...@apache.org>
---
.../src/main/webapps/router/federationhealth.html | 2 +-
.../hadoop/hdfs/server/namenode/FSNamesystem.java | 4 ++++
.../src/main/webapps/hdfs/dfshealth.html | 10 ++++-----
.../hdfs/server/namenode/TestNameNodeMXBean.java | 25 ++++++++++++++++++++--
4 files changed, 33 insertions(+), 8 deletions(-)
diff --git a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/webapps/router/federationhealth.html b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/webapps/router/federationhealth.html
index 01751c2..87d0e71 100644
--- a/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/webapps/router/federationhealth.html
+++ b/hadoop-hdfs-project/hadoop-hdfs-rbf/src/main/webapps/router/federationhealth.html
@@ -406,7 +406,7 @@
</thead>
{#EnteringMaintenanceNodes}
<tr>
- <td>{name} ({xferaddr})</td>
+ <td>{location}/{name} ({xferaddr})</td>
<td>{underReplicatedBlocks}</td>
<td>{maintenanceOnlyReplicas}</td>
<td>{underReplicateInOpenFiles}</td>
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
index 926c4e6..e789f12 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
@@ -6485,6 +6485,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
.put("infoAddr", node.getInfoAddr())
.put("infoSecureAddr", node.getInfoSecureAddr())
.put("xferaddr", node.getXferAddr())
+ .put("location", node.getNetworkLocation())
.put("lastContact", getLastContact(node))
.put("usedSpace", getDfsUsed(node))
.put("adminState", node.getAdminState().toString())
@@ -6534,6 +6535,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
.put("decommissioned", node.isDecommissioned())
.put("adminState", node.getAdminState().toString())
.put("xferaddr", node.getXferAddr())
+ .put("location", node.getNetworkLocation())
.build();
info.put(node.getHostName() + ":" + node.getXferPort(), innerinfo);
}
@@ -6555,6 +6557,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
Map<String, Object> innerinfo = ImmutableMap
.<String, Object> builder()
.put("xferaddr", node.getXferAddr())
+ .put("location", node.getNetworkLocation())
.put("underReplicatedBlocks",
node.getLeavingServiceStatus().getUnderReplicatedBlocks())
.put("decommissionOnlyReplicas",
@@ -6582,6 +6585,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean,
Map<String, Object> attrMap = ImmutableMap
.<String, Object> builder()
.put("xferaddr", node.getXferAddr())
+ .put("location", node.getNetworkLocation())
.put("underReplicatedBlocks",
node.getLeavingServiceStatus().getUnderReplicatedBlocks())
.put("maintenanceOnlyReplicas",
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html
index 8622e4d..c3ba371 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/hdfs/dfshealth.html
@@ -326,7 +326,7 @@
{#LiveNodes}
<tr>
<td ng-value="{state}">{state}</td>
- <td ng-value="{state}-{name}" class="dfshealth-node-icon dfshealth-node-{state}">{name} ({xferaddr})</td>
+ <td ng-value="{state}-{name}" class="dfshealth-node-icon dfshealth-node-{state}">{location}/{name} ({xferaddr})</td>
<td ng-value="{state}-{name}"><a href='{dnWebAddress}'>{dnWebAddress}</a></td>
<td ng-value="{lastContact}">{lastContact}s</td>
<td ng-value="{lastBlockReport}">{lastBlockReport}m</td>
@@ -349,7 +349,7 @@
{#DeadNodes}
<tr class="danger">
<td ng-value="{state}">{state}</td>
- <td ng-value="{state}-{name}" class="dfshealth-node-icon dfshealth-node-{state}">{name} ({xferaddr})</td>
+ <td ng-value="{state}-{name}" class="dfshealth-node-icon dfshealth-node-{state}">{location}/{name} ({xferaddr})</td>
<td></td>
<td>{#helper_relative_time value="{lastContact}"/}</td>
<td></td>
@@ -378,7 +378,7 @@
</thead>
{#EnteringMaintenanceNodes}
<tr>
- <td>{name} ({xferaddr})</td>
+ <td>{location}/{name} ({xferaddr})</td>
<td>{underReplicatedBlocks}</td>
<td>{maintenanceOnlyReplicas}</td>
<td>{underReplicateInOpenFiles}</td>
@@ -404,7 +404,7 @@
</thead>
{#DecomNodes}
<tr>
- <td>{name} ({xferaddr})</td>
+ <td>{location}/{name} ({xferaddr})</td>
<td>{underReplicatedBlocks}</td>
<td>{decommissionOnlyReplicas}</td>
<td>{underReplicateInOpenFiles}</td>
@@ -433,7 +433,7 @@ No nodes are decommissioning.
</thead>
{#LiveNodes}
<tr>
- <td>{name} ({xferaddr})</td>
+ <td>{location}/{name} ({xferaddr})</td>
<td>{#helper_date_tostring value="{lastVolumeFailureDate}"/}</td>
<td>{volfails}</td>
<td>{estimatedCapacityLostTotal|fmt_bytes}</td>
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMXBean.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMXBean.java
index a309e32..81c9cb8 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMXBean.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/TestNameNodeMXBean.java
@@ -112,7 +112,7 @@ public class TestNameNodeMXBean {
MiniDFSCluster cluster = null;
try {
- cluster = new MiniDFSCluster.Builder(conf).numDataNodes(2).build();
+ cluster = new MiniDFSCluster.Builder(conf).numDataNodes(4).build();
cluster.waitActive();
// Set upgrade domain on the first DN.
@@ -171,7 +171,7 @@ public class TestNameNodeMXBean {
"LiveNodes"));
Map<String, Map<String, Object>> liveNodes =
(Map<String, Map<String, Object>>) JSON.parse(alivenodeinfo);
- assertTrue(liveNodes.size() == 2);
+ assertTrue(liveNodes.size() == 4);
for (Map<String, Object> liveNode : liveNodes.values()) {
assertTrue(liveNode.containsKey("nonDfsUsedSpace"));
assertTrue(((Long)liveNode.get("nonDfsUsedSpace")) >= 0);
@@ -195,6 +195,27 @@ public class TestNameNodeMXBean {
assertFalse(xferAddr.equals(dnXferAddrInMaintenance) ^ inMaintenance);
}
assertEquals(fsn.getLiveNodes(), alivenodeinfo);
+
+ // Put the third DN to decommissioning state.
+ DatanodeDescriptor decommissioningNode = dm.getDatanode(
+ cluster.getDataNodes().get(2).getDatanodeId());
+ decommissioningNode.startDecommission();
+
+ // Put the fourth DN to decommissioned state.
+ DatanodeDescriptor decommissionedNode = dm.getDatanode(
+ cluster.getDataNodes().get(3).getDatanodeId());
+ decommissionedNode.setDecommissioned();
+
+ // Assert the location field is included in the mxbeanName
+ // under different states
+ String alivenodeinfo1 = (String) (mbs.getAttribute(mxbeanName,
+ "LiveNodes"));
+ Map<String, Map<String, Object>> liveNodes1 =
+ (Map<String, Map<String, Object>>) JSON.parse(alivenodeinfo1);
+ for (Map<String, Object> liveNode : liveNodes1.values()) {
+ assertTrue(liveNode.containsKey("location"));
+ }
+
// get attributes DeadNodes
String deadNodeInfo = (String) (mbs.getAttribute(mxbeanName,
"DeadNodes"));
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org