From 91c7ede9df51f180d5c086c793de4ba47d4a769b Mon Sep 17 00:00:00 2001
From: Bryan Beaudreault
Date: Fri, 29 Jul 2022 15:28:28 -0400
Subject: [PATCH] HubSpot Backport: HBASE-27257 Remove unnecessary usage of
CachedBlocksByFile from RS UI (#4667)
Signed-off-by: Wellington Chevreuil
---
.../tmpl/regionserver/BlockCacheTmpl.jamon | 24 ++++++++-----------
.../hadoop/hbase/io/hfile/BlockCacheUtil.java | 9 +++++--
2 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/BlockCacheTmpl.jamon b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/BlockCacheTmpl.jamon
index a18e6d4cfc4..0fece42f941 100644
--- a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/BlockCacheTmpl.jamon
+++ b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/BlockCacheTmpl.jamon
@@ -30,6 +30,7 @@ BlockCache bc;
%java>
<%import>
java.util.Map;
+org.apache.hadoop.hbase.io.hfile.BlockCacheUtil;
org.apache.hadoop.hbase.io.hfile.BlockCacheUtil.CachedBlocksByFile;
org.apache.hadoop.hbase.io.hfile.AgeSnapshot;
org.apache.hadoop.hbase.io.hfile.CachedBlock;
@@ -281,9 +282,7 @@ are combined counts. Request count is sum of hits and misses.
<%java>
String bcUrl = "http://hbase.apache.org/devapidocs/" + bc.getClass().getName().replaceAll("\\.", "/") + ".html";
String bcName = bc.getClass().getSimpleName();
- org.apache.hadoop.hbase.io.hfile.BlockCacheUtil.CachedBlocksByFile cbsbf =
- org.apache.hadoop.hbase.io.hfile.BlockCacheUtil.getLoadedCachedBlocksByFile(config, bc);
- AgeSnapshot cbsbfSnapshot = cbsbf.getAgeInCacheSnapshot();
+ int maxCachedBlocksByFile = BlockCacheUtil.getMaxCachedBlocksByFile(config);
boolean bucketCache = bc.getClass().getSimpleName().equals("BucketCache");
BucketCacheStats bucketCacheStats = null;
@@ -294,13 +293,6 @@ are combined counts. Request count is sum of hits and misses.
bucketAllocator = ((BucketCache)bc).getAllocator();
}
%java>
-<%if cbsbf.isFull() %>
-
-
-The stats below are incomplete! We ran into our accounting limit of <% cbsbf.getCount() %> blocks. Up the configuration hbase.ui.blockcache.by.file.max.
-
-
-%if>
Attribute |
@@ -365,9 +357,13 @@ are combined counts. Request count is sum of hits and misses.
%if>
<%doc>Call through to block cache Detail rendering template%doc>
-View block cache as JSON | Block cache as JSON by file
-<%java>
-cbsbf = null;
-%java>
+
+View block cache as JSON | Block cache as JSON by file
+<%if bc.getBlockCount() > maxCachedBlocksByFile %>
+
+Note: JSON view of block cache will be incomplete, because block count <% bc.getBlockCount() %> is greater than hbase.ui.blockcache.by.file.max value of <% maxCachedBlocksByFile %>.
+Increase that value to get a complete picture.
+%if>
+
%def>
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/BlockCacheUtil.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/BlockCacheUtil.java
index c2cf82148be..94e910e3466 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/BlockCacheUtil.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/BlockCacheUtil.java
@@ -255,6 +255,12 @@ public class BlockCacheUtil {
}
}
+ private static final int DEFAULT_MAX = 1000000;
+
+ public static int getMaxCachedBlocksByFile(Configuration conf) {
+ return conf == null ? DEFAULT_MAX : conf.getInt("hbase.ui.blockcache.by.file.max", DEFAULT_MAX);
+ }
+
/**
* Use one of these to keep a running account of cached blocks by file. Throw it away when done.
* This is different than metrics in that it is stats on current state of a cache.
@@ -274,14 +280,13 @@ public class BlockCacheUtil {
* are incomplete.
*/
private final int max;
- public static final int DEFAULT_MAX = 1000000;
CachedBlocksByFile() {
this(null);
}
CachedBlocksByFile(final Configuration c) {
- this.max = c == null? DEFAULT_MAX: c.getInt("hbase.ui.blockcache.by.file.max", DEFAULT_MAX);
+ this.max = getMaxCachedBlocksByFile(c);
}
/**