Skip to content

Commit fc4191a

Browse files
d-c-manningapurtell
authored andcommitted
HBASE-27159 Emit source metrics for BlockCacheExpressHitPercent (#4830)
Signed-off-by: Andrew Purtell <apurtell@apache.org>
1 parent 2d95ce0 commit fc4191a

6 files changed

Lines changed: 43 additions & 0 deletions

File tree

hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSource.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,18 @@ public interface MetricsRegionServerSource extends BaseSource, JvmPauseMonitorSo
329329
String BLOCK_CACHE_HIT_COUNT_DESC = "Count of the hit on the block cache.";
330330
String BLOCK_CACHE_PRIMARY_HIT_COUNT = "blockCacheHitCountPrimary";
331331
String BLOCK_CACHE_PRIMARY_HIT_COUNT_DESC = "Count of hit on primary replica in the block cache.";
332+
String BLOCK_CACHE_HIT_CACHING_COUNT = "blockCacheHitCachingCount";
333+
String BLOCK_CACHE_HIT_CACHING_COUNT_DESC =
334+
"Count of the hit on the block cache, for cacheable requests.";
332335
String BLOCK_CACHE_MISS_COUNT = "blockCacheMissCount";
333336
String BLOCK_COUNT_MISS_COUNT_DESC =
334337
"Number of requests for a block that missed the block cache.";
335338
String BLOCK_CACHE_PRIMARY_MISS_COUNT = "blockCacheMissCountPrimary";
336339
String BLOCK_COUNT_PRIMARY_MISS_COUNT_DESC =
337340
"Number of requests for a block of primary replica that missed the block cache.";
341+
String BLOCK_CACHE_MISS_CACHING_COUNT = "blockCacheMissCachingCount";
342+
String BLOCK_COUNT_MISS_CACHING_COUNT_DESC =
343+
"Number of requests for a block that missed the block cache, for cacheable requests.";
338344
String BLOCK_CACHE_EVICTION_COUNT = "blockCacheEvictionCount";
339345
String BLOCK_CACHE_EVICTION_COUNT_DESC =
340346
"Count of the number of blocks evicted from the block cache."

hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapper.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,11 @@ public interface MetricsRegionServerWrapper {
289289
*/
290290
long getBlockCachePrimaryHitCount();
291291

292+
/**
293+
* Get the count of hits to the block cache, for cacheable requests only.
294+
*/
295+
long getBlockCacheHitCachingCount();
296+
292297
/**
293298
* Get the count of misses to the block cache.
294299
*/
@@ -299,6 +304,11 @@ public interface MetricsRegionServerWrapper {
299304
*/
300305
long getBlockCachePrimaryMissCount();
301306

307+
/**
308+
* Get the count of misses to the block cache, for cacheable requests only.
309+
*/
310+
long getBlockCacheMissCachingCount();
311+
302312
/**
303313
* Get the number of items evicted from the block cache.
304314
*/

hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSourceImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,11 +370,16 @@ public void getMetrics(MetricsCollector metricsCollector, boolean all) {
370370
rsWrap.getBlockCacheHitCount())
371371
.addCounter(Interns.info(BLOCK_CACHE_PRIMARY_HIT_COUNT, BLOCK_CACHE_PRIMARY_HIT_COUNT_DESC),
372372
rsWrap.getBlockCachePrimaryHitCount())
373+
.addCounter(Interns.info(BLOCK_CACHE_HIT_CACHING_COUNT, BLOCK_CACHE_HIT_CACHING_COUNT_DESC),
374+
rsWrap.getBlockCacheHitCachingCount())
373375
.addCounter(Interns.info(BLOCK_CACHE_MISS_COUNT, BLOCK_COUNT_MISS_COUNT_DESC),
374376
rsWrap.getBlockCacheMissCount())
375377
.addCounter(
376378
Interns.info(BLOCK_CACHE_PRIMARY_MISS_COUNT, BLOCK_COUNT_PRIMARY_MISS_COUNT_DESC),
377379
rsWrap.getBlockCachePrimaryMissCount())
380+
.addCounter(
381+
Interns.info(BLOCK_CACHE_MISS_CACHING_COUNT, BLOCK_COUNT_MISS_CACHING_COUNT_DESC),
382+
rsWrap.getBlockCacheMissCachingCount())
378383
.addCounter(Interns.info(BLOCK_CACHE_EVICTION_COUNT, BLOCK_CACHE_EVICTION_COUNT_DESC),
379384
rsWrap.getBlockCacheEvictedCount())
380385
.addCounter(

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperImpl.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,11 @@ public long getBlockCachePrimaryHitCount() {
328328
return this.cacheStats != null ? this.cacheStats.getPrimaryHitCount() : 0L;
329329
}
330330

331+
@Override
332+
public long getBlockCacheHitCachingCount() {
333+
return this.cacheStats != null ? this.cacheStats.getHitCachingCount() : 0L;
334+
}
335+
331336
@Override
332337
public long getBlockCacheMissCount() {
333338
return this.cacheStats != null ? this.cacheStats.getMissCount() : 0L;
@@ -338,6 +343,11 @@ public long getBlockCachePrimaryMissCount() {
338343
return this.cacheStats != null ? this.cacheStats.getPrimaryMissCount() : 0L;
339344
}
340345

346+
@Override
347+
public long getBlockCacheMissCachingCount() {
348+
return this.cacheStats != null ? this.cacheStats.getMissCachingCount() : 0L;
349+
}
350+
341351
@Override
342352
public long getBlockCacheEvictedCount() {
343353
return this.cacheStats != null ? this.cacheStats.getEvictedCount() : 0L;

hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperStub.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,11 @@ public long getBlockCachePrimaryHitCount() {
322322
return 422;
323323
}
324324

325+
@Override
326+
public long getBlockCacheHitCachingCount() {
327+
return 16;
328+
}
329+
325330
@Override
326331
public long getBlockCacheMissCount() {
327332
return 417;
@@ -332,6 +337,11 @@ public long getBlockCachePrimaryMissCount() {
332337
return 421;
333338
}
334339

340+
@Override
341+
public long getBlockCacheMissCachingCount() {
342+
return 17;
343+
}
344+
335345
@Override
336346
public long getBlockCacheEvictedCount() {
337347
return 418;

hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegionServer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ public void testWrapperSource() {
111111
HELPER.assertGauge("blockCacheDataBlockCount", 300, serverSource);
112112
HELPER.assertGauge("blockCacheSize", 415, serverSource);
113113
HELPER.assertCounter("blockCacheHitCount", 416, serverSource);
114+
HELPER.assertCounter("blockCacheHitCachingCount", 16, serverSource);
114115
HELPER.assertCounter("blockCacheMissCount", 417, serverSource);
116+
HELPER.assertCounter("blockCacheMissCachingCount", 17, serverSource);
115117
HELPER.assertCounter("blockCacheEvictionCount", 418, serverSource);
116118
HELPER.assertGauge("blockCacheCountHitPercent", 98, serverSource);
117119
HELPER.assertGauge("blockCacheExpressHitPercent", 97, serverSource);

0 commit comments

Comments
 (0)