<%@ page contentType="text/html;charset=UTF-8" import="org.apache.hadoop.io.Text" import="org.apache.hadoop.io.Writable" import="org.apache.hadoop.hbase.HTableDescriptor" import="org.apache.hadoop.hbase.client.HTable" 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.master.MetaRegion" import="org.apache.hadoop.hbase.util.Bytes" import="java.io.IOException" import="java.util.Map" import="org.apache.hadoop.hbase.HConstants"%><% HMaster master = (HMaster)getServletContext().getAttribute(HMaster.MASTER); String tableName = request.getParameter("name"); HTable table = new HTable(master.getConfiguration(), tableName); Map serverToServerInfos = master.getServersToServerInfo(); String tableHeader = ""; HServerAddress rootLocation = master.getRootRegionLocation(); %> <% 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, null); } %> Split request accepted. <% } 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. <% } %>

This page will refresh in 5 seconds. <% } else { %> Regions in <%= tableName %>

Regions in <%= tableName %>


<%if(tableName.equals(Bytes.toString(HConstants.ROOT_TABLE_NAME))) {%> <%= tableHeader %> <% int infoPort = serverToServerInfos.get(rootLocation.getBindAddress()+":"+rootLocation.getPort()).getInfoPort(); String url = "http://" + rootLocation.getHostname() + ":" + infoPort + "/";%>
NameRegion ServerEncoded NameStart KeyEnd Key
<%= tableName %><%= rootLocation.getHostname() %>:<%= rootLocation.getPort() %>--
<%} else if(tableName.equals(Bytes.toString(HConstants.META_TABLE_NAME))) { %> <%= tableHeader %> <% Map onlineRegions = master.getOnlineMetaRegions(); for (MetaRegion meta: onlineRegions.values()) { int infoPort = serverToServerInfos.get(meta.getServer().getBindAddress()+":"+meta.getServer().getPort()).getInfoPort(); String url = "http://" + meta.getServer().getHostname() + ":" + infoPort + "/";%> <%= Bytes.toString(meta.getRegionName()) %> <%= meta.getServer().getHostname() %>:<%= meta.getServer().getPort() %> -<%= Bytes.toString(meta.getStartKey()) %>- <% } %> <%} else { try { Map regions = table.getRegionsInfo(); if(regions != null && regions.size() > 0) { %> <%= tableHeader %> <% for(Map.Entry hriEntry : regions.entrySet()) { %> <% int infoPort = serverToServerInfos.get(hriEntry.getValue().getBindAddress()+":"+hriEntry.getValue().getPort()).getInfoPort(); String urlRegionHistorian = "/regionhistorian.jsp?regionname="+hriEntry.getKey().getRegionNameAsString(); String urlRegionServer = "http://" + hriEntry.getValue().getHostname().toString() + ":" + infoPort + "/"; %> <%= hriEntry.getKey().getRegionNameAsString()%> <%= hriEntry.getValue().getHostname() %>:<%= hriEntry.getValue().getPort() %> <%= hriEntry.getKey().getEncodedName()%> <%= Bytes.toString(hriEntry.getKey().getStartKey())%> <%= Bytes.toString(hriEntry.getKey().getEndKey())%> <% } %> <% } } catch(Exception ex) { ex.printStackTrace(); } }%>


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.

<% } %>