<% /* * 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.io.IOException" import="java.util.Map" import="java.net.URLEncoder" 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.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.HBaseConfiguration" 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); HBaseConfiguration conf = master.getConfiguration(); HBaseAdmin hbadmin = new HBaseAdmin(conf); String tableName = request.getParameter("name"); HTable table = new HTable(conf, tableName); Map serverAddressToServerInfos = master.getServerAddressToServerInfo(); String tableHeader = "

Table Regions

"; 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. <% } %>

Reload. <% } else { %> Table: <%= tableName %>

Table: <%= tableName %>


<% if(tableName.equals(Bytes.toString(HConstants.ROOT_TABLE_NAME))) { %> <%= tableHeader %> <% int infoPort = serverAddressToServerInfos.get(rootLocation).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 = serverAddressToServerInfos.get(meta.getServer()).getInfoPort(); String url = "http://" + meta.getServer().getHostname() + ":" + infoPort + "/"; %> <%= Bytes.toString(meta.getRegionName()) %> <%= meta.getServer().getHostname().toString() + ":" + infoPort %> -<%= Bytes.toString(meta.getStartKey()) %><%= Bytes.toString(meta.getEndKey()) %> <% } %> <%} else { try { %>

Table Attributes

Attribute NameValueDescription
Enabled<%= hbadmin.isTableEnabled(table.getTableName()) %>Is the table enabled
<% Map regions = table.getRegionsInfo(); if(regions != null && regions.size() > 0) { %> <%= tableHeader %> <% for(Map.Entry hriEntry : regions.entrySet()) { int infoPort = serverAddressToServerInfos.get( hriEntry.getValue()).getInfoPort(); String urlRegionServer = "http://" + hriEntry.getValue().getHostname().toString() + ":" + infoPort + "/"; %> <%= Bytes.toStringBinary(hriEntry.getKey().getRegionName())%> <%= hriEntry.getValue().getHostname().toString() + ":" + infoPort %> <%= hriEntry.getKey().getEncodedName()%> <%= Bytes.toStringBinary(hriEntry.getKey().getStartKey())%> <%= Bytes.toStringBinary(hriEntry.getKey().getEndKey())%> <% } %> <% } } catch(Exception ex) { ex.printStackTrace(); } } // end else %>


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.

<% } %>