001package org.apache.hadoop.hdfs.server.namenode; 002 003import javax.servlet.*; 004import javax.servlet.http.*; 005import javax.servlet.jsp.*; 006import java.io.IOException; 007import java.util.List; 008import org.apache.hadoop.conf.Configuration; 009import org.apache.hadoop.hdfs.server.common.JspHelper; 010import org.apache.hadoop.hdfs.server.namenode.NamenodeJspHelper.XMLCorruptBlockInfo; 011import org.apache.hadoop.util.ServletUtil; 012import org.znerd.xmlenc.*; 013 014public final class corrupt_005freplicas_005fxml_jsp extends org.apache.jasper.runtime.HttpJspBase 015 implements org.apache.jasper.runtime.JspSourceDependent { 016 017 018/* 019 * Licensed to the Apache Software Foundation (ASF) under one 020 * or more contributor license agreements. See the NOTICE file 021 * distributed with this work for additional information 022 * regarding copyright ownership. The ASF licenses this file 023 * to you under the Apache License, Version 2.0 (the 024 * "License"); you may not use this file except in compliance 025 * with the License. You may obtain a copy of the License at 026 * 027 * http://www.apache.org/licenses/LICENSE-2.0 028 * 029 * Unless required by applicable law or agreed to in writing, software 030 * distributed under the License is distributed on an "AS IS" BASIS, 031 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 032 * See the License for the specific language governing permissions and 033 * limitations under the License. 034 */ 035 036 /* 037 038 This script outputs information about corrupt replicas on the system (as XML). 039 040 The script takes two GET parameters: 041 - numCorruptBlocks The number of corrupt blocks to return. Must be >= 0 && 042 <= 100. Defaults to 10. 043 - startingBlockId The block id (as a long) from which to begin iterating. 044 Output does not include the starting block id (it begins at the following 045 block id). If not given, iteration starts from beginning. 046 047 Example output is below: 048 <corrupt_block_info> 049 <dfs_replication>1</dfs_replication> 050 <num_missing_blocks>1</num_missing_blocks> 051 <num_corrupt_replica_blocks>1</num_corrupt_replica_blocks> 052 <corrupt_replica_block_ids> 053 <block_id>-2207002825050436217</block_id> 054 </corrupt_replica_block_ids> 055 </corrupt_block_info> 056 057 Notes: 058 - corrupt_block_info/corrupt_replica_block_ids will 0 to numCorruptBlocks 059 children 060 - If an error exists, corrupt_block_info/error will exist and 061 contain a human readable error message 062 063*/ 064 065 066 067 private static final long serialVersionUID = 1L; 068 069 private static java.util.List _jspx_dependants; 070 071 public Object getDependants() { 072 return _jspx_dependants; 073 } 074 075 public void _jspService(HttpServletRequest request, HttpServletResponse response) 076 throws java.io.IOException, ServletException { 077 078 JspFactory _jspxFactory = null; 079 PageContext pageContext = null; 080 HttpSession session = null; 081 ServletContext application = null; 082 ServletConfig config = null; 083 JspWriter out = null; 084 Object page = this; 085 JspWriter _jspx_out = null; 086 PageContext _jspx_page_context = null; 087 088 089 try { 090 _jspxFactory = JspFactory.getDefaultFactory(); 091 response.setContentType("application/xml"); 092 pageContext = _jspxFactory.getPageContext(this, request, response, 093 null, true, 8192, true); 094 _jspx_page_context = pageContext; 095 application = pageContext.getServletContext(); 096 config = pageContext.getServletConfig(); 097 session = pageContext.getSession(); 098 out = pageContext.getOut(); 099 _jspx_out = out; 100 101 out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); 102 103 104 NameNode nn = NameNodeHttpServer.getNameNodeFromContext(application); 105 FSNamesystem fsn = nn.getNamesystem(); 106 107 Integer numCorruptBlocks = 10; 108 try { 109 Long l = JspHelper.validateLong(request.getParameter("numCorruptBlocks")); 110 if (l != null) { 111 numCorruptBlocks = l.intValue(); 112 } 113 } catch(NumberFormatException e) { 114 115 } 116 117 Long startingBlockId = null; 118 try { 119 startingBlockId = 120 JspHelper.validateLong(request.getParameter("startingBlockId")); 121 } catch(NumberFormatException e) { 122 } 123 124 XMLCorruptBlockInfo cbi = new XMLCorruptBlockInfo(fsn, 125 new Configuration(), 126 numCorruptBlocks, 127 startingBlockId); 128 XMLOutputter doc = new XMLOutputter(out, "UTF-8"); 129 cbi.toXML(doc); 130 131 } catch (Throwable t) { 132 if (!(t instanceof SkipPageException)){ 133 out = _jspx_out; 134 if (out != null && out.getBufferSize() != 0) 135 out.clearBuffer(); 136 if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); 137 } 138 } finally { 139 if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context); 140 } 141 } 142}