Example #1
0
 /**
  * Select a datanode to service this request. Currently, this looks at no more than the first five
  * blocks of a file, selecting a datanode randomly from the most represented.
  *
  * @param conf
  */
 private DatanodeID pickSrcDatanode(LocatedBlocks blks, HdfsFileStatus i, Configuration conf)
     throws IOException {
   if (i.getLen() == 0 || blks.getLocatedBlocks().size() <= 0) {
     // pick a random datanode
     NameNode nn = NameNodeHttpServer.getNameNodeFromContext(getServletContext());
     return NamenodeJspHelper.getRandomDatanode(nn);
   }
   return JspHelper.bestNode(blks, conf);
 }
  public void _jspService(HttpServletRequest request, HttpServletResponse response)
      throws java.io.IOException, ServletException {

    JspFactory _jspxFactory = null;
    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;

    try {
      _jspxFactory = JspFactory.getDefaultFactory();
      response.setContentType("text/html; charset=UTF-8");
      pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;

      /*
       * Licensed to the Apache Software Foundation (ASF) under one
       * or more contributor license agreements.  See the NOTICE file
       * distributed with this work for additional information
       * regarding copyright ownership.  The ASF licenses this file
       * to you under the Apache License, Version 2.0 (the
       * "License"); you may not use this file except in compliance
       * with the License.  You may obtain a copy of the License at
       *
       *     http://www.apache.org/licenses/LICENSE-2.0
       *
       * Unless required by applicable law or agreed to in writing, software
       * distributed under the License is distributed on an "AS IS" BASIS,
       * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       * See the License for the specific language governing permissions and
       * limitations under the License.
       */

      out.write('\n');
      out.write('\n');
      out.write('\n');

      final NamenodeJspHelper.NodeListJsp nodelistjsp = new NamenodeJspHelper.NodeListJsp();
      NameNode nn = (NameNode) application.getAttribute("name.node");
      String namenodeRole = nn.getRole().toString();
      FSNamesystem fsn = nn.getNamesystem();
      String namenodeLabel =
          nn.getNameNodeAddress().getHostName() + ":" + nn.getNameNodeAddress().getPort();

      out.write(
          "\n\n<html>\n\n<link rel=\"stylesheet\" type=\"text/css\" href=\"/static/hadoop.css\">\n<title>Hadoop ");
      out.print(namenodeRole);
      out.write(' ');
      out.print(namenodeLabel);
      out.write("</title>\n  \n<body>\n<h1>");
      out.print(namenodeRole);
      out.write(' ');
      out.write('\'');
      out.print(namenodeLabel);
      out.write("'</h1>\n");
      out.print(NamenodeJspHelper.getVersionTable(fsn));
      out.write(
          "\n<br />\n<b><a href=\"/nn_browsedfscontent.jsp\">Browse the filesystem</a></b><br>\n<b><a href=\"/logs/\">");
      out.print(namenodeRole);
      out.write(
          " Logs</a></b><br>\n<b><a href=/dfshealth.jsp> Go back to DFS home</a></b>\n<hr>\n");
      nodelistjsp.generateNodesList(out, nn, request);
      out.write('\n');
      out.write('\n');

      out.println(ServletUtil.htmlFooter());

      out.write('\n');
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)) {
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0) out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }