HDFS-5308. Replace HttpConfig#getSchemePrefix with implicit schemes in HDFS JSP. Contributed by Haohui Mai.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1529512 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
be3edccf0a
commit
cae1ed9f6c
|
@ -362,6 +362,9 @@ Release 2.1.2 - UNRELEASED
|
||||||
HDFS-5256. Use guava LoadingCache to implement DFSClientCache. (Haohui Mai
|
HDFS-5256. Use guava LoadingCache to implement DFSClientCache. (Haohui Mai
|
||||||
via brandonli)
|
via brandonli)
|
||||||
|
|
||||||
|
HDFS-5308. Replace HttpConfig#getSchemePrefix with implicit schemes in HDFS
|
||||||
|
JSP. (Haohui Mai via jing9)
|
||||||
|
|
||||||
OPTIMIZATIONS
|
OPTIMIZATIONS
|
||||||
|
|
||||||
BUG FIXES
|
BUG FIXES
|
||||||
|
|
|
@ -19,9 +19,7 @@ package org.apache.hadoop.hdfs.server.datanode;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.InetAddress;
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.net.URI;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.security.PrivilegedExceptionAction;
|
import java.security.PrivilegedExceptionAction;
|
||||||
|
@ -39,7 +37,6 @@ import org.apache.hadoop.classification.InterfaceAudience;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.hdfs.DFSClient;
|
import org.apache.hadoop.hdfs.DFSClient;
|
||||||
import org.apache.hadoop.hdfs.DFSConfigKeys;
|
import org.apache.hadoop.hdfs.DFSConfigKeys;
|
||||||
import org.apache.hadoop.hdfs.protocol.DatanodeID;
|
|
||||||
import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
|
import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
|
||||||
import org.apache.hadoop.hdfs.protocol.DirectoryListing;
|
import org.apache.hadoop.hdfs.protocol.DirectoryListing;
|
||||||
import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
|
import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
|
||||||
|
@ -47,9 +44,6 @@ import org.apache.hadoop.hdfs.protocol.LocatedBlock;
|
||||||
import org.apache.hadoop.hdfs.security.token.block.BlockTokenIdentifier;
|
import org.apache.hadoop.hdfs.security.token.block.BlockTokenIdentifier;
|
||||||
import org.apache.hadoop.hdfs.security.token.block.BlockTokenSecretManager;
|
import org.apache.hadoop.hdfs.security.token.block.BlockTokenSecretManager;
|
||||||
import org.apache.hadoop.hdfs.server.common.JspHelper;
|
import org.apache.hadoop.hdfs.server.common.JspHelper;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.FSNamesystem;
|
|
||||||
import org.apache.hadoop.hdfs.server.namenode.NameNode;
|
|
||||||
import org.apache.hadoop.hdfs.server.namenode.NameNodeHttpServer;
|
|
||||||
import org.apache.hadoop.http.HtmlQuoting;
|
import org.apache.hadoop.http.HtmlQuoting;
|
||||||
import org.apache.hadoop.http.HttpConfig;
|
import org.apache.hadoop.http.HttpConfig;
|
||||||
import org.apache.hadoop.net.NetUtils;
|
import org.apache.hadoop.net.NetUtils;
|
||||||
|
@ -225,7 +219,7 @@ public class DatanodeJspHelper {
|
||||||
JspHelper.addTableFooter(out);
|
JspHelper.addTableFooter(out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
out.print("<br><a href=\"" + HttpConfig.getSchemePrefix()
|
out.print("<br><a href=\"///"
|
||||||
+ canonicalize(nnAddr) + ":"
|
+ canonicalize(nnAddr) + ":"
|
||||||
+ namenodeInfoPort + "/dfshealth.jsp\">Go back to DFS home</a>");
|
+ namenodeInfoPort + "/dfshealth.jsp\">Go back to DFS home</a>");
|
||||||
dfs.close();
|
dfs.close();
|
||||||
|
@ -302,8 +296,7 @@ public class DatanodeJspHelper {
|
||||||
Long.MAX_VALUE).getLocatedBlocks();
|
Long.MAX_VALUE).getLocatedBlocks();
|
||||||
// Add the various links for looking at the file contents
|
// Add the various links for looking at the file contents
|
||||||
// URL for downloading the full file
|
// URL for downloading the full file
|
||||||
String downloadUrl = HttpConfig.getSchemePrefix() + req.getServerName() + ":"
|
String downloadUrl = "/streamFile" + ServletUtil.encodePath(filename)
|
||||||
+ req.getServerPort() + "/streamFile" + ServletUtil.encodePath(filename)
|
|
||||||
+ JspHelper.getUrlParam(JspHelper.NAMENODE_ADDRESS, nnAddr, true)
|
+ JspHelper.getUrlParam(JspHelper.NAMENODE_ADDRESS, nnAddr, true)
|
||||||
+ JspHelper.getDelegationTokenUrlParam(tokenString);
|
+ JspHelper.getDelegationTokenUrlParam(tokenString);
|
||||||
out.print("<a name=\"viewOptions\"></a>");
|
out.print("<a name=\"viewOptions\"></a>");
|
||||||
|
@ -320,7 +313,7 @@ public class DatanodeJspHelper {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String fqdn = canonicalize(chosenNode.getIpAddr());
|
String fqdn = canonicalize(chosenNode.getIpAddr());
|
||||||
String tailUrl = HttpConfig.getSchemePrefix() + fqdn + ":" + chosenNode.getInfoPort()
|
String tailUrl = "///" + fqdn + ":" + chosenNode.getInfoPort()
|
||||||
+ "/tail.jsp?filename=" + URLEncoder.encode(filename, "UTF-8")
|
+ "/tail.jsp?filename=" + URLEncoder.encode(filename, "UTF-8")
|
||||||
+ "&namenodeInfoPort=" + namenodeInfoPort
|
+ "&namenodeInfoPort=" + namenodeInfoPort
|
||||||
+ "&chunkSizeToView=" + chunkSizeToView
|
+ "&chunkSizeToView=" + chunkSizeToView
|
||||||
|
@ -369,7 +362,7 @@ public class DatanodeJspHelper {
|
||||||
String datanodeAddr = locs[j].getXferAddr();
|
String datanodeAddr = locs[j].getXferAddr();
|
||||||
datanodePort = locs[j].getXferPort();
|
datanodePort = locs[j].getXferPort();
|
||||||
fqdn = canonicalize(locs[j].getIpAddr());
|
fqdn = canonicalize(locs[j].getIpAddr());
|
||||||
String blockUrl = HttpConfig.getSchemePrefix() + fqdn + ":" + locs[j].getInfoPort()
|
String blockUrl = "///" + fqdn + ":" + locs[j].getInfoPort()
|
||||||
+ "/browseBlock.jsp?blockId=" + blockidstring
|
+ "/browseBlock.jsp?blockId=" + blockidstring
|
||||||
+ "&blockSize=" + blockSize
|
+ "&blockSize=" + blockSize
|
||||||
+ "&filename=" + URLEncoder.encode(filename, "UTF-8")
|
+ "&filename=" + URLEncoder.encode(filename, "UTF-8")
|
||||||
|
@ -380,7 +373,7 @@ public class DatanodeJspHelper {
|
||||||
+ JspHelper.getDelegationTokenUrlParam(tokenString)
|
+ JspHelper.getDelegationTokenUrlParam(tokenString)
|
||||||
+ JspHelper.getUrlParam(JspHelper.NAMENODE_ADDRESS, nnAddr);
|
+ JspHelper.getUrlParam(JspHelper.NAMENODE_ADDRESS, nnAddr);
|
||||||
|
|
||||||
String blockInfoUrl = HttpConfig.getSchemePrefix() + nnCanonicalName + ":"
|
String blockInfoUrl = "///" + nnCanonicalName + ":"
|
||||||
+ namenodeInfoPort
|
+ namenodeInfoPort
|
||||||
+ "/block_info_xml.jsp?blockId=" + blockidstring;
|
+ "/block_info_xml.jsp?blockId=" + blockidstring;
|
||||||
out.print("<td> </td><td><a href=\"" + blockUrl + "\">"
|
out.print("<td> </td><td><a href=\"" + blockUrl + "\">"
|
||||||
|
@ -391,7 +384,7 @@ public class DatanodeJspHelper {
|
||||||
}
|
}
|
||||||
out.println("</table>");
|
out.println("</table>");
|
||||||
out.print("<hr>");
|
out.print("<hr>");
|
||||||
out.print("<br><a href=\"" + HttpConfig.getSchemePrefix()
|
out.print("<br><a href=\"///"
|
||||||
+ nnCanonicalName + ":"
|
+ nnCanonicalName + ":"
|
||||||
+ namenodeInfoPort + "/dfshealth.jsp\">Go back to DFS home</a>");
|
+ namenodeInfoPort + "/dfshealth.jsp\">Go back to DFS home</a>");
|
||||||
dfs.close();
|
dfs.close();
|
||||||
|
@ -491,9 +484,7 @@ public class DatanodeJspHelper {
|
||||||
String parent = new File(filename).getParent();
|
String parent = new File(filename).getParent();
|
||||||
JspHelper.printGotoForm(out, namenodeInfoPort, tokenString, parent, nnAddr);
|
JspHelper.printGotoForm(out, namenodeInfoPort, tokenString, parent, nnAddr);
|
||||||
out.print("<hr>");
|
out.print("<hr>");
|
||||||
out.print("<a href=\"" + HttpConfig.getSchemePrefix()
|
out.print("<a href=\"/browseDirectory.jsp?dir=" + URLEncoder.encode(parent, "UTF-8")
|
||||||
+ req.getServerName() + ":" + req.getServerPort()
|
|
||||||
+ "/browseDirectory.jsp?dir=" + URLEncoder.encode(parent, "UTF-8")
|
|
||||||
+ "&namenodeInfoPort=" + namenodeInfoPort
|
+ "&namenodeInfoPort=" + namenodeInfoPort
|
||||||
+ JspHelper.getDelegationTokenUrlParam(tokenString)
|
+ JspHelper.getDelegationTokenUrlParam(tokenString)
|
||||||
+ JspHelper.getUrlParam(JspHelper.NAMENODE_ADDRESS, nnAddr)
|
+ JspHelper.getUrlParam(JspHelper.NAMENODE_ADDRESS, nnAddr)
|
||||||
|
@ -539,7 +530,7 @@ public class DatanodeJspHelper {
|
||||||
}
|
}
|
||||||
String nextUrl = null;
|
String nextUrl = null;
|
||||||
if (nextBlockIdStr != null) {
|
if (nextBlockIdStr != null) {
|
||||||
nextUrl = HttpConfig.getSchemePrefix() + canonicalize(nextHost) + ":" + nextPort
|
nextUrl = "///" + canonicalize(nextHost) + ":" + nextPort
|
||||||
+ "/browseBlock.jsp?blockId=" + nextBlockIdStr
|
+ "/browseBlock.jsp?blockId=" + nextBlockIdStr
|
||||||
+ "&blockSize=" + nextBlockSize
|
+ "&blockSize=" + nextBlockSize
|
||||||
+ "&startOffset=" + nextStartOffset
|
+ "&startOffset=" + nextStartOffset
|
||||||
|
@ -594,7 +585,7 @@ public class DatanodeJspHelper {
|
||||||
|
|
||||||
String prevUrl = null;
|
String prevUrl = null;
|
||||||
if (prevBlockIdStr != null) {
|
if (prevBlockIdStr != null) {
|
||||||
prevUrl = HttpConfig.getSchemePrefix() + canonicalize(prevHost) + ":" + prevPort
|
prevUrl = "///" + canonicalize(prevHost) + ":" + prevPort
|
||||||
+ "/browseBlock.jsp?blockId=" + prevBlockIdStr
|
+ "/browseBlock.jsp?blockId=" + prevBlockIdStr
|
||||||
+ "&blockSize=" + prevBlockSize
|
+ "&blockSize=" + prevBlockSize
|
||||||
+ "&startOffset=" + prevStartOffset
|
+ "&startOffset=" + prevStartOffset
|
||||||
|
|
|
@ -827,7 +827,7 @@ class ClusterJspHelper {
|
||||||
doc.startTag("item");
|
doc.startTag("item");
|
||||||
doc.attribute("label", label);
|
doc.attribute("label", label);
|
||||||
doc.attribute("value", value);
|
doc.attribute("value", value);
|
||||||
doc.attribute("link", HttpConfig.getSchemePrefix() + url);
|
doc.attribute("link", "///" + url);
|
||||||
doc.endTag(); // item
|
doc.endTag(); // item
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -747,7 +747,7 @@ class NamenodeJspHelper {
|
||||||
String suffix, boolean alive, int nnHttpPort, String nnaddr)
|
String suffix, boolean alive, int nnHttpPort, String nnaddr)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
// from nn_browsedfscontent.jsp:
|
// from nn_browsedfscontent.jsp:
|
||||||
String url = HttpConfig.getSchemePrefix() + d.getHostName() + ":"
|
String url = "///" + d.getHostName() + ":"
|
||||||
+ d.getInfoPort()
|
+ d.getInfoPort()
|
||||||
+ "/browseDirectory.jsp?namenodeInfoPort=" + nnHttpPort + "&dir="
|
+ "/browseDirectory.jsp?namenodeInfoPort=" + nnHttpPort + "&dir="
|
||||||
+ URLEncoder.encode("/", "UTF-8")
|
+ URLEncoder.encode("/", "UTF-8")
|
||||||
|
|
|
@ -92,12 +92,12 @@ public class TestDatanodeJsp {
|
||||||
throws IOException {
|
throws IOException {
|
||||||
Pattern compile = Pattern.compile(regex);
|
Pattern compile = Pattern.compile(regex);
|
||||||
Matcher matcher = compile.matcher(viewFilePage);
|
Matcher matcher = compile.matcher(viewFilePage);
|
||||||
URL hyperlink = null;
|
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
// got hyperlink for Tail this file
|
// got hyperlink for Tail this file
|
||||||
hyperlink = new URL(matcher.group(1));
|
String u = matcher.group(1);
|
||||||
|
String urlString = u.startsWith("///") ? ("http://" + u.substring(3)) : u;
|
||||||
viewFilePage = StringEscapeUtils.unescapeHtml(DFSTestUtil
|
viewFilePage = StringEscapeUtils.unescapeHtml(DFSTestUtil
|
||||||
.urlGet(hyperlink));
|
.urlGet(new URL(urlString)));
|
||||||
assertTrue("page should show preview of file contents", viewFilePage
|
assertTrue("page should show preview of file contents", viewFilePage
|
||||||
.contains(FILE_DATA));
|
.contains(FILE_DATA));
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue