HBASE-27257 Remove unnecessary usage of CachedBlocksByFile from RS UI (#4667)

Signed-off-by: Wellington Chevreuil <wchevreuil@apache.org>
This commit is contained in:
Bryan Beaudreault 2022-07-29 15:28:28 -04:00 committed by GitHub
parent 811f0e7d2a
commit e8c14ee308
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 16 deletions

View File

@ -30,6 +30,7 @@ BlockCache bc;
</%java> </%java>
<%import> <%import>
java.util.Map; java.util.Map;
org.apache.hadoop.hbase.io.hfile.BlockCacheUtil;
org.apache.hadoop.hbase.io.hfile.BlockCacheUtil.CachedBlocksByFile; org.apache.hadoop.hbase.io.hfile.BlockCacheUtil.CachedBlocksByFile;
org.apache.hadoop.hbase.io.hfile.AgeSnapshot; org.apache.hadoop.hbase.io.hfile.AgeSnapshot;
org.apache.hadoop.hbase.io.hfile.CachedBlock; org.apache.hadoop.hbase.io.hfile.CachedBlock;
@ -281,9 +282,7 @@ are combined counts. Request count is sum of hits and misses.</p>
<%java> <%java>
String bcUrl = "http://hbase.apache.org/devapidocs/" + bc.getClass().getName().replaceAll("\\.", "/") + ".html"; String bcUrl = "http://hbase.apache.org/devapidocs/" + bc.getClass().getName().replaceAll("\\.", "/") + ".html";
String bcName = bc.getClass().getSimpleName(); String bcName = bc.getClass().getSimpleName();
org.apache.hadoop.hbase.io.hfile.BlockCacheUtil.CachedBlocksByFile cbsbf = int maxCachedBlocksByFile = BlockCacheUtil.getMaxCachedBlocksByFile(config);
org.apache.hadoop.hbase.io.hfile.BlockCacheUtil.getLoadedCachedBlocksByFile(config, bc);
AgeSnapshot cbsbfSnapshot = cbsbf.getAgeInCacheSnapshot();
boolean bucketCache = bc.getClass().getSimpleName().equals("BucketCache"); boolean bucketCache = bc.getClass().getSimpleName().equals("BucketCache");
BucketCacheStats bucketCacheStats = null; BucketCacheStats bucketCacheStats = null;
@ -294,13 +293,6 @@ are combined counts. Request count is sum of hits and misses.</p>
bucketAllocator = ((BucketCache)bc).getAllocator(); bucketAllocator = ((BucketCache)bc).getAllocator();
} }
</%java> </%java>
<%if cbsbf.isFull() %>
<p>
<div class="alert alert-danger">
<strong>The stats below are incomplete!</strong> We ran into our accounting limit of <% cbsbf.getCount() %> blocks. Up the configuration <i>hbase.ui.blockcache.by.file.max</i>.
</div>
</p>
</%if>
<table id="blocks_summary" class="table table-striped"> <table id="blocks_summary" class="table table-striped">
<tr> <tr>
<th>Attribute</th> <th>Attribute</th>
@ -365,9 +357,13 @@ are combined counts. Request count is sum of hits and misses.</p>
</%if> </%if>
</table> </table>
<%doc>Call through to block cache Detail rendering template</%doc> <%doc>Call through to block cache Detail rendering template</%doc>
<p>View block cache <a href="?format=json&bcn=<% name %>">as JSON</a> | Block cache <a href="?format=json&bcn=<% name %>&bcv=file">as JSON by file</a></p> <p>
<%java> View block cache <a href="?format=json&bcn=<% name %>">as JSON</a> | Block cache <a href="?format=json&bcn=<% name %>&bcv=file">as JSON by file</a>
cbsbf = null; <%if bc.getBlockCount() > maxCachedBlocksByFile %>
</%java> <br>
<b>Note</b>: JSON view of block cache will be incomplete, because block count <% bc.getBlockCount() %> is greater than <i>hbase.ui.blockcache.by.file.max</i> value of <% maxCachedBlocksByFile %>.
Increase that value to get a complete picture.
</%if>
</p>
</%def> </%def>

View File

@ -242,6 +242,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. * 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. See * This is different than metrics in that it is stats on current state of a cache. See
@ -259,14 +265,13 @@ public class BlockCacheUtil {
* displays warning in red when stats are incomplete. * displays warning in red when stats are incomplete.
*/ */
private final int max; private final int max;
public static final int DEFAULT_MAX = 1000000;
CachedBlocksByFile() { CachedBlocksByFile() {
this(null); this(null);
} }
CachedBlocksByFile(final Configuration c) { CachedBlocksByFile(final Configuration c) {
this.max = c == null ? DEFAULT_MAX : c.getInt("hbase.ui.blockcache.by.file.max", DEFAULT_MAX); this.max = getMaxCachedBlocksByFile(c);
} }
/** /**