|
@@ -19,7 +19,6 @@ 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.URL;
|
|
import java.net.URL;
|
|
import java.net.URLEncoder;
|
|
import java.net.URLEncoder;
|
|
@@ -37,7 +36,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.DFSUtil;
|
|
|
|
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;
|
|
@@ -45,6 +43,7 @@ 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.http.HttpConfig;
|
|
import org.apache.hadoop.net.NetUtils;
|
|
import org.apache.hadoop.net.NetUtils;
|
|
import org.apache.hadoop.security.UserGroupInformation;
|
|
import org.apache.hadoop.security.UserGroupInformation;
|
|
import org.apache.hadoop.security.token.Token;
|
|
import org.apache.hadoop.security.token.Token;
|
|
@@ -140,7 +139,7 @@ public class DatanodeJspHelper {
|
|
DatanodeInfo chosenNode = JspHelper.bestNode(firstBlock, conf);
|
|
DatanodeInfo chosenNode = JspHelper.bestNode(firstBlock, conf);
|
|
String fqdn = canonicalize(chosenNode.getIpAddr());
|
|
String fqdn = canonicalize(chosenNode.getIpAddr());
|
|
int datanodePort = chosenNode.getXferPort();
|
|
int datanodePort = chosenNode.getXferPort();
|
|
- String redirectLocation = "http://" + fqdn + ":"
|
|
|
|
|
|
+ String redirectLocation = HttpConfig.getSchemePrefix() + fqdn + ":"
|
|
+ chosenNode.getInfoPort() + "/browseBlock.jsp?blockId="
|
|
+ chosenNode.getInfoPort() + "/browseBlock.jsp?blockId="
|
|
+ firstBlock.getBlock().getBlockId() + "&blockSize="
|
|
+ firstBlock.getBlock().getBlockId() + "&blockSize="
|
|
+ firstBlock.getBlock().getNumBytes() + "&genstamp="
|
|
+ firstBlock.getBlock().getNumBytes() + "&genstamp="
|
|
@@ -220,7 +219,7 @@ public class DatanodeJspHelper {
|
|
JspHelper.addTableFooter(out);
|
|
JspHelper.addTableFooter(out);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- out.print("<br><a href=\"http://"
|
|
|
|
|
|
+ out.print("<br><a href=\"" + HttpConfig.getSchemePrefix()
|
|
+ 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();
|
|
@@ -296,7 +295,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 = "http://" + req.getServerName() + ":"
|
|
|
|
|
|
+ String downloadUrl = HttpConfig.getSchemePrefix() + req.getServerName() + ":"
|
|
+ req.getServerPort() + "/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);
|
|
@@ -314,7 +313,7 @@ public class DatanodeJspHelper {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
String fqdn = canonicalize(chosenNode.getIpAddr());
|
|
String fqdn = canonicalize(chosenNode.getIpAddr());
|
|
- String tailUrl = "http://" + fqdn + ":" + chosenNode.getInfoPort()
|
|
|
|
|
|
+ String tailUrl = HttpConfig.getSchemePrefix() + 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
|
|
@@ -363,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 = "http://" + fqdn + ":" + locs[j].getInfoPort()
|
|
|
|
|
|
+ String blockUrl = HttpConfig.getSchemePrefix() + 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")
|
|
@@ -374,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 = "http://" + nnCanonicalName + ":"
|
|
|
|
|
|
+ String blockInfoUrl = HttpConfig.getSchemePrefix() + 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 + "\">"
|
|
@@ -385,7 +384,7 @@ public class DatanodeJspHelper {
|
|
}
|
|
}
|
|
out.println("</table>");
|
|
out.println("</table>");
|
|
out.print("<hr>");
|
|
out.print("<hr>");
|
|
- out.print("<br><a href=\"http://"
|
|
|
|
|
|
+ out.print("<br><a href=\"" + HttpConfig.getSchemePrefix()
|
|
+ nnCanonicalName + ":"
|
|
+ nnCanonicalName + ":"
|
|
+ namenodeInfoPort + "/dfshealth.jsp\">Go back to DFS home</a>");
|
|
+ namenodeInfoPort + "/dfshealth.jsp\">Go back to DFS home</a>");
|
|
dfs.close();
|
|
dfs.close();
|
|
@@ -485,7 +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=\"http://"
|
|
|
|
|
|
+ out.print("<a href=\"" + HttpConfig.getSchemePrefix()
|
|
+ req.getServerName() + ":" + req.getServerPort()
|
|
+ req.getServerName() + ":" + req.getServerPort()
|
|
+ "/browseDirectory.jsp?dir=" + URLEncoder.encode(parent, "UTF-8")
|
|
+ "/browseDirectory.jsp?dir=" + URLEncoder.encode(parent, "UTF-8")
|
|
+ "&namenodeInfoPort=" + namenodeInfoPort
|
|
+ "&namenodeInfoPort=" + namenodeInfoPort
|
|
@@ -533,7 +532,7 @@ public class DatanodeJspHelper {
|
|
}
|
|
}
|
|
String nextUrl = null;
|
|
String nextUrl = null;
|
|
if (nextBlockIdStr != null) {
|
|
if (nextBlockIdStr != null) {
|
|
- nextUrl = "http://" + canonicalize(nextHost) + ":" + nextPort
|
|
|
|
|
|
+ nextUrl = HttpConfig.getSchemePrefix() + canonicalize(nextHost) + ":" + nextPort
|
|
+ "/browseBlock.jsp?blockId=" + nextBlockIdStr
|
|
+ "/browseBlock.jsp?blockId=" + nextBlockIdStr
|
|
+ "&blockSize=" + nextBlockSize
|
|
+ "&blockSize=" + nextBlockSize
|
|
+ "&startOffset=" + nextStartOffset
|
|
+ "&startOffset=" + nextStartOffset
|
|
@@ -588,7 +587,7 @@ public class DatanodeJspHelper {
|
|
|
|
|
|
String prevUrl = null;
|
|
String prevUrl = null;
|
|
if (prevBlockIdStr != null) {
|
|
if (prevBlockIdStr != null) {
|
|
- prevUrl = "http://" + canonicalize(prevHost) + ":" + prevPort
|
|
|
|
|
|
+ prevUrl = HttpConfig.getSchemePrefix() + canonicalize(prevHost) + ":" + prevPort
|
|
+ "/browseBlock.jsp?blockId=" + prevBlockIdStr
|
|
+ "/browseBlock.jsp?blockId=" + prevBlockIdStr
|
|
+ "&blockSize=" + prevBlockSize
|
|
+ "&blockSize=" + prevBlockSize
|
|
+ "&startOffset=" + prevStartOffset
|
|
+ "&startOffset=" + prevStartOffset
|