<%@ page contentType="text/html;charset=UTF-8" import="org.apache.hadoop.io.Text" 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.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(); %>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(); } }%>