<%-- /** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ --%> <%@ page contentType="text/html;charset=UTF-8" import="java.util.HashMap" 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.ServerName" import="org.apache.hadoop.hbase.HServerAddress" import="org.apache.hadoop.hbase.ServerName" import="org.apache.hadoop.hbase.HServerInfo" import="org.apache.hadoop.hbase.HServerLoad" import="org.apache.hadoop.hbase.HServerLoad.RegionLoad" 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

"; ServerName rl = master.getCatalogTracker().getRootLocation(); boolean showFragmentation = conf.getBoolean("hbase.master.ui.fragmentation.enabled", false); boolean readOnly = conf.getBoolean("hbase.master.ui.readonly", false); Map frags = null; if (showFragmentation) { frags = FSUtils.getTableFragmentation(master); } // HARDCODED FOR NOW TODO: FIX GET FROM ZK // This port might be wrong if RS actually ended up using something else. int infoPort = conf.getInt("hbase.regionserver.info.port", 60030); %> <% String action = request.getParameter("action"); String key = request.getParameter("key"); if ( !readOnly && 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 %> <% String url = "//" + rl.getHostname() + ":" + infoPort + "/"; %>
NameRegion ServerStart KeyEnd KeyRequests
<%= 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; ServerName metaLocation = master.getCatalogTracker().waitForMeta(1); for (int i = 0; i < 1; i++) { String url = "//" + 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
Compaction <%= hbadmin.getCompactionState(table.getTableName()) %> Is the table compacting
Fragmentation <%= frags.get(tableName) != null ? frags.get(tableName).intValue() + "%" : "n/a" %> How fragmented is the table. After a major compaction it is 0%.
<% Map regDistribution = new HashMap(); Map regions = table.getRegionLocations(); if(regions != null && regions.size() > 0) { %> <%= tableHeader %> <% for (Map.Entry hriEntry : regions.entrySet()) { HRegionInfo regionInfo = hriEntry.getKey(); ServerName addr = hriEntry.getValue(); long req = 0; String regionServer = null; if (addr != null) { HServerLoad sl = master.getServerManager().getLoad(addr); if (sl != null) { Map map = sl.getRegionsLoad(); if (map.containsKey(regionInfo.getRegionName())) { req = map.get(regionInfo.getRegionName()).getRequestsCount(); } // This port might be wrong if RS actually ended up using something else. regionServer = addr.getHostname().toString() + ":" + infoPort; Integer i = regDistribution.get(regionServer); if (null == i) i = new Integer(0); regDistribution.put(regionServer, i+1); } } %> <%= Bytes.toStringBinary(regionInfo.getRegionName())%> <% if (regionServer != null) { %> "><%= regionServer %> <% } else { %> not deployed <% } %> <%= Bytes.toStringBinary(regionInfo.getStartKey())%> <%= Bytes.toStringBinary(regionInfo.getEndKey())%> <%= req%> <% } %>

Regions by Region Server

<% for (Map.Entry rdEntry : regDistribution.entrySet()) { %> <% } %>
Region ServerRegion Count
"><%= rdEntry.getKey() %> <%= rdEntry.getValue()%>
<% } } catch(Exception ex) { ex.printStackTrace(System.err); } } // end else HConnectionManager.deleteConnection(hbadmin.getConfiguration()); %> <% if (!readOnly) { %>


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.

<% } %> <% } %>