block_info_xml.jsp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?xml version="1.0" encoding="UTF-8"?><%!
  2. /*
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. */
  19. /*
  20. This script outputs information about a block (as XML). The script accepts a
  21. GET parameter named blockId which should be block id (as a long).
  22. Example output is below (the blockId was 8888705098093096373):
  23. <block_info>
  24. <block_id>8888705098093096373</block_id>
  25. <block_name>blk_8888705098093096373</block_name>
  26. <file>
  27. <local_name>some_file_name</local_name>
  28. <local_directory>/input/</local_directory>
  29. <user_name>user_name</user_name>
  30. <group_name>supergroup</group_name>
  31. <is_directory>false</is_directory>
  32. <access_time>1251166313680</access_time>
  33. <is_under_construction>false</is_under_construction>
  34. <ds_quota>-1</ds_quota>
  35. <permission_status>user_name:supergroup:rw-r--r--</permission_status>
  36. <replication>1</replication>
  37. <disk_space_consumed>2815</disk_space_consumed>
  38. <preferred_block_size>67108864</preferred_block_size>
  39. </file>
  40. <replicas>
  41. <replica>
  42. <host_name>hostname</host_name>
  43. <is_corrupt>false</is_corrupt>
  44. </replica>
  45. </replicas>
  46. </block_info>
  47. Notes:
  48. - block_info/file will only exist if the file can be found
  49. - block_info/replicas can contain 0 or more children
  50. - If an error exists, block_info/error will exist and contain a human
  51. readable error message
  52. */
  53. %>
  54. <%@ page
  55. contentType="application/xml"
  56. import="org.apache.hadoop.hdfs.server.namenode.NamenodeJspHelper.XMLBlockInfo"
  57. import="org.apache.hadoop.hdfs.server.common.JspHelper"
  58. import="org.znerd.xmlenc.*"
  59. %>
  60. <%!
  61. //for java.io.Serializable
  62. private static final long serialVersionUID = 1L;
  63. %>
  64. <%
  65. NameNode nn = NameNodeHttpServer.getNameNodeFromContext(application);
  66. String namenodeRole = nn.getRole().toString();
  67. FSNamesystem fsn = nn.getNamesystem();
  68. Long blockId = null;
  69. try {
  70. blockId = JspHelper.validateLong(request.getParameter("blockId"));
  71. } catch(NumberFormatException e) {
  72. blockId = null;
  73. }
  74. XMLBlockInfo bi = new XMLBlockInfo(fsn, blockId);
  75. XMLOutputter doc = new XMLOutputter(out, "UTF-8");
  76. bi.toXML(doc);
  77. %>