<%-- /** * 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="static org.apache.commons.lang.StringEscapeUtils.escapeXml" import="java.util.TreeMap" import="java.util.Map" 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.ServerLoad" import="org.apache.hadoop.hbase.RegionLoad" import="org.apache.hadoop.hbase.master.HMaster" import="org.apache.hadoop.hbase.util.Bytes" import="org.apache.hadoop.hbase.util.FSUtils" import="org.apache.hadoop.hbase.regionserver.compactions.CompactionRequest" import="org.apache.hadoop.hbase.protobuf.generated.AdminProtos.GetRegionInfoResponse.CompactionState" import="org.apache.hadoop.hbase.TableName" import="org.apache.hadoop.hbase.HBaseConfiguration" %> <% HMaster master = (HMaster)getServletContext().getAttribute(HMaster.MASTER); Configuration conf = master.getConfiguration(); HBaseAdmin hbadmin = new HBaseAdmin(conf); String fqtn = request.getParameter("name"); HTable table = new HTable(conf, fqtn); String tableHeader = "

Table Regions

"; ServerName rl = master.getCatalogTracker().getMetaLocation(); 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); } %> <% String action = request.getParameter("action"); String key = request.getParameter("key"); if ( !readOnly && action != null ) { %> HBase Master: <%= master.getServerName() %>


<% if (action.equals("split")) { if (key != null && key.length() > 0) { hbadmin.split(key); } else { hbadmin.split(fqtn); } %> Split request accepted. <% } else if (action.equals("compact")) { if (key != null && key.length() > 0) { hbadmin.compact(key); } else { hbadmin.compact(fqtn); } %> Compact request accepted. <% } %>

Go Back, or wait for the redirect.

<% } else { %> Table: <%= fqtn %>
<% if(fqtn.equals(TableName.META_TABLE_NAME.getNameAsString())) { %> <%= 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() + ":" + master.getRegionServerInfoPort(metaLocation) + "/"; %>
<% } %>
NameRegion ServerStart KeyEnd KeyRequests
<%= escapeXml(meta.getRegionNameAsString()) %> <%= metaLocation.getHostname().toString() + ":" + master.getRegionServerInfoPort(metaLocation) %> - <%= escapeXml(Bytes.toString(meta.getStartKey())) %> <%= escapeXml(Bytes.toString(meta.getEndKey())) %>
<%} else { try { %>

Table Attributes

<% if (showFragmentation) { %> <% } %>
Attribute Name Value Description
Enabled <%= hbadmin.isTableEnabled(table.getTableName()) %> Is the table enabled
Compaction <% try { CompactionState compactionState = hbadmin.getCompactionState(table.getTableName()); %> <%= compactionState %> <% } catch (Exception e) { // Nothing really to do here e.printStackTrace(); %> Unknown <% } %> Is the table compacting
Fragmentation <%= frags.get(fqtn) != null ? frags.get(fqtn).intValue() + "%" : "n/a" %> How fragmented is the table. After a major compaction it is 0%.
<% Map regDistribution = new TreeMap(); 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 urlRegionServer = null; if (addr != null) { ServerLoad sl = master.getServerManager().getLoad(addr); if (sl != null) { Map map = sl.getRegionsLoad(); if (map.containsKey(regionInfo.getRegionName())) { req = map.get(regionInfo.getRegionName()).getRequestsCount(); } Integer i = regDistribution.get(addr); if (null == i) i = Integer.valueOf(0); regDistribution.put(addr, i + 1); } } %> <%= escapeXml(Bytes.toStringBinary(regionInfo.getRegionName())) %> <% if (addr != null) { String url = "//" + addr.getHostname() + ":" + master.getRegionServerInfoPort(addr) + "/"; %> <%= addr.getHostname().toString() + ":" + addr.getPort() %> <% } else { %> not deployed <% } %> <%= escapeXml(Bytes.toStringBinary(regionInfo.getStartKey())) %> <%= escapeXml(Bytes.toStringBinary(regionInfo.getEndKey())) %> <%= req%> <% } %>

Regions by Region Server

<% for (Map.Entry rdEntry : regDistribution.entrySet()) { ServerName addr = rdEntry.getKey(); String url = "//" + addr.getHostname() + ":" + master.getRegionServerInfoPort(addr) + "/"; %> <% } %>
Region ServerRegion Count
<%= addr.getHostname().toString() + ":" + addr.getPort() %> <%= 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.

<% } %> <% } %>