From ad8948e8e0e2de8ed6ec824ac09ffbc0840a97ef Mon Sep 17 00:00:00 2001 From: Brandon Li Date: Tue, 8 Oct 2013 00:27:39 +0000 Subject: [PATCH] HDFS-5317. Merging change r1530114 from trunk git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1530117 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 ++ .../server/namenode/NamenodeJspHelper.java | 34 ++++++++----------- .../hdfs/server/datanode/TestDatanodeJsp.java | 7 ++-- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index b96f04b9400..69ca50b009b 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -159,6 +159,9 @@ Release 2.2.0 - 2013-10-13 HDFS-5291. Standby namenode after transition to active goes into safemode. (jing9) + HDFS-5317. Go back to DFS Home link does not work on datanode webUI + (Haohui Mai via brandonli) + Release 2.1.1-beta - 2013-09-23 INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NamenodeJspHelper.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NamenodeJspHelper.java index f044e75daab..884a9025b8a 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NamenodeJspHelper.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NamenodeJspHelper.java @@ -23,6 +23,7 @@ import java.io.IOException; import java.lang.management.ManagementFactory; import java.lang.management.MemoryMXBean; import java.lang.management.MemoryUsage; +import java.net.InetAddress; import java.net.InetSocketAddress; import java.net.URI; import java.net.URLEncoder; @@ -60,6 +61,7 @@ import org.apache.hadoop.hdfs.server.namenode.startupprogress.Status; import org.apache.hadoop.hdfs.server.namenode.startupprogress.Step; import org.apache.hadoop.hdfs.server.namenode.startupprogress.StepType; import org.apache.hadoop.hdfs.server.protocol.NamenodeProtocols; +import org.apache.hadoop.http.HttpConfig; import org.apache.hadoop.io.Text; import org.apache.hadoop.net.NodeBase; import org.apache.hadoop.security.UserGroupInformation; @@ -738,11 +740,11 @@ class NamenodeJspHelper { } private void generateNodeDataHeader(JspWriter out, DatanodeDescriptor d, - String suffix, boolean alive, int nnHttpPort, String nnaddr, String scheme) + String suffix, boolean alive, int nnInfoPort, String nnaddr, String scheme) throws IOException { // from nn_browsedfscontent.jsp: String url = "///" + JspHelper.Url.authority(scheme, d) - + "/browseDirectory.jsp?namenodeInfoPort=" + nnHttpPort + "&dir=" + + "/browseDirectory.jsp?namenodeInfoPort=" + nnInfoPort + "&dir=" + URLEncoder.encode("/", "UTF-8") + JspHelper.getUrlParam(JspHelper.NAMENODE_ADDRESS, nnaddr); @@ -759,9 +761,9 @@ class NamenodeJspHelper { } void generateDecommissioningNodeData(JspWriter out, DatanodeDescriptor d, - String suffix, boolean alive, int nnHttpPort, String nnaddr, String scheme) + String suffix, boolean alive, int nnInfoPort, String nnaddr, String scheme) throws IOException { - generateNodeDataHeader(out, d, suffix, alive, nnHttpPort, nnaddr, scheme); + generateNodeDataHeader(out, d, suffix, alive, nnInfoPort, nnaddr, scheme); if (!alive) { return; } @@ -785,7 +787,7 @@ class NamenodeJspHelper { } void generateNodeData(JspWriter out, DatanodeDescriptor d, String suffix, - boolean alive, int nnHttpPort, String nnaddr, String scheme) throws IOException { + boolean alive, int nnInfoPort, String nnaddr, String scheme) throws IOException { /* * Say the datanode is dn1.hadoop.apache.org with ip 192.168.0.5 we use: * 1) d.getHostName():d.getPort() to display. Domain and port are stripped @@ -797,7 +799,7 @@ class NamenodeJspHelper { * interact with datanodes. */ - generateNodeDataHeader(out, d, suffix, alive, nnHttpPort, nnaddr, scheme); + generateNodeDataHeader(out, d, suffix, alive, nnInfoPort, nnaddr, scheme); if (!alive) { out.print(" " + d.isDecommissioned() + "\n"); @@ -863,11 +865,8 @@ class NamenodeJspHelper { final List dead = new ArrayList(); dm.fetchDatanodes(live, dead, true); - InetSocketAddress nnSocketAddress = - (InetSocketAddress)context.getAttribute( - NameNodeHttpServer.NAMENODE_ADDRESS_ATTRIBUTE_KEY); - String nnaddr = nnSocketAddress.getAddress().getHostAddress() + ":" - + nnSocketAddress.getPort(); + String nnaddr = nn.getServiceRpcAddress().getAddress().getHostName() + ":" + + nn.getServiceRpcAddress().getPort(); whatNodes = request.getParameter("whatNodes"); // show only live or only // dead nodes @@ -903,16 +902,11 @@ class NamenodeJspHelper { counterReset(); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - } - if (live.isEmpty() && dead.isEmpty()) { out.print("There are no datanodes in the cluster"); } else { - int nnHttpPort = nn.getHttpAddress().getPort(); + int nnInfoPort = request.getServerPort(); out.print("
"); if (whatNodes.equals("LIVE")) { out.print("" + "Live Datanodes : " @@ -954,7 +948,7 @@ class NamenodeJspHelper { JspHelper.sortNodeList(live, sorterField, sorterOrder); for (int i = 0; i < live.size(); i++) { - generateNodeData(out, live.get(i), port_suffix, true, nnHttpPort, + generateNodeData(out, live.get(i), port_suffix, true, nnInfoPort, nnaddr, request.getScheme()); } } @@ -975,7 +969,7 @@ class NamenodeJspHelper { JspHelper.sortNodeList(dead, sorterField, sorterOrder); for (int i = 0; i < dead.size(); i++) { generateNodeData(out, dead.get(i), port_suffix, false, - nnHttpPort, nnaddr, request.getScheme()); + nnInfoPort, nnaddr, request.getScheme()); } out.print("\n"); @@ -1006,7 +1000,7 @@ class NamenodeJspHelper { JspHelper.sortNodeList(decommissioning, "name", "ASC"); for (int i = 0; i < decommissioning.size(); i++) { generateDecommissioningNodeData(out, decommissioning.get(i), - port_suffix, true, nnHttpPort, nnaddr, request.getScheme()); + port_suffix, true, nnInfoPort, nnaddr, request.getScheme()); } out.print("\n"); } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDatanodeJsp.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDatanodeJsp.java index b1f3b3ec3c5..147d12e2ff1 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDatanodeJsp.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/datanode/TestDatanodeJsp.java @@ -61,9 +61,10 @@ public class TestDatanodeJsp { InetSocketAddress nnIpcAddress = cluster.getNameNode().getNameNodeAddress(); InetSocketAddress nnHttpAddress = cluster.getNameNode().getHttpAddress(); - int dnInfoPort = cluster.getDataNodes().get(0).getInfoPort(); - - URL url = new URL("http://localhost:" + dnInfoPort + "/" + String base = JspHelper.Url.url("http", cluster.getDataNodes().get(0) + .getDatanodeId()); + + URL url = new URL(base + "/" + "browseDirectory.jsp" + JspHelper.getUrlParam("dir", URLEncoder.encode(testPath.toString(), "UTF-8"), true) + JspHelper.getUrlParam("namenodeInfoPort", Integer