1 package org.apache.hadoop.hbase.generated.master;
2
3 import javax.servlet.*;
4 import javax.servlet.http.*;
5 import javax.servlet.jsp.*;
6 import java.util.Map;
7 import org.apache.hadoop.io.Writable;
8 import org.apache.hadoop.conf.Configuration;
9 import org.apache.hadoop.hbase.client.HTable;
10 import org.apache.hadoop.hbase.client.HBaseAdmin;
11 import org.apache.hadoop.hbase.client.HConnectionManager;
12 import org.apache.hadoop.hbase.HRegionInfo;
13 import org.apache.hadoop.hbase.HServerAddress;
14 import org.apache.hadoop.hbase.HServerInfo;
15 import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
16 import org.apache.hadoop.hbase.master.HMaster;
17 import org.apache.hadoop.hbase.util.Bytes;
18 import org.apache.hadoop.hbase.util.FSUtils;
19 import java.util.Map;
20 import org.apache.hadoop.hbase.HConstants;
21
22 public final class table_jsp extends org.apache.jasper.runtime.HttpJspBase
23 implements org.apache.jasper.runtime.JspSourceDependent {
24
25 private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();
26
27 private static java.util.Vector _jspx_dependants;
28
29 private org.apache.jasper.runtime.ResourceInjector _jspx_resourceInjector;
30
31 public Object getDependants() {
32 return _jspx_dependants;
33 }
34
35 public void _jspService(HttpServletRequest request, HttpServletResponse response)
36 throws java.io.IOException, ServletException {
37
38 PageContext pageContext = null;
39 HttpSession session = null;
40 ServletContext application = null;
41 ServletConfig config = null;
42 JspWriter out = null;
43 Object page = this;
44 JspWriter _jspx_out = null;
45 PageContext _jspx_page_context = null;
46
47 try {
48 response.setContentType("text/html;charset=UTF-8");
49 pageContext = _jspxFactory.getPageContext(this, request, response,
50 null, true, 8192, true);
51 _jspx_page_context = pageContext;
52 application = pageContext.getServletContext();
53 config = pageContext.getServletConfig();
54 session = pageContext.getSession();
55 out = pageContext.getOut();
56 _jspx_out = out;
57 _jspx_resourceInjector = (org.apache.jasper.runtime.ResourceInjector) application.getAttribute("com.sun.appserv.jsp.resource.injector");
58
59
60 HMaster master = (HMaster)getServletContext().getAttribute(HMaster.MASTER);
61 Configuration conf = master.getConfiguration();
62 HBaseAdmin hbadmin = new HBaseAdmin(conf);
63 String tableName = request.getParameter("name");
64 HTable table = new HTable(conf, tableName);
65 String tableHeader = "<h2>Table Regions</h2><table><tr><th>Name</th><th>Region Server</th><th>Start Key</th><th>End Key</th></tr>";
66 HServerAddress rl = master.getCatalogTracker().getRootLocation();
67 boolean showFragmentation = conf.getBoolean("hbase.master.ui.fragmentation.enabled", false);
68 Map<String, Integer> frags = null;
69 if (showFragmentation) {
70 frags = FSUtils.getTableFragmentation(master);
71 }
72
73 out.write("\n\n<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \n \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"> \n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n\n");
74
75 String action = request.getParameter("action");
76 String key = request.getParameter("key");
77 if ( action != null ) {
78
79 out.write("\n<head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\"/>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"/static/hbase.css\" />\n<meta http-equiv=\"refresh\" content=\"5,javascript:history.back()\" />\n</head>\n<body>\n<a id=\"logo\" href=\"http://wiki.apache.org/lucene-hadoop/Hbase\"><img src=\"/static/hbase_logo_med.gif\" alt=\"HBase Logo\" title=\"HBase Logo\" /></a>\n<h1 id=\"page_title\">Table action request accepted</h1>\n<p><hr><p>\n");
80
81 if (action.equals("split")) {
82 if (key != null && key.length() > 0) {
83 hbadmin.split(key);
84 } else {
85 hbadmin.split(tableName);
86 }
87
88
89 out.write(" Split request accepted. ");
90
91 } else if (action.equals("compact")) {
92 if (key != null && key.length() > 0) {
93 hbadmin.compact(key);
94 } else {
95 hbadmin.compact(tableName);
96 }
97
98 out.write(" Compact request accepted. ");
99
100 }
101
102 out.write("\n<p>Go <a href=\"javascript:history.back()\">Back</a>, or wait for the redirect.\n\n</body>\n");
103
104 } else {
105
106 out.write("\n<head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\"/>\n<title>Table: ");
107 out.print( tableName );
108 out.write("</title>\n<link rel=\"stylesheet\" type=\"text/css\" href=\"/static/hbase.css\" />\n</head>\n<body>\n<a id=\"logo\" href=\"http://wiki.apache.org/lucene-hadoop/Hbase\"><img src=\"/static/hbase_logo_med.gif\" alt=\"HBase Logo\" title=\"HBase Logo\" /></a>\n<h1 id=\"page_title\">Table: ");
109 out.print( tableName );
110 out.write("</h1>\n<p id=\"links_menu\"><a href=\"/master.jsp\">Master</a>, <a href=\"/logs/\">Local logs</a>, <a href=\"/stacks\">Thread Dump</a>, <a href=\"/logLevel\">Log Level</a></p>\n<hr id=\"head_rule\" />\n");
111
112 if(tableName.equals(Bytes.toString(HConstants.ROOT_TABLE_NAME))) {
113
114 out.write('\n');
115 out.print( tableHeader );
116 out.write('\n');
117
118 int infoPort = master.getServerManager().getHServerInfo(rl).getInfoPort();
119 String url = "http://" + rl.getHostname() + ":" + infoPort + "/";
120
121 out.write("\n<tr>\n <td>");
122 out.print( tableName );
123 out.write("</td>\n <td><a href=\"");
124 out.print( url );
125 out.write('"');
126 out.write('>');
127 out.print( rl.getHostname() );
128 out.write(':');
129 out.print( rl.getPort() );
130 out.write("</a></td>\n <td>-</td>\n <td></td>\n <td>-</td>\n</tr>\n</table>\n");
131
132 } else if(tableName.equals(Bytes.toString(HConstants.META_TABLE_NAME))) {
133
134 out.write('\n');
135 out.print( tableHeader );
136 out.write('\n');
137
138
139 HRegionInfo meta = HRegionInfo.FIRST_META_REGIONINFO;
140 HServerAddress metaLocation = master.getCatalogTracker().getMetaLocation();
141 for (int i = 0; i < 1; i++) {
142 int infoPort = master.getServerManager().getHServerInfo(metaLocation).getInfoPort();
143 String url = "http://" + metaLocation.getHostname() + ":" + infoPort + "/";
144
145 out.write("\n<tr>\n <td>");
146 out.print( meta.getRegionNameAsString() );
147 out.write("</td>\n <td><a href=\"");
148 out.print( url );
149 out.write('"');
150 out.write('>');
151 out.print( metaLocation.getHostname().toString() + ":" + infoPort );
152 out.write("</a></td>\n <td>-</td><td>");
153 out.print( Bytes.toString(meta.getStartKey()) );
154 out.write("</td><td>");
155 out.print( Bytes.toString(meta.getEndKey()) );
156 out.write("</td>\n</tr>\n");
157 }
158 out.write("\n</table>\n");
159 } else {
160 try {
161 out.write("\n<h2>Table Attributes</h2>\n<table>\n <tr>\n <th>Attribute Name</th>\n <th>Value</th>\n <th>Description</th></tr>\n <tr>\n <td>Enabled</td>\n <td>");
162 out.print( hbadmin.isTableEnabled(table.getTableName()) );
163 out.write("</td>\n <td>Is the table enabled</td>\n </tr>\n");
164 if (showFragmentation) {
165 out.write("\n <tr>\n <td>Fragmentation</td>\n <td>");
166 out.print( frags.get(tableName) != null ? frags.get(tableName).intValue() + "%" : "n/a" );
167 out.write("</td>\n <td>How fragmented is the table. After a major compaction it is 0%.</td>\n </tr>\n");
168 }
169 out.write("\n</table>\n");
170
171 Map<HRegionInfo, HServerAddress> regions = table.getRegionsInfo();
172 if(regions != null && regions.size() > 0) {
173 out.write('\n');
174 out.print( tableHeader );
175 out.write('\n');
176
177 for(Map.Entry<HRegionInfo, HServerAddress> hriEntry : regions.entrySet()) {
178 HRegionInfo regionInfo = hriEntry.getKey();
179 HServerAddress addr = hriEntry.getValue();
180
181 int infoPort = 0;
182 String urlRegionServer = null;
183
184 if (addr != null) {
185 HServerInfo info = master.getServerManager().getHServerInfo(addr);
186 if (info != null) {
187 infoPort = info.getInfoPort();
188 urlRegionServer =
189 "http://" + addr.getHostname().toString() + ":" + infoPort + "/";
190 }
191 }
192
193 out.write("\n<tr>\n <td>");
194 out.print( Bytes.toStringBinary(regionInfo.getRegionName()));
195 out.write("</td>\n ");
196
197 if (urlRegionServer != null) {
198
199 out.write("\n <td>\n <a href=\"");
200 out.print( urlRegionServer );
201 out.write('"');
202 out.write('>');
203 out.print( addr.getHostname().toString() + ":" + infoPort );
204 out.write("</a>\n </td>\n ");
205
206 } else {
207
208 out.write("\n <td class=\"undeployed-region\">not deployed</td>\n ");
209
210 }
211
212 out.write("\n <td>");
213 out.print( Bytes.toStringBinary(regionInfo.getStartKey()));
214 out.write("</td>\n <td>");
215 out.print( Bytes.toStringBinary(regionInfo.getEndKey()));
216 out.write("</td>\n</tr>\n");
217 }
218 out.write("\n</table>\n");
219 }
220 } catch(Exception ex) {
221 ex.printStackTrace(System.err);
222 }
223 }
224
225 HConnectionManager.deleteConnection(hbadmin.getConfiguration(), false);
226
227 out.write("\n\n<p><hr><p>\nActions:\n<p>\n<center>\n<table style=\"border-style: none\" width=\"90%\">\n<tr>\n <form method=\"get\">\n <input type=\"hidden\" name=\"action\" value=\"compact\">\n <input type=\"hidden\" name=\"name\" value=\"");
228 out.print( tableName );
229 out.write("\">\n <td style=\"border-style: none; text-align: center\">\n <input style=\"font-size: 12pt; width: 10em\" type=\"submit\" value=\"Compact\"></td>\n <td style=\"border-style: none\" width=\"5%\"> </td>\n <td style=\"border-style: none\">Region Key (optional):<input type=\"text\" name=\"key\" size=\"40\"></td>\n <td style=\"border-style: none\">This action will force a compaction of all\n regions of the table, or, if a key is supplied, only the region containing the\n given key.</td>\n </form>\n</tr>\n<tr><td style=\"border-style: none\" colspan=\"4\"> </td></tr>\n<tr>\n <form method=\"get\">\n <input type=\"hidden\" name=\"action\" value=\"split\">\n <input type=\"hidden\" name=\"name\" value=\"");
230 out.print( tableName );
231 out.write("\">\n <td style=\"border-style: none; text-align: center\">\n <input style=\"font-size: 12pt; width: 10em\" type=\"submit\" value=\"Split\"></td>\n <td style=\"border-style: none\" width=\"5%\"> </td>\n <td style=\"border-style: none\">Region Key (optional):<input type=\"text\" name=\"key\" size=\"40\"></td>\n <td style=\"border-style: none\">This action will force a split of all eligible\n regions of the table, or, if a key is supplied, only the region containing the\n given key. An eligible region is one that does not contain any references to\n other regions. Split requests for noneligible regions will be ignored.</td>\n </form>\n</tr>\n</table>\n</center>\n<p>\n\n");
232
233 }
234
235 out.write("\n\n</body>\n</html>\n");
236 } catch (Throwable t) {
237 if (!(t instanceof SkipPageException)){
238 out = _jspx_out;
239 if (out != null && out.getBufferSize() != 0)
240 out.clearBuffer();
241 if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
242 }
243 } finally {
244 _jspxFactory.releasePageContext(_jspx_page_context);
245 }
246 }
247 }