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

org.apache.hadoop.hbase.generated.master.table_jsp Maven / Gradle / Ivy

There is a newer version: 3.0.0-beta-1
Show newest version
package org.apache.hadoop.hbase.generated.master;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import static org.apache.commons.lang3.StringEscapeUtils.escapeXml;
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.Optional;
import java.util.TreeMap;
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.HRegionLocation;
import org.apache.hadoop.hbase.HTableDescriptor;
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.CompactionState;
import org.apache.hadoop.hbase.client.ConnectionFactory;
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.http.InfoServer;
import org.apache.hadoop.hbase.master.HMaster;
import org.apache.hadoop.hbase.master.RegionState;
import org.apache.hadoop.hbase.master.assignment.RegionStates;
import org.apache.hadoop.hbase.master.webapp.MetaBrowser;
import org.apache.hadoop.hbase.master.webapp.RegionReplicaInfo;
import org.apache.hadoop.hbase.quotas.QuotaSettingsFactory;
import org.apache.hadoop.hbase.quotas.QuotaTableUtil;
import org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot;
import org.apache.hadoop.hbase.quotas.ThrottleSettings;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.hbase.util.FSUtils;
import org.apache.hadoop.hbase.zookeeper.MetaTableLocator;
import org.apache.hadoop.util.StringUtils;
import org.apache.hbase.thirdparty.com.google.protobuf.ByteString;
import org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos;
import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos;
import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.Quotas;
import org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.SpaceQuota;
import java.net.URLEncoder;
import java.util.stream.Collectors;

public final class table_jsp extends org.apache.jasper.runtime.HttpJspBase
    implements org.apache.jasper.runtime.JspSourceDependent {


  /**
   * @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 buildRegionServerLink(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() + "";
  }

  private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();

  private static java.util.List _jspx_dependants;

  private org.glassfish.jsp.api.ResourceInjector _jspx_resourceInjector;

  public java.util.List getDependants() {
    return _jspx_dependants;
  }

  public void _jspService(HttpServletRequest request, HttpServletResponse response)
        throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;

    try {
      response.setContentType("text/html;charset=UTF-8");
      pageContext = _jspxFactory.getPageContext(this, request, response,
      			null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;
      _jspx_resourceInjector = (org.glassfish.jsp.api.ResourceInjector) application.getAttribute("com.sun.appserv.jsp.resource.injector");

      out.write("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
      out.write('\n');

  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;
  boolean withReplica = false;
  boolean showFragmentation = conf.getBoolean("hbase.master.ui.fragmentation.enabled", false);
  boolean readOnly = !InfoServer.canUserModifyUI(request, getServletContext(), conf);
  int numMetaReplicas = conf.getInt(HConstants.META_REPLICAS_NUM,
          HConstants.DEFAULT_META_REPLICA_NUM);
  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 = ConnectionFactory.createAsyncConnection(master.getConfiguration()).get();
  final AsyncAdmin admin = connection.getAdminBuilder()
    .setOperationTimeout(5, TimeUnit.SECONDS)
    .build();
  final MetaBrowser metaBrowser = new MetaBrowser(connection, request);

      out.write('\n');
      out.write('\n');
      org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "header.jsp" + "?" + org.apache.jasper.runtime.JspRuntimeLibrary.URLEncode("pageTitle", request.getCharacterEncoding())+ "=" + org.apache.jasper.runtime.JspRuntimeLibrary.URLEncode((java.lang.String) org.apache.jasper.runtime.PageContextImpl.evaluateExpression("${pageTitle}", java.lang.String.class, (PageContext)_jspx_page_context, null), request.getCharacterEncoding()), out, false);
      out.write('\n');
      out.write('\n');

  if (fqtn != null && master.isInitialized()) {
    try {
      table = master.getConnection().getTable(TableName.valueOf(fqtn));
      if (table.getTableDescriptor().getRegionReplication() > 1) {
        withReplica = true;
      }
      if ( !readOnly && action != null ) {

      out.write("\n
\n
\n
\n

Table action request accepted

\n
\n
\n


\n "); if (action.equals("split")) { if (key != null && key.length() > 0) { admin.split(TableName.valueOf(fqtn), Bytes.toBytes(key)); } else { admin.split(TableName.valueOf(fqtn)); } out.write(" Split 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)); } out.write(" 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); } out.write(" Merge request accepted. "); } out.write("\n "); org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "redirect.jsp", out, false); out.write("\n

\n"); } else { out.write("\n
\n
\n
\n

Table "); out.print( escaped_fqtn ); out.write("

\n
\n
\n
\n "); if(fqtn.equals(TableName.META_TABLE_NAME.getNameAsString())) { out.write("\n

Table Regions

\n
\n \n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n "); if (withReplica) { out.write("\n \n "); } out.write("\n \n \n \n "); // NOTE: Presumes meta with one or more replicas for (int j = 0; j < numMetaReplicas; j++) { RegionInfo meta = RegionReplicaUtil.getRegionInfoForReplica( RegionInfoBuilder.FIRST_META_REGIONINFO, j); ServerName metaLocation = MetaTableLocator.waitMetaRegionLocation(master.getZooKeeper(), j, 1); for (int i = 0; i < 1; i++) { String hostAndPort = ""; String readReq = "N/A"; String writeReq = "N/A"; String fileSize = ZEROMB; String fileCount = "N/A"; String memSize = ZEROMB; float locality = 0.0f; 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); } locality = load.getDataLocality(); } } } out.write("\n \n \n \n \n \n \n \n \n \n \n \n "); if (withReplica) { out.write("\n \n "); } out.write("\n \n "); } out.write("\n "); } out.write("\n \n
NameRegion ServerReadRequestsWriteRequestsStorefileSizeNum.StorefilesMemSizeLocalityStart KeyEnd KeyReplicaID
"); out.print( escapeXml(meta.getRegionNameAsString()) ); out.write(""); out.print( StringEscapeUtils.escapeHtml4(hostAndPort) ); out.write(""); out.print( readReq); out.write(""); out.print( writeReq); out.write(""); out.print( fileSize); out.write(""); out.print( fileCount); out.write(""); out.print( memSize); out.write(""); out.print( locality); out.write(""); out.print( escapeXml(Bytes.toString(meta.getStartKey())) ); out.write(""); out.print( escapeXml(Bytes.toString(meta.getEndKey())) ); out.write(""); out.print( meta.getReplicaId() ); out.write("
\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n "); // NOTE: Presumes meta with one or more replicas for (int j = 0; j < numMetaReplicas; j++) { RegionInfo meta = RegionReplicaUtil.getRegionInfoForReplica( RegionInfoBuilder.FIRST_META_REGIONINFO, j); ServerName metaLocation = MetaTableLocator.waitMetaRegionLocation(master.getZooKeeper(), j, 1); for (int i = 0; i < 1; i++) { 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)) + "%"; } } } } out.write("\n \n \n \n \n \n \n \n \n "); } out.write("\n "); } out.write("\n \n
NameRegion ServerNum. Compacting CellsNum. Compacted CellsRemaining CellsCompaction Progress
"); out.print( escapeXml(meta.getRegionNameAsString()) ); out.write(""); out.print( StringEscapeUtils.escapeHtml4(hostAndPort) ); out.write(""); out.print( String.format("%,1d", compactingCells)); out.write(""); out.print( String.format("%,1d", compactedCells)); out.write(""); out.print( String.format("%,1d", compactingCells - compactedCells)); out.write(""); out.print( compactionProgress); out.write("
\n
\n
\n
\n

Meta Entries

\n"); if (!metaBrowser.getErrorMessages().isEmpty()) { for (final String errorMessage : metaBrowser.getErrorMessages()) { out.write("\n
\n "); out.print( errorMessage ); out.write("\n
\n"); } } 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; out.write("\n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n"); 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) { out.write("\n \n \n \n"); 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("
")); out.write("\n
\n \n \n \n \n \n \n \n \n \n \n \n"); } metaScanHasMore = results.hasMoreResults(); } out.write("\n
RegionNameStart KeyEnd KeyReplica IDRegionStateServerSequence NumberTarget Serverinfo:merge*info:split*
Null result
'); out.print( regionNameDisplay ); out.write(""); out.print( startKeyDisplay ); out.write(""); out.print( endKeyDisplay ); out.write(""); out.print( replicaIdDisplay ); out.write(""); out.print( regionStateDisplay ); out.write("'); out.print( buildRegionServerLink(serverName, rsPort, regionInfo, regionState) ); out.write("'); out.print( seqNum ); out.write("'); out.print( targetServerName ); out.write(""); out.print( mergeRegionNames ); out.write(""); out.print( splitName ); out.write("
\n
\n
\n
\n \n
\n
\n
\n \n
\n \n \n \n \n \n \n \n
\n
\n
\n
\n "); } else { 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 { out.write("\n

Table Attributes

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n "); if (showFragmentation) { out.write("\n \n \n \n \n \n "); } out.write("\n "); 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(); out.write("\n \n \n \n \n \n "); } if (quota != null && quota.hasThrottle()) { List throttles = QuotaSettingsFactory.fromTableThrottles(table.getName(), quota.getThrottle()); if (throttles.size() > 0) { out.write("\n \n \n \n \n \n "); } } } out.write("\n
Attribute NameValueDescription
Enabled"); out.print( master.getAssignmentManager().isTableEnabled(table.getName()) ); out.write("Is the table enabled
Compaction\n "); if (master.getAssignmentManager().isTableEnabled(table.getName())) { try { CompactionState compactionState = admin.getCompactionState(table.getName()).get(); out.print( compactionState ); } catch (Exception e) { // Nothing really to do here for(StackTraceElement element : e.getStackTrace()) { out.print( StringEscapeUtils.escapeHtml4(element.toString()) ); } out.write(" Unknown "); } } else { out.print( CompactionState.NONE ); } out.write("\n Is the table compacting
Fragmentation"); out.print( frags.get(fqtn) != null ? frags.get(fqtn).intValue() + "%" : "n/a" ); out.write("How fragmented is the table. After a major compaction it is 0%.
Space Quota\n \n \n \n \n \n \n \n \n \n \n \n \n \n "); if (masterSnapshot != null) { out.write("\n \n \n \n \n \n \n \n \n "); } out.write("\n
PropertyValue
Limit"); out.print( StringUtils.byteDesc(spaceQuota.getSoftLimit()) ); out.write("
Policy"); out.print( spaceQuota.getViolationPolicy() ); out.write("
Usage"); out.print( StringUtils.byteDesc(masterSnapshot.getUsage()) ); out.write("
State"); out.print( masterSnapshot.getQuotaStatus().isInViolation() ? "In Violation" : "In Observance" ); out.write("
\n
Information about a Space Quota on this table, if set.
Throttle Quota\n \n \n \n \n \n \n \n "); for (ThrottleSettings throttle : throttles) { out.write("\n \n \n \n \n \n \n "); } out.write("\n
LimitTypeTimeUnitScope
"); out.print( throttle.getSoftLimit() ); out.write(""); out.print( throttle.getThrottleType() ); out.write(""); out.print( throttle.getTimeUnit() ); out.write(""); out.print( throttle.getQuotaScope() ); out.write("
\n
Information about a Throttle Quota on this table, if set.
\n

Table Schema

\n \n \n \n \n \n "); Collection families = table.getTableDescriptor().getFamilies(); for (HColumnDescriptor family: families) { out.write("\n \n \n \n \n "); } out.write("\n
Column Family Name
"); out.print( StringEscapeUtils.escapeHtml4(family.getNameAsString()) ); out.write("\n \n \n \n \n \n "); Map familyValues = family.getValues(); for (Bytes familyKey: familyValues.keySet()) { out.write("\n \n \n \n \n "); } out.write("\n
PropertyValue
\n "); out.print( StringEscapeUtils.escapeHtml4(familyKey.toString()) ); out.write("\n \n "); out.print( StringEscapeUtils.escapeHtml4(familyValues.get(familyKey).toString()) ); out.write("\n
\n
\n "); long totalReadReq = 0; long totalWriteReq = 0; long totalSize = 0; long totalStoreFileCount = 0; long totalMemSize = 0; long totalCompactingCells = 0; long totalCompactedCells = 0; String totalCompactionProgress = ""; String totalMemSizeStr = ZEROMB; String totalSizeStr = ZEROMB; String urlRegionServer = null; 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.getRegionInfo(); 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(); } 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(regions != null && regions.size() > 0) { out.write("\n

Table Regions

\n
\n \n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n "); if (withReplica) { out.write("\n \n "); } out.write("\n \n \n \n "); 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; float locality = 0.0f; 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); } locality = load.getDataLocality(); } if (stateMap.containsKey(regionInfo.getEncodedName())) { state = stateMap.get(regionInfo.getEncodedName()).toString(); } if (addr != null) { ServerMetrics sl = master.getServerManager().getLoad(addr); // This port might be wrong if RS actually ended up using something else. urlRegionServer = "//" + URLEncoder.encode(addr.getHostname()) + ":" + master.getRegionServerInfoPort(addr) + "/rs-status"; if(sl != null) { Integer i = regDistribution.get(addr); if (null == i) i = Integer.valueOf(0); regDistribution.put(addr, i + 1); if (withReplica && RegionReplicaUtil.isDefaultReplica(regionInfo.getReplicaId())) { i = primaryRegDistribution.get(addr); if (null == i) i = Integer.valueOf(0); primaryRegDistribution.put(addr, i+1); } } } if (numRegionsRendered < numRegionsToRender) { numRegionsRendered++; out.write("\n \n \n "); if (urlRegionServer != null) { out.write("\n \n "); } else { out.write("\n \n "); } out.write("\n \n \n \n \n \n \n \n \n \n "); if (withReplica) { out.write("\n \n "); } out.write("\n \n "); } out.write("\n "); } out.write("\n \n
Name("); out.print( String.format("%,1d", regions.size())); out.write(")Region ServerReadRequests
("); out.print( String.format("%,1d", totalReadReq)); out.write(")
WriteRequests
("); out.print( String.format("%,1d", totalWriteReq)); out.write(")
StorefileSize
("); out.print( totalSizeStr ); out.write(")
Num.Storefiles
("); out.print( String.format("%,1d", totalStoreFileCount)); out.write(")
MemSize
("); out.print( totalMemSizeStr ); out.write(")
LocalityStart KeyEnd KeyRegion StateReplicaID
"); out.print( escapeXml(Bytes.toStringBinary(regionInfo.getRegionName())) ); out.write("\n '); out.print( addr == null? "-": StringEscapeUtils.escapeHtml4(addr.getHostname().toString()) + ":" + master.getRegionServerInfoPort(addr) ); out.write("\n not deployed"); out.print( readReq); out.write(""); out.print( writeReq); out.write(""); out.print( regionSize); out.write(""); out.print( fileCount); out.write(""); out.print( memSize); out.write(""); out.print( locality); out.write(""); out.print( escapeXml(Bytes.toStringBinary(regionInfo.getStartKey()))); out.write(""); out.print( escapeXml(Bytes.toStringBinary(regionInfo.getEndKey()))); out.write(""); out.print( state); out.write(""); out.print( regionInfo.getReplicaId() ); out.write("
\n "); if (numRegions > numRegionsRendered) { String allRegionsUrl = "?name=" + URLEncoder.encode(fqtn,"UTF-8") + "&numRegions=all"; out.write("\n

This table has "); out.print( numRegions ); out.write(" regions in total, in order to improve the page load time,\n only "); out.print( numRegionsRendered ); out.write(" regions are displayed here, click\n here to see all regions.

\n "); } out.write("\n
\n
\n \n \n \n \n \n \n \n \n \n \n \n \n "); 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 (addr != null) { // This port might be wrong if RS actually ended up using something else. urlRegionServer = "//" + URLEncoder.encode(addr.getHostname()) + ":" + master.getRegionServerInfoPort(addr) + "/rs-status"; } if (numRegionsRendered < numRegionsToRender) { numRegionsRendered++; out.write("\n \n \n "); if (urlRegionServer != null) { out.write("\n \n "); } else { out.write("\n \n "); } out.write("\n \n \n \n \n \n "); } out.write("\n "); } out.write("\n \n
Name("); out.print( String.format("%,1d", regions.size())); out.write(")Region ServerNum. Compacting Cells
("); out.print( String.format("%,1d", totalCompactingCells)); out.write(")
Num. Compacted Cells
("); out.print( String.format("%,1d", totalCompactedCells)); out.write(")
Remaining Cells
("); out.print( String.format("%,1d", totalCompactingCells-totalCompactedCells)); out.write(")
Compaction Progress
("); out.print( totalCompactionProgress ); out.write(")
"); out.print( escapeXml(Bytes.toStringBinary(regionInfo.getRegionName())) ); out.write("\n '); out.print( addr == null? "-": StringEscapeUtils.escapeHtml4(addr.getHostname().toString()) + ":" + master.getRegionServerInfoPort(addr) ); out.write("\n not deployed"); out.print( String.format("%,1d", compactingCells)); out.write(""); out.print( String.format("%,1d", compactedCells)); out.write(""); out.print( String.format("%,1d", compactingCells - compactedCells)); out.write(""); out.print( compactionProgress); out.write("
\n "); if (numRegions > numRegionsRendered) { String allRegionsUrl = "?name=" + URLEncoder.encode(fqtn,"UTF-8") + "&numRegions=all"; out.write("\n

This table has "); out.print( numRegions ); out.write(" regions in total, in order to improve the page load time,\n only "); out.print( numRegionsRendered ); out.write(" regions are displayed here, click\n here to see all regions.

\n "); } out.write("\n
\n
\n
\n

Regions by Region Server

\n "); if (withReplica) { out.write("\n \n "); } else { out.write("\n
Region ServerRegion CountPrimary Region Count
\n \n "); } out.write("\n "); for (Map.Entry rdEntry : regDistribution.entrySet()) { ServerName addr = rdEntry.getKey(); String url = "//" + URLEncoder.encode(addr.getHostname()) + ":" + master.getRegionServerInfoPort(addr) + "/rs-status"; out.write("\n \n \n \n "); if (withReplica) { out.write("\n \n "); } out.write("\n \n "); } out.write("\n \n
Region ServerRegion Count
'); out.print( StringEscapeUtils.escapeHtml4(addr.getHostname().toString()) + ":" + master.getRegionServerInfoPort(addr) ); out.write(""); out.print( rdEntry.getValue()); out.write(""); out.print( primaryRegDistribution.get(addr)); out.write("
\n "); } } catch(Exception ex) { for(StackTraceElement element : ex.getStackTrace()) { out.print( StringEscapeUtils.escapeHtml4(element.toString()) ); } } finally { connection.close(); } } // end else out.write("\n\n

Table Stats

\n \n \n \n \n \n \n \n \n \n "); } else { out.write("\n 0 MB \n "); } out.write("\n \n \n
NameValueDescription
Size\n "); if (totalStoreFileSizeMB > 0) { out.write("\n "); out.print( StringUtils.TraditionalBinaryPrefix. long2String(totalStoreFileSizeMB * 1024 * 1024, "B", 2)); out.write("Total size of store files
\n\n "); if (!readOnly) { out.write("\n


\n Actions:\n

\n

\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
\n \n \n \n \n This action will force a compaction of all regions of the table, or,\n if a key is supplied, only the region containing the\n given key.\n
\n \n \n \n \n This action will force a split of all eligible\n regions of the table, or, if a key is supplied, only the region containing the\n given key. An eligible region is one that does not contain any references to\n other regions. Split requests for noneligible regions will be ignored.\n
\n \n \n \n \n \n This action will merge two regions of the table, Merge requests for\n noneligible regions will be ignored.\n
\n
\n

\n "); } out.write("\n
\n
\n"); } } catch(TableNotFoundException e) { out.write("\n
\n
\n
\n

Table not found

\n
\n
\n


\n

Go Back\n

"); } catch(IllegalArgumentException e) { out.write("\n
\n
\n
\n

Table qualifier must not be empty

\n
\n
\n


\n

Go Back\n

"); } } else { // handle the case for fqtn is null or master is not initialized with error message + redirect out.write("\n
\n
\n
\n

Table not ready

\n
\n
\n


\n "); org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "redirect.jsp", out, false); out.write("\n

\n"); } out.write('\n'); out.write('\n'); org.apache.jasper.runtime.JspRuntimeLibrary.include(request, response, "footer.jsp", out, false); out.write("\n\n\n\n\n\n"); } catch (Throwable t) { if (!(t instanceof SkipPageException)){ out = _jspx_out; if (out != null && out.getBufferSize() != 0) out.clearBuffer(); if (_jspx_page_context != null) _jspx_page_context.handlePageException(t); else throw new ServletException(t); } } finally { _jspxFactory.releasePageContext(_jspx_page_context); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy