001package org.apache.hadoop.hdfs.server.namenode;
002
003import javax.servlet.*;
004import javax.servlet.http.*;
005import javax.servlet.jsp.*;
006import org.apache.hadoop.util.ServletUtil;
007import org.apache.hadoop.fs.FileStatus;
008import org.apache.hadoop.fs.FileUtil;
009import org.apache.hadoop.fs.Path;
010import org.apache.hadoop.ha.HAServiceProtocol.HAServiceState;
011import java.util.Collection;
012import java.util.Collections;
013import java.util.Arrays;
014
015public final class corrupt_005ffiles_jsp extends org.apache.jasper.runtime.HttpJspBase
016    implements org.apache.jasper.runtime.JspSourceDependent {
017
018//for java.io.Serializable
019  private static final long serialVersionUID = 1L;
020  private static java.util.List _jspx_dependants;
021
022  public Object getDependants() {
023    return _jspx_dependants;
024  }
025
026  public void _jspService(HttpServletRequest request, HttpServletResponse response)
027        throws java.io.IOException, ServletException {
028
029    JspFactory _jspxFactory = null;
030    PageContext pageContext = null;
031    HttpSession session = null;
032    ServletContext application = null;
033    ServletConfig config = null;
034    JspWriter out = null;
035    Object page = this;
036    JspWriter _jspx_out = null;
037    PageContext _jspx_page_context = null;
038
039
040    try {
041      _jspxFactory = JspFactory.getDefaultFactory();
042      response.setContentType("text/html; charset=UTF-8");
043      pageContext = _jspxFactory.getPageContext(this, request, response,
044                        null, true, 8192, true);
045      _jspx_page_context = pageContext;
046      application = pageContext.getServletContext();
047      config = pageContext.getServletConfig();
048      session = pageContext.getSession();
049      out = pageContext.getOut();
050      _jspx_out = out;
051
052
053  /*
054   * Licensed to the Apache Software Foundation (ASF) under one
055   * or more contributor license agreements.  See the NOTICE file
056   * distributed with this work for additional information
057   * regarding copyright ownership.  The ASF licenses this file
058   * to you under the Apache License, Version 2.0 (the
059   * "License"); you may not use this file except in compliance
060   * with the License.  You may obtain a copy of the License at
061   *
062   *     http://www.apache.org/licenses/LICENSE-2.0
063   *
064   * Unless required by applicable law or agreed to in writing, software
065   * distributed under the License is distributed on an "AS IS" BASIS,
066   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
067   * See the License for the specific language governing permissions and
068   * limitations under the License.
069   */
070
071
072  NameNode nn = NameNodeHttpServer.getNameNodeFromContext(application);
073  FSNamesystem fsn = nn.getNamesystem();
074  HAServiceState nnHAState = nn.getServiceState();
075  boolean isActive = (nnHAState == HAServiceState.ACTIVE);
076  String namenodeRole = nn.getRole().toString();
077  String namenodeLabel = NamenodeJspHelper.getNameNodeLabel(nn);
078  Collection<FSNamesystem.CorruptFileBlockInfo> corruptFileBlocks = fsn != null ?
079    fsn.listCorruptFileBlocks("/", null) :
080    Collections.<FSNamesystem.CorruptFileBlockInfo>emptyList();
081  int corruptFileCount = corruptFileBlocks.size();
082
083      out.write("<!DOCTYPE html>\n<html>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"/static/hadoop.css\">\n<title>Hadoop ");
084      out.print(namenodeRole);
085      out.write("&nbsp;");
086      out.print(namenodeLabel);
087      out.write("</title>\n<body>\n<h1>");
088      out.print(namenodeRole);
089      out.write(' ');
090      out.write('\'');
091      out.print(namenodeLabel);
092      out.write("'</h1>\n");
093      out.print(NamenodeJspHelper.getVersionTable(fsn));
094      out.write("<br>\n");
095 if (isActive && fsn != null) { 
096      out.write("<b><a href=\"/nn_browsedfscontent.jsp\">Browse the filesystem</a></b>\n  <br>\n");
097 } 
098      out.write("<b><a href=\"/logs/\">");
099      out.print(namenodeRole);
100      out.write(" Logs</a></b>\n<br>\n<b><a href=/dfshealth.jsp> Go back to DFS home</a></b>\n<hr>\n<h3>Reported Corrupt Files</h3>\n");
101
102  if (corruptFileCount == 0) {
103
104      out.write("<i>No missing blocks found at the moment.</i> <br>\n    Please run fsck for a thorough health analysis.\n");
105
106  } else {
107    for (FSNamesystem.CorruptFileBlockInfo c : corruptFileBlocks) {
108      String currentFileBlock = c.toString();
109
110      out.print(currentFileBlock);
111      out.write("<br>\n");
112
113    }
114
115      out.write("<p>\n      <b>Total:</b> At least ");
116      out.print(corruptFileCount);
117      out.write(" corrupt file(s)\n    </p>\n");
118
119  }
120
121
122  out.println(ServletUtil.htmlFooter());
123
124    } catch (Throwable t) {
125      if (!(t instanceof SkipPageException)){
126        out = _jspx_out;
127        if (out != null && out.getBufferSize() != 0)
128          out.clearBuffer();
129        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
130      }
131    } finally {
132      if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
133    }
134  }
135}