From 57a76f71bd4015ba913c20763afddc0087037471 Mon Sep 17 00:00:00 2001 From: Haohui Mai Date: Mon, 24 Nov 2014 17:46:35 -0800 Subject: [PATCH] HDFS-7303. NN UI fails to distinguish datanodes on the same host. Contributed by Benoy Antony. --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 5 ++++- .../apache/hadoop/hdfs/server/namenode/FSNamesystem.java | 7 +++---- .../hadoop/hdfs/server/namenode/TestNameNodeMXBean.java | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 7e84948d77c..fed184666bc 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -223,9 +223,12 @@ Release 2.7.0 - UNRELEASED HDFS-7374. Allow decommissioning of dead DataNodes. (Zhe Zhang) - HDFS-7403. Inaccurate javadoc of BlockUCState#COMPLETE state. ( + HDFS-7403. Inaccurate javadoc of BlockUCState#COMPLETE state. ( Yongjun Zhang via yliu) + HDFS-7303. NN UI fails to distinguish datanodes on the same host. + (Benoy Antony via wheat9) + Release 2.6.1 - UNRELEASED INCOMPATIBLE CHANGES 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 db1a93816a3..336acd517fe 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 @@ -7248,8 +7248,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean, .put("blockPoolUsedPercent", node.getBlockPoolUsedPercent()) .put("volfails", node.getVolumeFailures()) .build(); - - info.put(node.getHostName(), innerinfo); + info.put(node.getHostName() + ":" + node.getXferPort(), innerinfo); } return JSON.toString(info); } @@ -7270,7 +7269,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean, .put("decommissioned", node.isDecommissioned()) .put("xferaddr", node.getXferAddr()) .build(); - info.put(node.getHostName(), innerinfo); + info.put(node.getHostName() + ":" + node.getXferPort(), innerinfo); } return JSON.toString(info); } @@ -7297,7 +7296,7 @@ public class FSNamesystem implements Namesystem, FSNamesystemMBean, .put("underReplicateInOpenFiles", node.decommissioningStatus.getUnderReplicatedInOpenFiles()) .build(); - info.put(node.getHostName(), innerinfo); + info.put(node.getHostName() + ":" + node.getXferPort(), innerinfo); } return JSON.toString(info); } 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 fa9dca14c99..03ade90b415 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 @@ -67,7 +67,7 @@ public class TestNameNodeMXBean { MiniDFSCluster cluster = null; try { - cluster = new MiniDFSCluster.Builder(conf).build(); + cluster = new MiniDFSCluster.Builder(conf).numDataNodes(2).build(); cluster.waitActive(); FSNamesystem fsn = cluster.getNameNode().namesystem; @@ -111,7 +111,7 @@ public class TestNameNodeMXBean { "LiveNodes")); Map> liveNodes = (Map>) JSON.parse(alivenodeinfo); - assertTrue(liveNodes.size() > 0); + assertTrue(liveNodes.size() == 2); for (Map liveNode : liveNodes.values()) { assertTrue(liveNode.containsKey("nonDfsUsedSpace")); assertTrue(((Long)liveNode.get("nonDfsUsedSpace")) > 0);