[120] | 1 | package org.apache.hadoop.hdfs.server.namenode; |
---|
| 2 | |
---|
| 3 | import javax.servlet.*; |
---|
| 4 | import javax.servlet.http.*; |
---|
| 5 | import javax.servlet.jsp.*; |
---|
| 6 | import javax.servlet.*; |
---|
| 7 | import javax.servlet.http.*; |
---|
| 8 | import java.io.*; |
---|
| 9 | import java.util.*; |
---|
| 10 | import org.apache.hadoop.hdfs.*; |
---|
| 11 | import org.apache.hadoop.hdfs.server.namenode.*; |
---|
| 12 | import org.apache.hadoop.hdfs.server.datanode.*; |
---|
| 13 | import org.apache.hadoop.hdfs.protocol.*; |
---|
| 14 | import org.apache.hadoop.util.*; |
---|
| 15 | import java.text.DateFormat; |
---|
| 16 | import java.net.InetAddress; |
---|
| 17 | import java.net.URLEncoder; |
---|
| 18 | |
---|
| 19 | public final class nn_005fbrowsedfscontent_jsp extends org.apache.jasper.runtime.HttpJspBase |
---|
| 20 | implements org.apache.jasper.runtime.JspSourceDependent { |
---|
| 21 | |
---|
| 22 | |
---|
| 23 | public void redirectToRandomDataNode( |
---|
| 24 | NameNode nn, |
---|
| 25 | HttpServletResponse resp) throws IOException { |
---|
| 26 | FSNamesystem fsn = nn.getNamesystem(); |
---|
| 27 | String datanode = fsn.randomDataNode(); |
---|
| 28 | String redirectLocation; |
---|
| 29 | String nodeToRedirect; |
---|
| 30 | int redirectPort; |
---|
| 31 | if (datanode != null) { |
---|
| 32 | redirectPort = Integer.parseInt(datanode.substring(datanode.indexOf(':') + 1)); |
---|
| 33 | nodeToRedirect = datanode.substring(0, datanode.indexOf(':')); |
---|
| 34 | } |
---|
| 35 | else { |
---|
| 36 | nodeToRedirect = nn.getHttpAddress().getHostName(); |
---|
| 37 | redirectPort = nn.getHttpAddress().getPort(); |
---|
| 38 | } |
---|
| 39 | String fqdn = InetAddress.getByName(nodeToRedirect).getCanonicalHostName(); |
---|
| 40 | redirectLocation = "http://" + fqdn + ":" + redirectPort + |
---|
| 41 | "/browseDirectory.jsp?namenodeInfoPort=" + |
---|
| 42 | nn.getHttpAddress().getPort() + |
---|
| 43 | "&dir=" + URLEncoder.encode("/", "UTF-8"); |
---|
| 44 | resp.sendRedirect(redirectLocation); |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | private static java.util.List _jspx_dependants; |
---|
| 48 | |
---|
| 49 | public Object getDependants() { |
---|
| 50 | return _jspx_dependants; |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | public void _jspService(HttpServletRequest request, HttpServletResponse response) |
---|
| 54 | throws java.io.IOException, ServletException { |
---|
| 55 | |
---|
| 56 | JspFactory _jspxFactory = null; |
---|
| 57 | PageContext pageContext = null; |
---|
| 58 | HttpSession session = null; |
---|
| 59 | ServletContext application = null; |
---|
| 60 | ServletConfig config = null; |
---|
| 61 | JspWriter out = null; |
---|
| 62 | Object page = this; |
---|
| 63 | JspWriter _jspx_out = null; |
---|
| 64 | PageContext _jspx_page_context = null; |
---|
| 65 | |
---|
| 66 | |
---|
| 67 | try { |
---|
| 68 | _jspxFactory = JspFactory.getDefaultFactory(); |
---|
| 69 | response.setContentType("text/html; charset=UTF-8"); |
---|
| 70 | pageContext = _jspxFactory.getPageContext(this, request, response, |
---|
| 71 | null, true, 8192, true); |
---|
| 72 | _jspx_page_context = pageContext; |
---|
| 73 | application = pageContext.getServletContext(); |
---|
| 74 | config = pageContext.getServletConfig(); |
---|
| 75 | session = pageContext.getSession(); |
---|
| 76 | out = pageContext.getOut(); |
---|
| 77 | _jspx_out = out; |
---|
| 78 | |
---|
| 79 | out.write('\n'); |
---|
| 80 | out.write("\n\n<html>\n\n<title></title>\n\n<body>\n"); |
---|
| 81 | |
---|
| 82 | NameNode nn = (NameNode)application.getAttribute("name.node"); |
---|
| 83 | redirectToRandomDataNode(nn, response); |
---|
| 84 | |
---|
| 85 | out.write("\n<hr>\n\n<h2>Local logs</h2>\n<a href=\"/logs/\">Log</a> directory\n\n"); |
---|
| 86 | |
---|
| 87 | out.println(ServletUtil.htmlFooter()); |
---|
| 88 | |
---|
| 89 | out.write('\n'); |
---|
| 90 | } catch (Throwable t) { |
---|
| 91 | if (!(t instanceof SkipPageException)){ |
---|
| 92 | out = _jspx_out; |
---|
| 93 | if (out != null && out.getBufferSize() != 0) |
---|
| 94 | out.clearBuffer(); |
---|
| 95 | if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); |
---|
| 96 | } |
---|
| 97 | } finally { |
---|
| 98 | if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context); |
---|
| 99 | } |
---|
| 100 | } |
---|
| 101 | } |
---|