From c6ad71e25666d4606e0cdaf4b411b1c005b463d6 Mon Sep 17 00:00:00 2001 From: Baiqiang Zhao Date: Tue, 19 Nov 2019 16:21:36 +0800 Subject: [PATCH] HBASE-23278 Add a table-level compaction progress display on the UI (#816) Signed-off-by: Guangxu Cheng --- .../resources/hbase-webapps/master/table.jsp | 1511 ++++++++++------- 1 file changed, 859 insertions(+), 652 deletions(-) diff --git a/hbase-server/src/main/resources/hbase-webapps/master/table.jsp b/hbase-server/src/main/resources/hbase-webapps/master/table.jsp index c7701269f86..64165103889 100644 --- a/hbase-server/src/main/resources/hbase-webapps/master/table.jsp +++ b/hbase-server/src/main/resources/hbase-webapps/master/table.jsp @@ -19,41 +19,42 @@ --%> <%@page import="java.net.URLEncoder"%> <%@ page contentType="text/html;charset=UTF-8" - import="static org.apache.commons.lang3.StringEscapeUtils.escapeXml" - import="java.util.ArrayList" - import="java.util.Collection" - import="java.util.LinkedHashMap" - import="java.util.List" - import="java.util.Map" - 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.ServerName" - 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.master.HMaster" - 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="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.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.ServerName" + 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.master.HMaster" + 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"%> <%@ 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" %> @@ -62,6 +63,8 @@ <%@ page import="org.apache.hadoop.hbase.RegionMetrics" %> <%@ page import="org.apache.hadoop.hbase.Size" %> <%@ page import="org.apache.hadoop.hbase.RegionMetricsBuilder" %> +<%@ page import="org.apache.hadoop.hbase.master.assignment.RegionStates" %> +<%@ page import="org.apache.hadoop.hbase.master.RegionState" %> <%! /** * @return An empty region load stamped with the passed in regionInfo @@ -87,10 +90,10 @@ boolean showFragmentation = conf.getBoolean("hbase.master.ui.fragmentation.enabled", false); boolean readOnly = conf.getBoolean("hbase.master.ui.readonly", false); int numMetaReplicas = conf.getInt(HConstants.META_REPLICAS_NUM, - HConstants.DEFAULT_META_REPLICA_NUM); + HConstants.DEFAULT_META_REPLICA_NUM); Map frags = null; if (showFragmentation) { - frags = FSUtils.getTableFragmentation(master); + frags = FSUtils.getTableFragmentation(master); } boolean quotasEnabled = conf.getBoolean("hbase.quota.enabled", false); String action = request.getParameter("action"); @@ -118,9 +121,9 @@ String pageTitle; if ( !readOnly && action != null ) { - pageTitle = "HBase Master: " + StringEscapeUtils.escapeHtml4(master.getServerName().toString()); + pageTitle = "HBase Master: " + StringEscapeUtils.escapeHtml4(master.getServerName().toString()); } else { - pageTitle = "Table: " + escaped_fqtn; + pageTitle = "Table: " + escaped_fqtn; } pageContext.setAttribute("pageTitle", pageTitle); AsyncConnection connection = ConnectionFactory.createAsyncConnection(master.getConfiguration()).get(); @@ -132,25 +135,22 @@ <% -if (fqtn != null && master.isInitialized()) { - try { - table = master.getConnection().getTable(TableName.valueOf(fqtn)); - if (table.getTableDescriptor().getRegionReplication() > 1) { - tableHeader = "

Table Regions

"; - withReplica = true; - } else { - tableHeader = "

Table Regions

NameRegion ServerReadRequestsWriteRequestsStorefileSizeNum.StorefilesMemSizeLocalityStart KeyEnd KeyReplicaID
"; - } - if ( !readOnly && action != null ) { + if (fqtn != null && master.isInitialized()) { + try { + table = master.getConnection().getTable(TableName.valueOf(fqtn)); + if (table.getTableDescriptor().getRegionReplication() > 1) { + withReplica = true; + } + if ( !readOnly && action != null ) { %>
-
- -
-


-<% +

+ +
+


+ <% if (action.equals("split")) { if (key != null && key.length() > 0) { admin.split(TableName.valueOf(fqtn), Bytes.toBytes(key)); @@ -180,458 +180,651 @@ if (fqtn != null && master.isInitialized()) { %> Merge request accepted. <% } %> - +

<% - } else { +} else { %>
-
- +
+ -
-<% - if(fqtn.equals(TableName.META_TABLE_NAME.getNameAsString())) { -%> -<%= tableHeader %> -
-<% - // 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(); - } + +
+ <% + if(fqtn.equals(TableName.META_TABLE_NAME.getNameAsString())) { + %> +

Table Regions

+
+ +
+
+
NameRegion ServerReadRequestsWriteRequestsStorefileSizeNum.StorefilesMemSizeLocalityStart KeyEnd Key
+ + + + + + + + + + + + + <% + if (withReplica) { + %> + + <% + } + %> + + + + <% + // 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(); + } + } + } + %> + + + + + + + + + + + + <% + if (withReplica) { + %> + + <% + } + %> + + <% } %> + <%} %> + +
NameRegion ServerReadRequestsWriteRequestsStorefileSizeNum.StorefilesMemSizeLocalityStart KeyEnd KeyReplicaID
<%= escapeXml(meta.getRegionNameAsString()) %><%= StringEscapeUtils.escapeHtml4(hostAndPort) %><%= readReq%><%= writeReq%><%= fileSize%><%= fileCount%><%= memSize%><%= locality%><%= 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); + 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)) + "%"; + } + } + } + } + %> + + + + + + + + + <% } %> + <%} %> + +
NameRegion ServerNum. Compacting CellsNum. Compacted CellsRemaining CellsCompaction Progress
<%= escapeXml(meta.getRegionNameAsString()) %><%= StringEscapeUtils.escapeHtml4(hostAndPort) %><%= String.format("%,1d", compactingCells)%><%= String.format("%,1d", compactedCells)%><%= String.format("%,1d", compactingCells - compactedCells)%><%= compactionProgress%>
+
+ + + <%} 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); } } -%> - - <%= escapeXml(meta.getRegionNameAsString()) %> - <%= StringEscapeUtils.escapeHtml4(hostAndPort) %> - <%= readReq%> - <%= writeReq%> - <%= fileSize%> - <%= fileCount%> - <%= memSize%> - <%= locality%> - <%= escapeXml(Bytes.toString(meta.getStartKey())) %> - <%= escapeXml(Bytes.toString(meta.getEndKey())) %> -<% - if (withReplica) { -%> - <%= meta.getReplicaId() %> -<% - } -%> - -<% } %> -<%} %> - - -<%} else { - 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 NameValueDescription
Enabled<%= master.getAssignmentManager().isTableEnabled(table.getName()) %>Is the table enabled
Compaction -<% - if (master.getAssignmentManager().isTableEnabled(table.getName())) { - try { - CompactionState compactionState = admin.getCompactionState(table.getName()).get(); - %><%= compactionState %><% - } catch (Exception e) { - // Nothing really to do here - for(StackTraceElement element : e.getStackTrace()) { - %><%= StringEscapeUtils.escapeHtml4(element.toString()) %><% - } - %> Unknown <% - } - } 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) { -%> - - - - - - - - -<% - } -%> -
PropertyValue
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) { -%> - - - - - - -<% - } -%> -
LimitTypeTimeUnitScope
<%= throttle.getSoftLimit() %><%= throttle.getThrottleType() %><%= throttle.getTimeUnit() %><%= throttle.getQuotaScope() %>
-
Information about a Throttle Quota on this table, if set.
-

Table Schema

- - - - - - <% - Collection families = table.getTableDescriptor().getFamilies(); - for (HColumnDescriptor family: families) { - %> - - - - - <% } %> -
Column Family Name
<%= StringEscapeUtils.escapeHtml4(family.getNameAsString()) %> + RegionLocator r = master.getConnection().getRegionLocator(table.getName()); + try { %> +

Table Attributes

- - + + + - <% - Map familyValues = family.getValues(); - for (Bytes familyKey: familyValues.keySet()) { - %> + + + + + + + <% + if (master.getAssignmentManager().isTableEnabled(table.getName())) { + try { + CompactionState compactionState = admin.getCompactionState(table.getName()).get(); + %><%= compactionState %><% + } catch (Exception e) { + // Nothing really to do here + for(StackTraceElement element : e.getStackTrace()) { + %><%= StringEscapeUtils.escapeHtml4(element.toString()) %><% + } + %> Unknown <% + } + } else { + %><%= CompactionState.NONE %><% + } + %> + + + + <% 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) { + %> + + + + + + <% + } + } + } + %> +
PropertyValueAttribute NameValueDescription
Enabled<%= master.getAssignmentManager().isTableEnabled(table.getName()) %>Is the table enabled
Compaction - <%= StringEscapeUtils.escapeHtml4(familyKey.toString()) %> - 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 - <%= StringEscapeUtils.escapeHtml4(familyValues.get(familyKey).toString()) %> + + + + + + + + + + + + + + <% + if (masterSnapshot != null) { + %> + + + + + + + + + <% + } + %> +
PropertyValue
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) { + %> + + + + + + + <% + } + %> +
LimitTypeTimeUnitScope
<%= throttle.getSoftLimit() %><%= throttle.getThrottleType() %><%= throttle.getTimeUnit() %><%= throttle.getQuotaScope() %>
+
Information about a Throttle Quota on this table, if set.
+

Table Schema

+ + + + + + <% + Collection families = table.getTableDescriptor().getFamilies(); + for (HColumnDescriptor family: families) { + %> + + + - <% } %> + <% } %>
Column Family Name
<%= StringEscapeUtils.escapeHtml4(family.getNameAsString()) %> + + + + + + <% + Map familyValues = family.getValues(); + for (Bytes familyKey: familyValues.keySet()) { + %> + + + + + <% } %> +
PropertyValue
+ <%= StringEscapeUtils.escapeHtml4(familyKey.toString()) %> + + <%= StringEscapeUtils.escapeHtml4(familyValues.get(familyKey).toString()) %> +
-
-<% - long totalReadReq = 0; - long totalWriteReq = 0; - long totalSize = 0; - long totalStoreFileCount = 0; - long totalMemSize = 0; - 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); + <% + 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); + 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); } - } 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(regions != null && regions.size() > 0) { %> -

Table Regions

- - - - - - - - - - - - - -<% - if (withReplica) { -%> - -<% - } -%> - - - - -<% - 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; - 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); + if (totalSize > 0) { + totalSizeStr = StringUtils.byteDesc(totalSize*1024l*1024); } - fileCount = String.format("%,1d", load.getStoreFileCount()); - double mSize = load.getMemStoreSize().get(Size.Unit.BYTE); - if (mSize > 0) { - memSize = StringUtils.byteDesc((long)mSize); + if (totalMemSize > 0) { + totalMemSizeStr = StringUtils.byteDesc(totalMemSize*1024l*1024); } - locality = load.getDataLocality(); - } - - 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 (totalCompactingCells > 0) { + totalCompactionProgress = String.format("%.2f", 100 * + ((float) totalCompactedCells / totalCompactingCells)) + "%"; } - } - if (numRegionsRendered < numRegionsToRender) { - numRegionsRendered++; -%> - - - <% - if (urlRegionServer != null) { - %> - - <% - } else { - %> - - <% - } - %> - - - - - - - - - <% - if (withReplica) { - %> - - <% - } - %> - -<% } %> -<% } %> - -
Name(<%= String.format("%,1d", regions.size())%>)Region ServerReadRequests
(<%= String.format("%,1d", totalReadReq)%>)
WriteRequests
(<%= String.format("%,1d", totalWriteReq)%>)
StorefileSize
(<%= totalSizeStr %>)
Num.Storefiles
(<%= String.format("%,1d", totalStoreFileCount)%>)
MemSize
(<%= totalMemSizeStr %>)
LocalityStart KeyEnd KeyReplicaID
<%= escapeXml(Bytes.toStringBinary(regionInfo.getRegionName())) %> - <%= addr == null? "-": StringEscapeUtils.escapeHtml4(addr.getHostname().toString()) + ":" + master.getRegionServerInfoPort(addr) %> - not deployed<%= readReq%><%= writeReq%><%= regionSize%><%= fileCount%><%= memSize%><%= locality%><%= escapeXml(Bytes.toStringBinary(regionInfo.getStartKey()))%><%= escapeXml(Bytes.toStringBinary(regionInfo.getEndKey()))%><%= regionInfo.getReplicaId() %>
-<% if (numRegions > numRegionsRendered) { - String allRegionsUrl = "?name=" + URLEncoder.encode(fqtn,"UTF-8") + "&numRegions=all"; -%> -

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.

-<% } %> -

Regions by Region Server

-<% -if (withReplica) { -%> - -<% + if(regions != null && regions.size() > 0) { %> +

Table Regions

+
+ +
+
+
Region ServerRegion CountPrimary Region Count
+ + + + + + + + + + + + + + <% + if (withReplica) { + %> + + <% + } + %> + + + + <% + 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++; + %> + + + <% + if (urlRegionServer != null) { + %> + + <% + } else { + %> + + <% + } + %> + + + + + + + + + + <% + if (withReplica) { + %> + + <% + } + %> + + <% } %> + <% } %> + +
Name(<%= String.format("%,1d", regions.size())%>)Region ServerReadRequests
(<%= String.format("%,1d", totalReadReq)%>)
WriteRequests
(<%= String.format("%,1d", totalWriteReq)%>)
StorefileSize
(<%= totalSizeStr %>)
Num.Storefiles
(<%= String.format("%,1d", totalStoreFileCount)%>)
MemSize
(<%= totalMemSizeStr %>)
LocalityStart KeyEnd KeyRegion StateReplicaID
<%= escapeXml(Bytes.toStringBinary(regionInfo.getRegionName())) %> + <%= addr == null? "-": StringEscapeUtils.escapeHtml4(addr.getHostname().toString()) + ":" + master.getRegionServerInfoPort(addr) %> + not deployed<%= readReq%><%= writeReq%><%= regionSize%><%= fileCount%><%= memSize%><%= locality%><%= escapeXml(Bytes.toStringBinary(regionInfo.getStartKey()))%><%= escapeXml(Bytes.toStringBinary(regionInfo.getEndKey()))%><%= state%><%= regionInfo.getReplicaId() %>
+ <% if (numRegions > numRegionsRendered) { + String allRegionsUrl = "?name=" + URLEncoder.encode(fqtn,"UTF-8") + "&numRegions=all"; + %> +

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.

+ <% } %> + +
+ + + + + + + + + + + + + <% + 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++; + %> + + + <% + if (urlRegionServer != null) { + %> + + <% + } else { + %> + + <% + } + %> + + + + + + <% } %> + <% } %> + +
Name(<%= String.format("%,1d", regions.size())%>)Region ServerNum. 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())) %> + <%= addr == null? "-": StringEscapeUtils.escapeHtml4(addr.getHostname().toString()) + ":" + master.getRegionServerInfoPort(addr) %> + not deployed<%= String.format("%,1d", compactingCells)%><%= String.format("%,1d", compactedCells)%><%= String.format("%,1d", compactingCells - compactedCells)%><%= compactionProgress%>
+ <% if (numRegions > numRegionsRendered) { + String allRegionsUrl = "?name=" + URLEncoder.encode(fqtn,"UTF-8") + "&numRegions=all"; + %> +

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.

+ <% } %> +
+ + +

Regions by Region Server

+ <% + if (withReplica) { + %> + + <% } else { %> -
Region ServerRegion CountPrimary Region Count
- -<% -} -%> -<% - for (Map.Entry rdEntry : regDistribution.entrySet()) { - ServerName addr = rdEntry.getKey(); - String url = "//" + URLEncoder.encode(addr.getHostname()) + ":" + master.getRegionServerInfoPort(addr) + "/rs-status"; -%> - - - -<% -if (withReplica) { -%> - -<% -} -%> - -<% } %> - -
Region ServerRegion Count
<%= StringEscapeUtils.escapeHtml4(addr.getHostname().toString()) + ":" + master.getRegionServerInfoPort(addr) %><%= rdEntry.getValue()%><%= primaryRegDistribution.get(addr)%>
-<% } + + + <% + } + %> + <% + for (Map.Entry rdEntry : regDistribution.entrySet()) { + ServerName addr = rdEntry.getKey(); + String url = "//" + URLEncoder.encode(addr.getHostname()) + ":" + master.getRegionServerInfoPort(addr) + "/rs-status"; + %> + + + + <% + if (withReplica) { + %> + + <% + } + %> + + <% } %> + +
Region ServerRegion Count
<%= StringEscapeUtils.escapeHtml4(addr.getHostname().toString()) + ":" + master.getRegionServerInfoPort(addr) %><%= rdEntry.getValue()%><%= primaryRegDistribution.get(addr)%>
+ <% } } catch(Exception ex) { for(StackTraceElement element : ex.getStackTrace()) { %><%= StringEscapeUtils.escapeHtml4(element.toString()) %><% @@ -642,129 +835,129 @@ if (withReplica) { } // end else %> -

Table Stats

- - - - - - - - - - <% - } else { - %> - 0 MB - <% - } - %> - - -
NameValueDescription
Size - <% - if (totalStoreFileSizeMB > 0) { - %> - <%= StringUtils.TraditionalBinaryPrefix. - long2String(totalStoreFileSizeMB * 1024 * 1024, "B", 2)%>Total size of store files
+

Table Stats

+ + + + + + + + + + <% + } else { + %> + 0 MB + <% + } + %> + + +
NameValueDescription
Size + <% + if (totalStoreFileSizeMB > 0) { + %> + <%= StringUtils.TraditionalBinaryPrefix. + long2String(totalStoreFileSizeMB * 1024 * 1024, "B", 2)%>Total size of store files
-<% if (!readOnly) { %> -


-Actions: -

-

- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - 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. -
- - - - - 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. -
- - - - - - This action will merge two regions of the table, Merge requests for - noneligible regions will be ignored. -
-
-

-<% } %> - + <% if (!readOnly) { %> +


+ Actions: +

+

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + 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. +
+ + + + + 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. +
+ + + + + + This action will merge two regions of the table, Merge requests for + noneligible regions will be ignored. +
+
+

+ <% } %> + <% } - } catch(TableNotFoundException e) { %> -
-
- +} catch(TableNotFoundException e) { %> +
+
+ -


-

Go Back -

<% - } catch(IllegalArgumentException e) { %> -
-
- +
+


+

Go Back +

<% +} catch(IllegalArgumentException e) { %> +
+
+ -


-

Go Back -

<% +
+


+

Go Back +

<% } } - else { // handle the case for fqtn is null or master is not initialized with error message + redirect +else { // handle the case for fqtn is null or master is not initialized with error message + redirect %>
-
- +
+ -


- +

+


+

<% } %> @@ -774,64 +967,78 @@ Actions: