%@ page contentType="text/html;charset=UTF-8"
import="java.util.Map"
import="org.apache.hadoop.io.Writable"
import="org.apache.hadoop.conf.Configuration"
import="org.apache.hadoop.hbase.client.HTable"
import="org.apache.hadoop.hbase.client.HBaseAdmin"
import="org.apache.hadoop.hbase.HRegionInfo"
import="org.apache.hadoop.hbase.HServerAddress"
import="org.apache.hadoop.hbase.HServerInfo"
import="org.apache.hadoop.hbase.io.ImmutableBytesWritable"
import="org.apache.hadoop.hbase.master.HMaster"
import="org.apache.hadoop.hbase.util.Bytes"
import="org.apache.hadoop.hbase.util.FSUtils"
import="java.util.Map"
import="org.apache.hadoop.hbase.HConstants"%><%
HMaster master = (HMaster)getServletContext().getAttribute(HMaster.MASTER);
Configuration conf = master.getConfiguration();
HBaseAdmin hbadmin = new HBaseAdmin(conf);
String tableName = request.getParameter("name");
HTable table = new HTable(conf, tableName);
String tableHeader = "
Table Regions
Name | Region Server | Start Key | End Key |
";
HServerAddress rl = master.getCatalogTracker().getRootLocation();
boolean showFragmentation = conf.getBoolean("hbase.master.ui.fragmentation.enabled", false);
Map frags = null;
if (showFragmentation) {
frags = FSUtils.getTableFragmentation(master);
}
%>
<%
String action = request.getParameter("action");
String key = request.getParameter("key");
if ( action != null ) {
%>
Table action request accepted
<%
if (action.equals("split")) {
/*
if (key != null && key.length() > 0) {
Writable[] arr = new Writable[1];
arr[0] = new ImmutableBytesWritable(Bytes.toBytes(key));
master.modifyTable(Bytes.toBytes(tableName), HConstants.Modify.TABLE_SPLIT, arr);
} else {
master.modifyTable(Bytes.toBytes(tableName), HConstants.Modify.TABLE_SPLIT);
}
*/
%> Split request accepted -- BUT CURRENTLY A NOOP -- FIX!. <%
} else if (action.equals("compact")) {
/*
if (key != null && key.length() > 0) {
Writable[] arr = new Writable[1];
arr[0] = new ImmutableBytesWritable(Bytes.toBytes(key));
master.modifyTable(Bytes.toBytes(tableName), HConstants.Modify.TABLE_COMPACT, arr);
} else {
master.modifyTable(Bytes.toBytes(tableName), HConstants.Modify.TABLE_COMPACT, null);
}
*/
%> Compact request accepted -- BUT CURRENTLY A NOOP -- FIX! <%
}
%>
Reload.
<%
} else {
%>
Table: <%= tableName %>
Table: <%= tableName %>
<%
if(tableName.equals(Bytes.toString(HConstants.ROOT_TABLE_NAME))) {
%>
<%= tableHeader %>
<%
int infoPort = master.getServerManager().getHServerInfo(rl).getInfoPort();
String url = "http://" + rl.getHostname() + ":" + infoPort + "/";
%>
<%= tableName %> |
<%= rl.getHostname() %>:<%= rl.getPort() %> |
- |
|
- |
<%
} else if(tableName.equals(Bytes.toString(HConstants.META_TABLE_NAME))) {
%>
<%= tableHeader %>
<%
// NOTE: Presumes one meta region only.
HRegionInfo meta = HRegionInfo.FIRST_META_REGIONINFO;
HServerAddress metaLocation = master.getCatalogTracker().getMetaLocation();
for (int i = 0; i <= 1; i++) {
int infoPort = master.getServerManager().getHServerInfo(metaLocation).getInfoPort();
String url = "http://" + metaLocation.getHostname() + ":" + infoPort + "/";
%>
<%= meta.getRegionNameAsString() %> |
<%= metaLocation.getHostname().toString() + ":" + infoPort %> |
- | <%= Bytes.toString(meta.getStartKey()) %> | <%= Bytes.toString(meta.getEndKey()) %> |
<% } %>
<%} else {
try { %>
Table Attributes
Attribute Name |
Value |
Description |
Enabled |
<%= hbadmin.isTableEnabled(table.getTableName()) %> |
Is the table enabled |
<% if (showFragmentation) { %>
Fragmentation |
<%= frags.get(tableName) != null ? frags.get(tableName).intValue() + "%" : "n/a" %> |
How fragmented is the table. After a major compaction it is 0%. |
<% } %>
<%
Map regions = table.getRegionsInfo();
if(regions != null && regions.size() > 0) { %>
<%= tableHeader %>
<%
for(Map.Entry hriEntry : regions.entrySet()) {
int infoPort = master.getServerManager().getHServerInfo(hriEntry.getValue()).getInfoPort();
String urlRegionServer =
"http://" + hriEntry.getValue().getHostname().toString() + ":" + infoPort + "/";
%>
<%= Bytes.toStringBinary(hriEntry.getKey().getRegionName())%> |
<%= hriEntry.getValue().getHostname().toString() + ":" + infoPort %> |
<%= Bytes.toStringBinary(hriEntry.getKey().getStartKey())%> |
<%= Bytes.toStringBinary(hriEntry.getKey().getEndKey())%> |
<% } %>
<% }
} catch(Exception ex) {
ex.printStackTrace();
}
} // end else
%>
Actions:
<%
}
%>