Skip to content

Commit b0a083c

Browse files
committed
HBASE-27257 Remove unnecessary usage of CachedBlocksByFile from RS UI (apache#4667)
Signed-off-by: Wellington Chevreuil <wchevreuil@apache.org> (cherry picked from commit b532987) Change-Id: Ia154fa82756e834a5bc2c94229eceaa753e38dea
1 parent d215423 commit b0a083c

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/BlockCacheTmpl.jamon

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ BlockCache bc;
3030
</%java>
3131
<%import>
3232
java.util.Map;
33+
org.apache.hadoop.hbase.io.hfile.BlockCacheUtil;
3334
org.apache.hadoop.hbase.io.hfile.BlockCacheUtil.CachedBlocksByFile;
3435
org.apache.hadoop.hbase.io.hfile.AgeSnapshot;
3536
org.apache.hadoop.hbase.io.hfile.CachedBlock;
@@ -281,9 +282,7 @@ are combined counts. Request count is sum of hits and misses.</p>
281282
<%java>
282283
String bcUrl = "http://hbase.apache.org/devapidocs/" + bc.getClass().getName().replaceAll("\\.", "/") + ".html";
283284
String bcName = bc.getClass().getSimpleName();
284-
org.apache.hadoop.hbase.io.hfile.BlockCacheUtil.CachedBlocksByFile cbsbf =
285-
org.apache.hadoop.hbase.io.hfile.BlockCacheUtil.getLoadedCachedBlocksByFile(config, bc);
286-
AgeSnapshot cbsbfSnapshot = cbsbf.getAgeInCacheSnapshot();
285+
int maxCachedBlocksByFile = BlockCacheUtil.getMaxCachedBlocksByFile(config);
287286

288287
boolean bucketCache = bc.getClass().getSimpleName().equals("BucketCache");
289288
BucketCacheStats bucketCacheStats = null;
@@ -294,13 +293,6 @@ are combined counts. Request count is sum of hits and misses.</p>
294293
bucketAllocator = ((BucketCache)bc).getAllocator();
295294
}
296295
</%java>
297-
<%if cbsbf.isFull() %>
298-
<p>
299-
<div class="alert alert-danger">
300-
<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>.
301-
</div>
302-
</p>
303-
</%if>
304296
<table id="blocks_summary" class="table table-striped">
305297
<tr>
306298
<th>Attribute</th>
@@ -365,9 +357,13 @@ are combined counts. Request count is sum of hits and misses.</p>
365357
</%if>
366358
</table>
367359
<%doc>Call through to block cache Detail rendering template</%doc>
368-
<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>
369-
<%java>
370-
cbsbf = null;
371-
</%java>
360+
<p>
361+
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>
362+
<%if bc.getBlockCount() > maxCachedBlocksByFile %>
363+
<br>
364+
<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 %>.
365+
Increase that value to get a complete picture.
366+
</%if>
367+
</p>
372368
</%def>
373369

hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/BlockCacheUtil.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,12 @@ public static boolean shouldReplaceExistingCacheBlock(BlockCache blockCache,
242242
}
243243
}
244244

245+
private static final int DEFAULT_MAX = 1000000;
246+
247+
public static int getMaxCachedBlocksByFile(Configuration conf) {
248+
return conf == null ? DEFAULT_MAX : conf.getInt("hbase.ui.blockcache.by.file.max", DEFAULT_MAX);
249+
}
250+
245251
/**
246252
* Use one of these to keep a running account of cached blocks by file. Throw it away when done.
247253
* This is different than metrics in that it is stats on current state of a cache. See
@@ -259,14 +265,13 @@ public static class CachedBlocksByFile {
259265
* displays warning in red when stats are incomplete.
260266
*/
261267
private final int max;
262-
public static final int DEFAULT_MAX = 1000000;
263268

264269
CachedBlocksByFile() {
265270
this(null);
266271
}
267272

268273
CachedBlocksByFile(final Configuration c) {
269-
this.max = c == null ? DEFAULT_MAX : c.getInt("hbase.ui.blockcache.by.file.max", DEFAULT_MAX);
274+
this.max = getMaxCachedBlocksByFile(c);
270275
}
271276

272277
/**

0 commit comments

Comments
 (0)