All Downloads are FREE. Search and download functionalities are using the official Maven repository.

hbase-webapps.master.table.jsp Maven / Gradle / Ivy

There is a newer version: 3.0.0-beta-1
Show newest version
<%--
/**
 * 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.lang3.StringEscapeUtils.escapeXml"
  import="java.net.URLEncoder"
  import="java.util.ArrayList"
  import="java.util.Collection"
  import="java.util.HashMap"
  import="java.util.LinkedHashMap"
  import="java.util.List"
  import="java.util.Map"
  import="java.util.Set"
  import="java.util.HashSet"
  import="java.util.Optional"
  import="java.util.TreeMap"
  import="java.util.concurrent.TimeoutException"
  import="java.util.concurrent.TimeUnit"
  import="org.apache.commons.lang3.StringEscapeUtils"
  import="org.apache.hadoop.conf.Configuration"
  import="org.apache.hadoop.hbase.HConstants"
  import="org.apache.hadoop.hbase.HRegionLocation"
  import="org.apache.hadoop.hbase.NotServingRegionException"
  import="org.apache.hadoop.hbase.RegionMetrics"
  import="org.apache.hadoop.hbase.RegionMetricsBuilder"
  import="org.apache.hadoop.hbase.ServerMetrics"
  import="org.apache.hadoop.hbase.ServerName"
  import="org.apache.hadoop.hbase.Size"
  import="org.apache.hadoop.hbase.TableName"
  import="org.apache.hadoop.hbase.TableNotFoundException"
  import="org.apache.hadoop.hbase.client.AsyncAdmin"
  import="org.apache.hadoop.hbase.client.AsyncConnection"
  import="org.apache.hadoop.hbase.client.ColumnFamilyDescriptor"
  import="org.apache.hadoop.hbase.client.CompactionState"
  import="org.apache.hadoop.hbase.client.RegionInfo"
  import="org.apache.hadoop.hbase.client.RegionInfoBuilder"
  import="org.apache.hadoop.hbase.client.RegionLocator"
  import="org.apache.hadoop.hbase.client.RegionReplicaUtil"
  import="org.apache.hadoop.hbase.client.Table"
  import="org.apache.hadoop.hbase.client.TableState"
  import="org.apache.hadoop.hbase.client.ColumnFamilyDescriptor"
  import="org.apache.hadoop.hbase.http.InfoServer"
  import="org.apache.hadoop.hbase.master.HMaster"
  import="org.apache.hadoop.hbase.master.RegionState"
  import="org.apache.hadoop.hbase.master.assignment.RegionStateNode"
  import="org.apache.hadoop.hbase.master.assignment.RegionStates"
  import="org.apache.hadoop.hbase.master.http.MetaBrowser"
  import="org.apache.hadoop.hbase.master.http.RegionReplicaInfo"
  import="org.apache.hadoop.hbase.quotas.QuotaSettingsFactory"
  import="org.apache.hadoop.hbase.quotas.QuotaTableUtil"
  import="org.apache.hadoop.hbase.NotAllMetaRegionsOnlineException" %>
<%@ page import="org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot" %>
<%@ page import="org.apache.hadoop.hbase.quotas.ThrottleSettings" %>
<%@ page import="org.apache.hadoop.hbase.util.Bytes" %>
<%@ page import="org.apache.hadoop.hbase.util.FSUtils" %>
<%@ page import="org.apache.hadoop.hbase.zookeeper.MetaTableLocator" %>
<%@ page import="org.apache.hadoop.util.StringUtils" %>
<%@ page import="org.apache.hbase.thirdparty.com.google.protobuf.ByteString" %>
<%@ page import="org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos" %>
<%@ page import="org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos" %>
<%@ page import="org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas" %>
<%@ page import="org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota" %>
<%@ page import="java.util.stream.Collectors" %>
<%!
  /**
   * @return An empty region load stamped with the passed in regionInfo
   * region name.
   */
  private static RegionMetrics getEmptyRegionMetrics(final RegionInfo regionInfo) {
    return RegionMetricsBuilder.toRegionMetrics(ClusterStatusProtos.RegionLoad.newBuilder().
            setRegionSpecifier(HBaseProtos.RegionSpecifier.newBuilder().
                    setType(HBaseProtos.RegionSpecifier.RegionSpecifierType.REGION_NAME).
                    setValue(ByteString.copyFrom(regionInfo.getRegionName())).build()).build());
  }

  /**
   * Given dicey information that may or not be available in meta, render a link to the region on
   * its region server.
   * @return an anchor tag if one can be built, {@code null} otherwise.
   */
  private static String buildRegionLink(final ServerName serverName, final int rsInfoPort,
    final RegionInfo regionInfo, final RegionState.State regionState) {
    if (serverName == null || regionInfo == null) { return null; }

    if (regionState != RegionState.State.OPEN) {
      // region is assigned to RS, but RS knows nothing of it. don't bother with a link.
      return serverName.getServerName();
    }

    final String socketAddress = serverName.getHostname() + ":" + rsInfoPort;
    final String URI = "//" + socketAddress + "/region.jsp"
      + "?name=" + regionInfo.getEncodedName();
    return "" + serverName.getServerName() + "";
  }

  /**
   * Render an  tag contents server name which the given region deploys.
   * Links to the server rs-status page.
   * not deployed instead if can not find the deploy message.
   * @return an  tag contents server name links to server rs-status page.
   */
  private static String buildRegionDeployedServerTag(RegionInfo regionInfo, HMaster master,
    Map regionsToServer) {
    ServerName serverName = regionsToServer.get(regionInfo);

    if (serverName == null) {
      return "not deployed";
    }

    String hostName = serverName.getHostname();
    String hostNameEncoded = URLEncoder.encode(hostName);
    // This port might be wrong if RS actually ended up using something else.
    int serverInfoPort = master.getRegionServerInfoPort(serverName);
    String urlRegionServer = "//" + hostNameEncoded + ":" + serverInfoPort + "/rs-status";

    return "" + StringEscapeUtils.escapeHtml4(hostName)
      + ":" + serverInfoPort + "";
  }

  /**
   * @return an 

tag guide user to see all region messages. */ private static String moreRegionsToRender(int numRegionsRendered, int numRegions, String fqtn) { if (numRegions > numRegionsRendered) { String allRegionsUrl = "?name=" + URLEncoder.encode(fqtn) + "&numRegions=all"; return "This table has " + numRegions + " regions in total, in order to improve the page load time, only " + numRegionsRendered + " regions are displayed here, click here to see all regions.

"; } return ""; } %> <% final String ZEROMB = "0 MB"; HMaster master = (HMaster)getServletContext().getAttribute(HMaster.MASTER); Configuration conf = master.getConfiguration(); String fqtn = request.getParameter("name"); final String escaped_fqtn = StringEscapeUtils.escapeHtml4(fqtn); Table table = master.getConnection().getTable(TableName.valueOf(fqtn)); boolean showFragmentation = conf.getBoolean("hbase.master.ui.fragmentation.enabled", false); boolean readOnly = !InfoServer.canUserModifyUI(request, getServletContext(), conf); int numMetaReplicas = master.getTableDescriptors().get(TableName.META_TABLE_NAME).getRegionReplication(); Map frags = null; if (showFragmentation) { frags = FSUtils.getTableFragmentation(master); } boolean quotasEnabled = conf.getBoolean("hbase.quota.enabled", false); String action = request.getParameter("action"); String key = request.getParameter("key"); String left = request.getParameter("left"); String right = request.getParameter("right"); long totalStoreFileSizeMB = 0; final String numRegionsParam = request.getParameter("numRegions"); // By default, the page render up to 10000 regions to improve the page load time int numRegionsToRender = 10000; if (numRegionsParam != null) { // either 'all' or a number if (numRegionsParam.equals("all")) { numRegionsToRender = -1; } else { try { numRegionsToRender = Integer.parseInt(numRegionsParam); } catch (NumberFormatException ex) { // ignore } } } int numRegions = 0; String pageTitle; if ( !readOnly && action != null ) { pageTitle = "HBase Master: " + StringEscapeUtils.escapeHtml4(master.getServerName().toString()); } else { pageTitle = "Table: " + escaped_fqtn; } pageContext.setAttribute("pageTitle", pageTitle); final AsyncConnection connection = master.getAsyncConnection(); final AsyncAdmin admin = connection.getAdminBuilder() .setOperationTimeout(5, TimeUnit.SECONDS) .build(); final MetaBrowser metaBrowser = new MetaBrowser(connection, request); %> <% // handle the case for fqtn is null or master is not initialized with error message + redirect if (fqtn == null || ! master.isInitialized()) { %>


<% return; } %> <% // unknow table if (! admin.tableExists(TableName.valueOf(fqtn)).get()) { %>


<% return; } %> <% // table split/major compact/compact/merge actions if ( !readOnly && action != null ) { %>


<% if (action.equals("split")) { if (key != null && key.length() > 0) { admin.split(TableName.valueOf(fqtn), Bytes.toBytes(key)); } else { admin.split(TableName.valueOf(fqtn)); } %> Split request accepted. <% } else if (action.equals("major compact")) { if (key != null && key.length() > 0) { List regions = admin.getRegions(TableName.valueOf(fqtn)).get(); byte[] row = Bytes.toBytes(key); for (RegionInfo region : regions) { if (region.containsRow(row)) { admin.majorCompactRegion(region.getRegionName()); } } } else { admin.majorCompact(TableName.valueOf(fqtn)); } %> major Compact request accepted. <% } else if (action.equals("compact")) { if (key != null && key.length() > 0) { List regions = admin.getRegions(TableName.valueOf(fqtn)).get(); byte[] row = Bytes.toBytes(key); for (RegionInfo region : regions) { if (region.containsRow(row)) { admin.compactRegion(region.getRegionName()); } } } else { admin.compact(TableName.valueOf(fqtn)); } %> Compact request accepted. <% } else if (action.equals("merge")) { if (left != null && left.length() > 0 && right != null && right.length() > 0) { admin.mergeRegions(Bytes.toBytesBinary(left), Bytes.toBytesBinary(right), false); } %> Merge request accepted. <% } %>

<% return; } %>
<% //Meta table. if(fqtn.equals(TableName.META_TABLE_NAME.getNameAsString())) { %>

Table Regions

<% // NOTE: Presumes meta with one or more replicas for (int j = 0; j < numMetaReplicas; j++) { RegionInfo meta = RegionReplicaUtil.getRegionInfoForReplica( RegionInfoBuilder.FIRST_META_REGIONINFO, j); //If a metaLocation is null, All of its info would be empty here to be displayed. RegionStateNode rsn = master.getAssignmentManager().getRegionStates() .getRegionStateNode(meta); ServerName metaLocation = rsn != null ? rsn.getRegionLocation() : null; for (int i = 0; i < 1; i++) { //If metaLocation is null, default value below would be displayed in UI. String hostAndPort = ""; String readReq = "N/A"; String writeReq = "N/A"; String fileSize = ZEROMB; String fileCount = "N/A"; String memSize = ZEROMB; if (metaLocation != null) { ServerMetrics sl = master.getServerManager().getLoad(metaLocation); // The host name portion should be safe, but I don't know how we handle IDNs so err on the side of failing safely. hostAndPort = URLEncoder.encode(metaLocation.getHostname()) + ":" + master.getRegionServerInfoPort(metaLocation); if (sl != null) { Map map = sl.getRegionMetrics(); if (map.containsKey(meta.getRegionName())) { RegionMetrics load = map.get(meta.getRegionName()); readReq = String.format("%,1d", load.getReadRequestCount()); writeReq = String.format("%,1d", load.getWriteRequestCount()); double rSize = load.getStoreFileSize().get(Size.Unit.BYTE); if (rSize > 0) { fileSize = StringUtils.byteDesc((long) rSize); } fileCount = String.format("%,1d", load.getStoreFileCount()); double mSize = load.getMemStoreSize().get(Size.Unit.BYTE); if (mSize > 0) { memSize = StringUtils.byteDesc((long)mSize); } } } } %> <% } %> <%} %>
Name Region Server ReadRequests WriteRequests StorefileSize Num.Storefiles MemSize Start Key End Key ReplicaID
<%= escapeXml(meta.getRegionNameAsString()) %> <%= StringEscapeUtils.escapeHtml4(hostAndPort) %> <%= readReq%> <%= writeReq%> <%= fileSize%> <%= fileCount%> <%= memSize%> <%= escapeXml(Bytes.toString(meta.getStartKey())) %> <%= escapeXml(Bytes.toString(meta.getEndKey())) %> <%= meta.getReplicaId() %>
<% // NOTE: Presumes meta with one or more replicas for (int j = 0; j < numMetaReplicas; j++) { RegionInfo meta = RegionReplicaUtil.getRegionInfoForReplica( RegionInfoBuilder.FIRST_META_REGIONINFO, j); //If a metaLocation is null, All of its info would be empty here to be displayed. RegionStateNode rsn = master.getAssignmentManager().getRegionStates() .getRegionStateNode(meta); ServerName metaLocation = rsn != null ? rsn.getRegionLocation() : null; for (int i = 0; i < 1; i++) { //If metaLocation is null, default value below would be displayed in UI. String hostAndPort = ""; float locality = 0.0f; float localityForSsd = 0.0f; if (metaLocation != null) { ServerMetrics sl = master.getServerManager().getLoad(metaLocation); hostAndPort = URLEncoder.encode(metaLocation.getHostname()) + ":" + master.getRegionServerInfoPort(metaLocation); if (sl != null) { Map map = sl.getRegionMetrics(); if (map.containsKey(meta.getRegionName())) { RegionMetrics load = map.get(meta.getRegionName()); locality = load.getDataLocality(); localityForSsd = load.getDataLocalityForSsd(); } } } %> <% } %> <%} %>
Name Region Server Locality LocalityForSsd
<%= escapeXml(meta.getRegionNameAsString()) %> <%= StringEscapeUtils.escapeHtml4(hostAndPort) %> <%= locality%> <%= localityForSsd%>
<% // NOTE: Presumes meta with one or more replicas for (int j = 0; j < numMetaReplicas; j++) { RegionInfo meta = RegionReplicaUtil.getRegionInfoForReplica( RegionInfoBuilder.FIRST_META_REGIONINFO, j); //If a metaLocation is null, All of its info would be empty here to be displayed. RegionStateNode rsn = master.getAssignmentManager().getRegionStates() .getRegionStateNode(meta); ServerName metaLocation = rsn != null ? rsn.getRegionLocation() : null; for (int i = 0; i < 1; i++) { //If metaLocation is null, default value below would be displayed in UI. String hostAndPort = ""; long compactingCells = 0; long compactedCells = 0; String compactionProgress = ""; if (metaLocation != null) { ServerMetrics sl = master.getServerManager().getLoad(metaLocation); hostAndPort = URLEncoder.encode(metaLocation.getHostname()) + ":" + master.getRegionServerInfoPort(metaLocation); if (sl != null) { Map map = sl.getRegionMetrics(); if (map.containsKey(meta.getRegionName())) { RegionMetrics load = map.get(meta.getRegionName()); compactingCells = load.getCompactingCellCount(); compactedCells = load.getCompactedCellCount(); if (compactingCells > 0) { compactionProgress = String.format("%.2f", 100 * ((float) compactedCells / compactingCells)) + "%"; } } } } %> <% } %> <%} %>
Name Region Server Num. Compacting Cells Num. Compacted Cells Remaining Cells Compaction Progress
<%= escapeXml(meta.getRegionNameAsString()) %> <%= StringEscapeUtils.escapeHtml4(hostAndPort) %> <%= String.format("%,1d", compactingCells)%> <%= String.format("%,1d", compactedCells)%> <%= String.format("%,1d", compactingCells - compactedCells)%> <%= compactionProgress%>

Meta Entries

<% if (!metaBrowser.getErrorMessages().isEmpty()) { for (final String errorMessage : metaBrowser.getErrorMessages()) { %> <% } } String regionInfoColumnName = HConstants.CATALOG_FAMILY_STR + ":" + HConstants.REGIONINFO_QUALIFIER_STR; String serverColumnName = HConstants.CATALOG_FAMILY_STR + ":" + HConstants.SERVER_QUALIFIER_STR; String startCodeColumnName = HConstants.CATALOG_FAMILY_STR + ":" + HConstants.STARTCODE_QUALIFIER_STR; String serverNameColumnName = HConstants.CATALOG_FAMILY_STR + ":" + HConstants.SERVERNAME_QUALIFIER_STR; String seqNumColumnName = HConstants.CATALOG_FAMILY_STR + ":" + HConstants.SEQNUM_QUALIFIER_STR; %>
<% final boolean metaScanHasMore; byte[] lastRow = null; try (final MetaBrowser.Results results = metaBrowser.getResults()) { for (final RegionReplicaInfo regionReplicaInfo : results) { lastRow = Optional.ofNullable(regionReplicaInfo) .map(RegionReplicaInfo::getRow) .orElse(null); if (regionReplicaInfo == null) { %> <% continue; } final String regionNameDisplay = regionReplicaInfo.getRegionName() != null ? Bytes.toStringBinary(regionReplicaInfo.getRegionName()) : ""; final String startKeyDisplay = regionReplicaInfo.getStartKey() != null ? Bytes.toStringBinary(regionReplicaInfo.getStartKey()) : ""; final String endKeyDisplay = regionReplicaInfo.getEndKey() != null ? Bytes.toStringBinary(regionReplicaInfo.getEndKey()) : ""; final String replicaIdDisplay = regionReplicaInfo.getReplicaId() != null ? regionReplicaInfo.getReplicaId().toString() : ""; final String regionStateDisplay = regionReplicaInfo.getRegionState() != null ? regionReplicaInfo.getRegionState().toString() : ""; final RegionInfo regionInfo = regionReplicaInfo.getRegionInfo(); final ServerName serverName = regionReplicaInfo.getServerName(); final RegionState.State regionState = regionReplicaInfo.getRegionState(); final int rsPort = master.getRegionServerInfoPort(serverName); final long seqNum = regionReplicaInfo.getSeqNum(); final String regionSpanFormat = "%s"; final String targetServerName = regionReplicaInfo.getTargetServerName().toString(); final Map mergeRegions = regionReplicaInfo.getMergeRegionInfo(); final String mergeRegionNames = (mergeRegions == null) ? "" : mergeRegions.entrySet().stream() .map(entry -> String.format(regionSpanFormat, entry.getKey(), entry.getValue().getRegionNameAsString())) .collect(Collectors.joining("
")); final Map splitRegions = regionReplicaInfo.getSplitRegionInfo(); final String splitName = (splitRegions == null) ? "" : splitRegions.entrySet().stream() .map(entry -> String.format(regionSpanFormat, entry.getKey(), entry.getValue().getRegionNameAsString())) .collect(Collectors.joining("
")); %>
<% } metaScanHasMore = results.hasMoreResults(); } %>
RegionName Start Key End Key Replica ID RegionState Server Sequence Number Target Server info:merge* info:split*
Null result
<%= regionNameDisplay %> <%= startKeyDisplay %> <%= endKeyDisplay %> <%= replicaIdDisplay %> <%= regionStateDisplay %> "><%= buildRegionLink(serverName, rsPort, regionInfo, regionState) %> <%= seqNum %> <%= targetServerName %> <%= mergeRegionNames %> <%= splitName %>
  • > aria-label="Next">
aria-describedby="scan-limit" style="display:inline; width:auto" /> aria-describedby="scan-filter-table" style="display:inline; width:auto" />
<%} else { //Common tables RegionStates states = master.getAssignmentManager().getRegionStates(); Map> regionStates = states.getRegionByStateOfTable(table.getName()); Map stateMap = new HashMap<>(); for (RegionState.State regionState : regionStates.keySet()) { for (RegionInfo regionInfo : regionStates.get(regionState)) { stateMap.put(regionInfo.getEncodedName(), regionState); } } RegionLocator r = master.getConnection().getRegionLocator(table.getName()); try { %>

Table Attributes

<% if (showFragmentation) { %> <% } %> <% if (quotasEnabled) { TableName tn = TableName.valueOf(fqtn); SpaceQuotaSnapshot masterSnapshot = null; Quotas quota = QuotaTableUtil.getTableQuota(master.getConnection(), tn); if (quota == null || !quota.hasSpace()) { quota = QuotaTableUtil.getNamespaceQuota(master.getConnection(), tn.getNamespaceAsString()); if (quota != null) { masterSnapshot = master.getQuotaObserverChore().getNamespaceQuotaSnapshots() .get(tn.getNamespaceAsString()); } } else { masterSnapshot = master.getQuotaObserverChore().getTableQuotaSnapshots().get(tn); } if (quota != null && quota.hasSpace()) { SpaceQuota spaceQuota = quota.getSpace(); %> <% } if (quota != null && quota.hasThrottle()) { List throttles = QuotaSettingsFactory.fromTableThrottles(table.getName(), quota.getThrottle()); if (throttles.size() > 0) { %> <% } } } %>
Attribute Name Value Description
Enabled <%= master.getTableStateManager().isTableState(table.getName(), TableState.State.ENABLED) %> Is the table enabled
Compaction <% if (master.getTableStateManager().isTableState(table.getName(), TableState.State.ENABLED)) { CompactionState compactionState = master.getCompactionState(table.getName()); %><%= compactionState==null?"UNKNOWN":compactionState %><% } else { %><%= CompactionState.NONE %><% } %> 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%.
Space Quota <% if (masterSnapshot != null) { %> <% } %>
Property Value
Limit <%= StringUtils.byteDesc(spaceQuota.getSoftLimit()) %>
Policy <%= spaceQuota.getViolationPolicy() %>
Usage <%= StringUtils.byteDesc(masterSnapshot.getUsage()) %>
State <%= masterSnapshot.getQuotaStatus().isInViolation() ? "In Violation" : "In Observance" %>
Information about a Space Quota on this table, if set.
Throttle Quota <% for (ThrottleSettings throttle : throttles) { %> <% } %>
Limit Type TimeUnit Scope
<%= throttle.getSoftLimit() %> <%= throttle.getThrottleType() %> <%= throttle.getTimeUnit() %> <%= throttle.getQuotaScope() %>
Information about a Throttle Quota on this table, if set.

Table Schema

<% ColumnFamilyDescriptor[] families = table.getDescriptor().getColumnFamilies(); Set familyKeySet = new HashSet<>(); for (ColumnFamilyDescriptor family: families) { familyKeySet.addAll(family.getValues().keySet()); } %> <% for (ColumnFamilyDescriptor family: families) { %> <% } %> <% for (Bytes familyKey: familyKeySet) { %> <% for (ColumnFamilyDescriptor family: families) { String familyValue = "-"; if(family.getValues().containsKey(familyKey)){ familyValue = family.getValues().get(familyKey).toString(); } %> <% } %> <% } %>
Property \ Column Family Name <%= StringEscapeUtils.escapeHtml4(family.getNameAsString()) %>
<%= StringEscapeUtils.escapeHtml4(familyKey.toString()) %> <%= StringEscapeUtils.escapeHtml4(familyValue) %>
<% long totalReadReq = 0; long totalWriteReq = 0; long totalSize = 0; long totalStoreFileCount = 0; long totalMemSize = 0; long totalCompactingCells = 0; long totalCompactedCells = 0; long totalBlocksTotalWeight = 0; long totalBlocksLocalWeight = 0; long totalBlocksLocalWithSsdWeight = 0; String totalCompactionProgress = ""; String totalMemSizeStr = ZEROMB; String totalSizeStr = ZEROMB; String totalLocality = ""; String totalLocalityForSsd = ""; Map regDistribution = new TreeMap<>(); Map primaryRegDistribution = new TreeMap<>(); List regions = r.getAllRegionLocations(); Map regionsToLoad = new LinkedHashMap<>(); Map regionsToServer = new LinkedHashMap<>(); for (HRegionLocation hriEntry : regions) { RegionInfo regionInfo = hriEntry.getRegion(); ServerName addr = hriEntry.getServerName(); regionsToServer.put(regionInfo, addr); if (addr != null) { ServerMetrics sl = master.getServerManager().getLoad(addr); if (sl != null) { RegionMetrics regionMetrics = sl.getRegionMetrics().get(regionInfo.getRegionName()); regionsToLoad.put(regionInfo, regionMetrics); if (regionMetrics != null) { totalReadReq += regionMetrics.getReadRequestCount(); totalWriteReq += regionMetrics.getWriteRequestCount(); totalSize += regionMetrics.getStoreFileSize().get(Size.Unit.MEGABYTE); totalStoreFileCount += regionMetrics.getStoreFileCount(); totalMemSize += regionMetrics.getMemStoreSize().get(Size.Unit.MEGABYTE); totalStoreFileSizeMB += regionMetrics.getStoreFileSize().get(Size.Unit.MEGABYTE); totalCompactingCells += regionMetrics.getCompactingCellCount(); totalCompactedCells += regionMetrics.getCompactedCellCount(); totalBlocksTotalWeight += regionMetrics.getBlocksTotalWeight(); totalBlocksLocalWeight += regionMetrics.getBlocksLocalWeight(); totalBlocksLocalWithSsdWeight += regionMetrics.getBlocksLocalWithSsdWeight(); } else { RegionMetrics load0 = getEmptyRegionMetrics(regionInfo); regionsToLoad.put(regionInfo, load0); } } else{ RegionMetrics load0 = getEmptyRegionMetrics(regionInfo); regionsToLoad.put(regionInfo, load0); } } else { RegionMetrics load0 = getEmptyRegionMetrics(regionInfo); regionsToLoad.put(regionInfo, load0); } } if (totalSize > 0) { totalSizeStr = StringUtils.byteDesc(totalSize*1024l*1024); } if (totalMemSize > 0) { totalMemSizeStr = StringUtils.byteDesc(totalMemSize*1024l*1024); } if (totalCompactingCells > 0) { totalCompactionProgress = String.format("%.2f", 100 * ((float) totalCompactedCells / totalCompactingCells)) + "%"; } if (totalBlocksTotalWeight > 0) { totalLocality = String.format("%.1f", ((float) totalBlocksLocalWeight / totalBlocksTotalWeight)); totalLocalityForSsd = String.format("%.1f", ((float) totalBlocksLocalWithSsdWeight / totalBlocksTotalWeight)); } if(regions != null && regions.size() > 0) { %>

Table Regions

<% List> entryList = new ArrayList<>(regionsToLoad.entrySet()); numRegions = regions.size(); int numRegionsRendered = 0; // render all regions if (numRegionsToRender < 0) { numRegionsToRender = numRegions; } for (Map.Entry hriEntry : entryList) { RegionInfo regionInfo = hriEntry.getKey(); ServerName addr = regionsToServer.get(regionInfo); RegionMetrics load = hriEntry.getValue(); String readReq = "N/A"; String writeReq = "N/A"; String regionSize = ZEROMB; String fileCount = "N/A"; String memSize = ZEROMB; String state = "N/A"; if (load != null) { readReq = String.format("%,1d", load.getReadRequestCount()); writeReq = String.format("%,1d", load.getWriteRequestCount()); double rSize = load.getStoreFileSize().get(Size.Unit.BYTE); if (rSize > 0) { regionSize = StringUtils.byteDesc((long)rSize); } fileCount = String.format("%,1d", load.getStoreFileCount()); double mSize = load.getMemStoreSize().get(Size.Unit.BYTE); if (mSize > 0) { memSize = StringUtils.byteDesc((long)mSize); } } if (stateMap.containsKey(regionInfo.getEncodedName())) { state = stateMap.get(regionInfo.getEncodedName()).toString(); } if (addr != null) { ServerMetrics sl = master.getServerManager().getLoad(addr); if(sl != null) { Integer i = regDistribution.get(addr); if (null == i) i = Integer.valueOf(0); regDistribution.put(addr, i + 1); if (RegionReplicaUtil.isDefaultReplica(regionInfo.getReplicaId())) { i = primaryRegDistribution.get(addr); if (null == i) i = Integer.valueOf(0); primaryRegDistribution.put(addr, i+1); } } } if (numRegionsRendered < numRegionsToRender) { numRegionsRendered++; %> <%= buildRegionDeployedServerTag(regionInfo, master, regionsToServer) %> <% } %> <% } %>
Name(<%= String.format("%,1d", regions.size())%>) Region Server ReadRequests
(<%= String.format("%,1d", totalReadReq)%>)
WriteRequests
(<%= String.format("%,1d", totalWriteReq)%>)
StorefileSize
(<%= totalSizeStr %>)
Num.Storefiles
(<%= String.format("%,1d", totalStoreFileCount)%>)
MemSize
(<%= totalMemSizeStr %>)
Start Key End Key Region State ReplicaID
<%= escapeXml(Bytes.toStringBinary(regionInfo.getRegionName())) %><%= readReq%> <%= writeReq%> <%= regionSize%> <%= fileCount%> <%= memSize%> <%= escapeXml(Bytes.toStringBinary(regionInfo.getStartKey()))%> <%= escapeXml(Bytes.toStringBinary(regionInfo.getEndKey()))%> <%= state%> <%= regionInfo.getReplicaId() %>
<%= moreRegionsToRender(numRegionsRendered, numRegions, fqtn) %>
<% numRegionsRendered = 0; for (Map.Entry hriEntry : entryList) { RegionInfo regionInfo = hriEntry.getKey(); ServerName addr = regionsToServer.get(regionInfo); RegionMetrics load = hriEntry.getValue(); float locality = 0.0f; float localityForSsd = 0.0f; String state = "N/A"; if (load != null) { locality = load.getDataLocality(); localityForSsd = load.getDataLocalityForSsd(); } if (numRegionsRendered < numRegionsToRender) { numRegionsRendered++; %> <%= buildRegionDeployedServerTag(regionInfo, master, regionsToServer) %> <% } %> <% } %>
Name(<%= String.format("%,1d", regions.size())%>) Region Server Locality
(<%= totalLocality %>)
LocalityForSsd
(<%= totalLocalityForSsd %>)
<%= escapeXml(Bytes.toStringBinary(regionInfo.getRegionName())) %><%= locality%> <%= localityForSsd%>
<%= moreRegionsToRender(numRegionsRendered, numRegions, fqtn) %>
<% numRegionsRendered = 0; for (Map.Entry hriEntry : entryList) { RegionInfo regionInfo = hriEntry.getKey(); ServerName addr = regionsToServer.get(regionInfo); RegionMetrics load = hriEntry.getValue(); long compactingCells = 0; long compactedCells = 0; String compactionProgress = ""; if (load != null) { compactingCells = load.getCompactingCellCount(); compactedCells = load.getCompactedCellCount(); if (compactingCells > 0) { compactionProgress = String.format("%.2f", 100 * ((float) compactedCells / compactingCells)) + "%"; } } if (numRegionsRendered < numRegionsToRender) { numRegionsRendered++; %> <%= buildRegionDeployedServerTag(regionInfo, master, regionsToServer) %> <% } %> <% } %>
Name(<%= String.format("%,1d", regions.size())%>) Region Server Num. Compacting Cells
(<%= String.format("%,1d", totalCompactingCells)%>)
Num. Compacted Cells
(<%= String.format("%,1d", totalCompactedCells)%>)
Remaining Cells
(<%= String.format("%,1d", totalCompactingCells-totalCompactedCells)%>)
Compaction Progress
(<%= totalCompactionProgress %>)
<%= escapeXml(Bytes.toStringBinary(regionInfo.getRegionName())) %><%= String.format("%,1d", compactingCells)%> <%= String.format("%,1d", compactedCells)%> <%= String.format("%,1d", compactingCells - compactedCells)%> <%= compactionProgress%>
<%= moreRegionsToRender(numRegionsRendered, numRegions, fqtn) %>

Regions by Region Server

<% for (Map.Entry rdEntry : regDistribution.entrySet()) { ServerName addr = rdEntry.getKey(); String url = "//" + URLEncoder.encode(addr.getHostname()) + ":" + master.getRegionServerInfoPort(addr) + "/rs-status"; %> <% } %>
Region ServerRegion CountPrimary Region Count
<%= StringEscapeUtils.escapeHtml4(addr.getHostname().toString()) + ":" + master.getRegionServerInfoPort(addr) %> <%= rdEntry.getValue()%> <%= primaryRegDistribution.get(addr) == null ? 0 : primaryRegDistribution.get(addr)%>
<% } } catch(Exception ex) { %> Unknown Issue with Regions




© 2015 - 2024 Weber Informatics LLC | Privacy Policy