<%@ 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.client.HConnectionManager" 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

"; 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) { hbadmin.split(key); } else { hbadmin.split(tableName); } %> Split request accepted. <% } else if (action.equals("compact")) { if (key != null && key.length() > 0) { hbadmin.compact(key); } else { hbadmin.compact(tableName); } %> Compact request accepted. <% } %>

Go Back, or wait for the redirect. <% } 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 + "/"; %>
NameRegion ServerStart KeyEnd Key
<%= 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

<% if (showFragmentation) { %> <% } %>
Attribute Name Value Description
Enabled <%= hbadmin.isTableEnabled(table.getTableName()) %> Is the table enabled
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()) { HRegionInfo regionInfo = hriEntry.getKey(); HServerAddress addr = hriEntry.getValue(); int infoPort = 0; String urlRegionServer = null; if (addr != null) { HServerInfo info = master.getServerManager().getHServerInfo(addr); if (info != null) { infoPort = info.getInfoPort(); urlRegionServer = "http://" + addr.getHostname().toString() + ":" + infoPort + "/"; } } %> <%= Bytes.toStringBinary(regionInfo.getRegionName())%> <% if (urlRegionServer != null) { %> <%= addr.getHostname().toString() + ":" + infoPort %> <% } else { %> not deployed <% } %> <%= Bytes.toStringBinary(regionInfo.getStartKey())%> <%= Bytes.toStringBinary(regionInfo.getEndKey())%> <% } %> <% } } catch(Exception ex) { ex.printStackTrace(System.err); } } // end else HConnectionManager.deleteConnection(hbadmin.getConfiguration(), false); %>


Actions:

  Region Key (optional): This action will force a compaction of all regions of the table, or, if a key is supplied, only the region containing the given key.
 
  Region Key (optional): This action will force a split of all eligible regions of the table, or, if a key is supplied, only the region containing the given key. An eligible region is one that does not contain any references to other regions. Split requests for noneligible regions will be ignored.

<% } %>