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.hdfs.server.namenode.NamenodeJspHelper.XMLBlockInfo;
007 import org.apache.hadoop.hdfs.server.common.JspHelper;
008 import org.znerd.xmlenc.*;
009
010 public final class block_005finfo_005fxml_jsp extends org.apache.jasper.runtime.HttpJspBase
011 implements org.apache.jasper.runtime.JspSourceDependent {
012
013
014 /*
015 * Licensed to the Apache Software Foundation (ASF) under one
016 * or more contributor license agreements. See the NOTICE file
017 * distributed with this work for additional information
018 * regarding copyright ownership. The ASF licenses this file
019 * to you under the Apache License, Version 2.0 (the
020 * "License"); you may not use this file except in compliance
021 * with the License. You may obtain a copy of the License at
022 *
023 * http://www.apache.org/licenses/LICENSE-2.0
024 *
025 * Unless required by applicable law or agreed to in writing, software
026 * distributed under the License is distributed on an "AS IS" BASIS,
027 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
028 * See the License for the specific language governing permissions and
029 * limitations under the License.
030 */
031
032 /*
033
034 This script outputs information about a block (as XML). The script accepts a
035 GET parameter named blockId which should be block id (as a long).
036
037 Example output is below (the blockId was 8888705098093096373):
038 <block_info>
039 <block_id>8888705098093096373</block_id>
040 <block_name>blk_8888705098093096373</block_name>
041 <file>
042 <local_name>some_file_name</local_name>
043 <local_directory>/input/</local_directory>
044 <user_name>user_name</user_name>
045 <group_name>supergroup</group_name>
046 <is_directory>false</is_directory>
047 <access_time>1251166313680</access_time>
048 <is_under_construction>false</is_under_construction>
049 <ds_quota>-1</ds_quota>
050 <permission_status>user_name:supergroup:rw-r--r--</permission_status>
051 <replication>1</replication>
052 <disk_space_consumed>2815</disk_space_consumed>
053 <preferred_block_size>67108864</preferred_block_size>
054 </file>
055 <replicas>
056 <replica>
057 <host_name>hostname</host_name>
058 <is_corrupt>false</is_corrupt>
059 </replica>
060 </replicas>
061 </block_info>
062
063 Notes:
064 - block_info/file will only exist if the file can be found
065 - block_info/replicas can contain 0 or more children
066 - If an error exists, block_info/error will exist and contain a human
067 readable error message
068
069 */
070
071
072
073 //for java.io.Serializable
074 private static final long serialVersionUID = 1L;
075
076 private static java.util.List _jspx_dependants;
077
078 public Object getDependants() {
079 return _jspx_dependants;
080 }
081
082 public void _jspService(HttpServletRequest request, HttpServletResponse response)
083 throws java.io.IOException, ServletException {
084
085 JspFactory _jspxFactory = null;
086 PageContext pageContext = null;
087 HttpSession session = null;
088 ServletContext application = null;
089 ServletConfig config = null;
090 JspWriter out = null;
091 Object page = this;
092 JspWriter _jspx_out = null;
093 PageContext _jspx_page_context = null;
094
095
096 try {
097 _jspxFactory = JspFactory.getDefaultFactory();
098 response.setContentType("application/xml");
099 pageContext = _jspxFactory.getPageContext(this, request, response,
100 null, true, 8192, true);
101 _jspx_page_context = pageContext;
102 application = pageContext.getServletContext();
103 config = pageContext.getServletConfig();
104 session = pageContext.getSession();
105 out = pageContext.getOut();
106 _jspx_out = out;
107
108 out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
109
110 NameNode nn = NameNodeHttpServer.getNameNodeFromContext(application);
111 String namenodeRole = nn.getRole().toString();
112 FSNamesystem fsn = nn.getNamesystem();
113
114 Long blockId = null;
115 try {
116 blockId = JspHelper.validateLong(request.getParameter("blockId"));
117 } catch(NumberFormatException e) {
118 blockId = null;
119 }
120
121
122 XMLBlockInfo bi = new XMLBlockInfo(fsn, blockId);
123 XMLOutputter doc = new XMLOutputter(out, "UTF-8");
124 bi.toXML(doc);
125
126
127 } catch (Throwable t) {
128 if (!(t instanceof SkipPageException)){
129 out = _jspx_out;
130 if (out != null && out.getBufferSize() != 0)
131 out.clearBuffer();
132 if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
133 }
134 } finally {
135 if (_jspxFactory != null) _jspxFactory.releasePageContext(_jspx_page_context);
136 }
137 }
138 }