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