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 01751c21b1376..87d0e718bdcd3 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 @@
{#EnteringMaintenanceNodes}
- | {name} ({xferaddr}) |
+ {location}/{name} ({xferaddr}) |
{underReplicatedBlocks} |
{maintenanceOnlyReplicas} |
{underReplicateInOpenFiles} |
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 e559515696d66..ee09238357add 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
@@ -6492,6 +6492,7 @@ public String getLiveNodes() {
.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())
@@ -6541,6 +6542,7 @@ public String getDeadNodes() {
.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);
}
@@ -6562,6 +6564,7 @@ public String getDecomNodes() {
Map innerinfo = ImmutableMap
. builder()
.put("xferaddr", node.getXferAddr())
+ .put("location", node.getNetworkLocation())
.put("underReplicatedBlocks",
node.getLeavingServiceStatus().getUnderReplicatedBlocks())
.put("decommissionOnlyReplicas",
@@ -6589,6 +6592,7 @@ public String getEnteringMaintenanceNodes() {
Map attrMap = ImmutableMap
. 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 8622e4d3a5681..c3ba37165c998 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}
| {state} |
- {name} ({xferaddr}) |
+ {location}/{name} ({xferaddr}) |
{dnWebAddress} |
{lastContact}s |
{lastBlockReport}m |
@@ -349,7 +349,7 @@
{#DeadNodes}
| {state} |
- {name} ({xferaddr}) |
+ {location}/{name} ({xferaddr}) |
|
{#helper_relative_time value="{lastContact}"/} |
|
@@ -378,7 +378,7 @@
{#EnteringMaintenanceNodes}
- | {name} ({xferaddr}) |
+ {location}/{name} ({xferaddr}) |
{underReplicatedBlocks} |
{maintenanceOnlyReplicas} |
{underReplicateInOpenFiles} |
@@ -404,7 +404,7 @@
{#DecomNodes}
- | {name} ({xferaddr}) |
+ {location}/{name} ({xferaddr}) |
{underReplicatedBlocks} |
{decommissionOnlyReplicas} |
{underReplicateInOpenFiles} |
@@ -433,7 +433,7 @@
{#LiveNodes}
- | {name} ({xferaddr}) |
+ {location}/{name} ({xferaddr}) |
{#helper_date_tostring value="{lastVolumeFailureDate}"/} |
{volfails} |
{estimatedCapacityLostTotal|fmt_bytes} |
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 a309e324f5485..81c9cb8670066 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 void testNameNodeMXBeanInfo() throws Exception {
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 void testNameNodeMXBeanInfo() throws Exception {
"LiveNodes"));
Map> liveNodes =
(Map>) JSON.parse(alivenodeinfo);
- assertTrue(liveNodes.size() == 2);
+ assertTrue(liveNodes.size() == 4);
for (Map liveNode : liveNodes.values()) {
assertTrue(liveNode.containsKey("nonDfsUsedSpace"));
assertTrue(((Long)liveNode.get("nonDfsUsedSpace")) >= 0);
@@ -195,6 +195,27 @@ public void testNameNodeMXBeanInfo() throws Exception {
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> liveNodes1 =
+ (Map>) JSON.parse(alivenodeinfo1);
+ for (Map liveNode : liveNodes1.values()) {
+ assertTrue(liveNode.containsKey("location"));
+ }
+
// get attributes DeadNodes
String deadNodeInfo = (String) (mbs.getAttribute(mxbeanName,
"DeadNodes"));