From 61efb6d5adcfa6436fde2e0e1a9a5fdc09da88b1 Mon Sep 17 00:00:00 2001 From: Baiqiang Zhao Date: Mon, 18 May 2020 09:14:36 +0800 Subject: [PATCH] HBASE-24381 The Size metrics in Master Webui is wrong if the size is 0 (#1723) --- .../hbase/tmpl/master/RSGroupListTmpl.jamon | 14 +- .../tmpl/master/RegionServerListTmpl.jamon | 128 +++++++++--------- .../hbase-webapps/master/rsgroup.jsp | 15 +- 3 files changed, 78 insertions(+), 79 deletions(-) diff --git a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/RSGroupListTmpl.jamon b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/RSGroupListTmpl.jamon index c542c6892b8..03923c87a3f 100644 --- a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/RSGroupListTmpl.jamon +++ b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/RSGroupListTmpl.jamon @@ -171,10 +171,10 @@ if (master.getServerManager() != null) { <%java> final String ZEROMB = "0 MB"; - String usedHeapStr = ZEROMB; - String maxHeapStr = ZEROMB; - String memstoreSizeStr = ZEROMB; for (RSGroupInfo rsGroupInfo: rsGroupInfos) { + String usedHeapStr = ZEROMB; + String maxHeapStr = ZEROMB; + String memstoreSizeStr = ZEROMB; String rsGroupName = rsGroupInfo.getName(); long usedHeap = 0; long maxHeap = 0; @@ -275,11 +275,11 @@ if (master.getServerManager() != null) { <%java> final String ZEROKB = "0 KB"; final String ZEROMB = "0 MB"; - String uncompressedStorefileSizeStr = ZEROMB; - String storefileSizeStr = ZEROMB; - String indexSizeStr = ZEROKB; - String bloomSizeStr = ZEROKB; for (RSGroupInfo rsGroupInfo: rsGroupInfos) { + String uncompressedStorefileSizeStr = ZEROMB; + String storefileSizeStr = ZEROMB; + String indexSizeStr = ZEROKB; + String bloomSizeStr = ZEROKB; String rsGroupName = rsGroupInfo.getName(); int numStores = 0; long numStorefiles = 0; diff --git a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/RegionServerListTmpl.jamon b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/RegionServerListTmpl.jamon index 5ce19ab7b0f..a3067eeaf8a 100644 --- a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/RegionServerListTmpl.jamon +++ b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/RegionServerListTmpl.jamon @@ -162,31 +162,31 @@ Arrays.sort(serverNames); <%java> final String ZEROMB = "0 MB"; -String usedHeapStr = ZEROMB; -String maxHeapStr = ZEROMB; -String memStoreSizeMBStr = ZEROMB; for (ServerName serverName: serverNames) { - ServerMetrics sl = master.getServerManager().getLoad(serverName); - if (sl != null) { - long memStoreSizeMB = 0; - for (RegionMetrics rl : sl.getRegionMetrics().values()) { - memStoreSizeMB += rl.getMemStoreSize().get(Size.Unit.MEGABYTE); - } - if (memStoreSizeMB > 0) { - memStoreSizeMBStr = TraditionalBinaryPrefix.long2String(memStoreSizeMB - * TraditionalBinaryPrefix.MEGA.value, "B", 1); - } + String usedHeapStr = ZEROMB; + String maxHeapStr = ZEROMB; + String memStoreSizeMBStr = ZEROMB; + ServerMetrics sl = master.getServerManager().getLoad(serverName); + if (sl != null) { + long memStoreSizeMB = 0; + for (RegionMetrics rl : sl.getRegionMetrics().values()) { + memStoreSizeMB += rl.getMemStoreSize().get(Size.Unit.MEGABYTE); + } + if (memStoreSizeMB > 0) { + memStoreSizeMBStr = TraditionalBinaryPrefix.long2String(memStoreSizeMB + * TraditionalBinaryPrefix.MEGA.value, "B", 1); + } - double usedHeapSizeMB = sl.getUsedHeapSize().get(Size.Unit.MEGABYTE); - if (usedHeapSizeMB > 0) { - usedHeapStr = TraditionalBinaryPrefix.long2String((long) usedHeapSizeMB - * TraditionalBinaryPrefix.MEGA.value, "B", 1); - } - double maxHeapSizeMB = sl.getMaxHeapSize().get(Size.Unit.MEGABYTE); - if (maxHeapSizeMB > 0) { - maxHeapStr = TraditionalBinaryPrefix.long2String((long) maxHeapSizeMB - * TraditionalBinaryPrefix.MEGA.value, "B", 1); - } + double usedHeapSizeMB = sl.getUsedHeapSize().get(Size.Unit.MEGABYTE); + if (usedHeapSizeMB > 0) { + usedHeapStr = TraditionalBinaryPrefix.long2String((long) usedHeapSizeMB + * TraditionalBinaryPrefix.MEGA.value, "B", 1); + } + double maxHeapSizeMB = sl.getMaxHeapSize().get(Size.Unit.MEGABYTE); + if (maxHeapSizeMB > 0) { + maxHeapStr = TraditionalBinaryPrefix.long2String((long) maxHeapSizeMB + * TraditionalBinaryPrefix.MEGA.value, "B", 1); + } <& serverNameLink; serverName=serverName; &> @@ -195,11 +195,11 @@ for (ServerName serverName: serverNames) { <% memStoreSizeMBStr %> <%java> - } else { + } else { <& emptyStat; serverName=serverName; &> <%java> - } + } } @@ -276,44 +276,44 @@ if (sl != null) { <%java> final String ZEROKB = "0 KB"; final String ZEROMB = "0 MB"; -String storeUncompressedSizeMBStr = ZEROMB; -String storeFileSizeMBStr = ZEROMB; -String totalStaticIndexSizeKBStr = ZEROKB; -String totalStaticBloomSizeKBStr = ZEROKB; for (ServerName serverName: serverNames) { -ServerMetrics sl = master.getServerManager().getLoad(serverName); -if (sl != null) { - long storeCount = 0; - long storeFileCount = 0; - long storeUncompressedSizeMB = 0; - long storeFileSizeMB = 0; - long totalStaticIndexSizeKB = 0; - long totalStaticBloomSizeKB = 0; - for (RegionMetrics rl : sl.getRegionMetrics().values()) { - storeCount += rl.getStoreCount(); - storeFileCount += rl.getStoreFileCount(); - storeUncompressedSizeMB += rl.getUncompressedStoreFileSize().get(Size.Unit.MEGABYTE); - storeFileSizeMB += rl.getStoreFileSize().get(Size.Unit.MEGABYTE); - totalStaticIndexSizeKB += rl.getStoreFileUncompressedDataIndexSize().get(Size.Unit.KILOBYTE); - totalStaticBloomSizeKB += rl.getBloomFilterSize().get(Size.Unit.KILOBYTE); - } - if (storeUncompressedSizeMB > 0) { - storeUncompressedSizeMBStr = TraditionalBinaryPrefix. - long2String(storeUncompressedSizeMB * TraditionalBinaryPrefix.MEGA.value, "B", 1); - } - if (storeFileSizeMB > 0) { - storeFileSizeMBStr = TraditionalBinaryPrefix. - long2String(storeFileSizeMB * TraditionalBinaryPrefix.MEGA.value, "B", 1); - } - if (totalStaticIndexSizeKB > 0) { - totalStaticIndexSizeKBStr = TraditionalBinaryPrefix. - long2String(totalStaticIndexSizeKB * TraditionalBinaryPrefix.KILO.value, "B", 1); - } - if (totalStaticBloomSizeKB > 0) { - totalStaticBloomSizeKBStr = TraditionalBinaryPrefix. - long2String(totalStaticBloomSizeKB * TraditionalBinaryPrefix.KILO.value, "B", 1); - } + String storeUncompressedSizeMBStr = ZEROMB; + String storeFileSizeMBStr = ZEROMB; + String totalStaticIndexSizeKBStr = ZEROKB; + String totalStaticBloomSizeKBStr = ZEROKB; + ServerMetrics sl = master.getServerManager().getLoad(serverName); + if (sl != null) { + long storeCount = 0; + long storeFileCount = 0; + long storeUncompressedSizeMB = 0; + long storeFileSizeMB = 0; + long totalStaticIndexSizeKB = 0; + long totalStaticBloomSizeKB = 0; + for (RegionMetrics rl : sl.getRegionMetrics().values()) { + storeCount += rl.getStoreCount(); + storeFileCount += rl.getStoreFileCount(); + storeUncompressedSizeMB += rl.getUncompressedStoreFileSize().get(Size.Unit.MEGABYTE); + storeFileSizeMB += rl.getStoreFileSize().get(Size.Unit.MEGABYTE); + totalStaticIndexSizeKB += rl.getStoreFileUncompressedDataIndexSize().get(Size.Unit.KILOBYTE); + totalStaticBloomSizeKB += rl.getBloomFilterSize().get(Size.Unit.KILOBYTE); + } + if (storeUncompressedSizeMB > 0) { + storeUncompressedSizeMBStr = TraditionalBinaryPrefix. + long2String(storeUncompressedSizeMB * TraditionalBinaryPrefix.MEGA.value, "B", 1); + } + if (storeFileSizeMB > 0) { + storeFileSizeMBStr = TraditionalBinaryPrefix. + long2String(storeFileSizeMB * TraditionalBinaryPrefix.MEGA.value, "B", 1); + } + if (totalStaticIndexSizeKB > 0) { + totalStaticIndexSizeKBStr = TraditionalBinaryPrefix. + long2String(totalStaticIndexSizeKB * TraditionalBinaryPrefix.KILO.value, "B", 1); + } + if (totalStaticBloomSizeKB > 0) { + totalStaticBloomSizeKBStr = TraditionalBinaryPrefix. + long2String(totalStaticBloomSizeKB * TraditionalBinaryPrefix.KILO.value, "B", 1); + } <& serverNameLink; serverName=serverName; &> @@ -325,11 +325,11 @@ if (sl != null) { <% totalStaticBloomSizeKBStr %> <%java> - } else { - + } else { + <& emptyStat; serverName=serverName; &> <%java> - } + } } diff --git a/hbase-server/src/main/resources/hbase-webapps/master/rsgroup.jsp b/hbase-server/src/main/resources/hbase-webapps/master/rsgroup.jsp index 429ebd380e3..94590c8e9dc 100644 --- a/hbase-server/src/main/resources/hbase-webapps/master/rsgroup.jsp +++ b/hbase-server/src/main/resources/hbase-webapps/master/rsgroup.jsp @@ -213,11 +213,10 @@ Memstore Size <% - String usedHeapSizeMBStr = ZEROMB; - String maxHeapSizeMBStr = ZEROMB; - String memStoreSizeMBStr = ZEROMB; - for (Address server: rsGroupServers) { + String usedHeapSizeMBStr = ZEROMB; + String maxHeapSizeMBStr = ZEROMB; + String memStoreSizeMBStr = ZEROMB; ServerName serverName = serverMaping.get(server); ServerMetrics sl = onlineServers.get(server); if (sl != null && serverName != null) { @@ -309,11 +308,11 @@ Bloom Size <% - String storeUncompressedSizeMBStr = ZEROMB; - String storeFileSizeMBStr = ZEROMB; - String totalStaticIndexSizeKBStr = ZEROKB; - String totalStaticBloomSizeKBStr = ZEROKB; for (Address server: rsGroupServers) { + String storeUncompressedSizeMBStr = ZEROMB; + String storeFileSizeMBStr = ZEROMB; + String totalStaticIndexSizeKBStr = ZEROKB; + String totalStaticBloomSizeKBStr = ZEROKB; ServerName serverName = serverMaping.get(server); ServerMetrics sl = onlineServers.get(server); if (sl != null && serverName != null) {