From b9ec644e516466a7dd53df47b29058952264a728 Mon Sep 17 00:00:00 2001 From: d-c-manning <67607031+d-c-manning@users.noreply.github.com> Date: Mon, 17 Oct 2022 14:18:37 -0700 Subject: [PATCH] HBASE-27159 Emit source metrics for BlockCacheExpressHitPercent (#4830) Signed-off-by: Andrew Purtell --- .../hbase/regionserver/MetricsRegionServerSource.java | 6 ++++++ .../hbase/regionserver/MetricsRegionServerWrapper.java | 10 ++++++++++ .../regionserver/MetricsRegionServerSourceImpl.java | 5 +++++ .../regionserver/MetricsRegionServerWrapperImpl.java | 10 ++++++++++ .../regionserver/MetricsRegionServerWrapperStub.java | 10 ++++++++++ .../hbase/regionserver/TestMetricsRegionServer.java | 2 ++ 6 files changed, 43 insertions(+) diff --git a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSource.java b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSource.java index fb08dcc190d..debddcf1b56 100644 --- a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSource.java +++ b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSource.java @@ -329,12 +329,18 @@ public interface MetricsRegionServerSource extends BaseSource, JvmPauseMonitorSo String BLOCK_CACHE_HIT_COUNT_DESC = "Count of the hit on the block cache."; String BLOCK_CACHE_PRIMARY_HIT_COUNT = "blockCacheHitCountPrimary"; String BLOCK_CACHE_PRIMARY_HIT_COUNT_DESC = "Count of hit on primary replica in the block cache."; + String BLOCK_CACHE_HIT_CACHING_COUNT = "blockCacheHitCachingCount"; + String BLOCK_CACHE_HIT_CACHING_COUNT_DESC = + "Count of the hit on the block cache, for cacheable requests."; String BLOCK_CACHE_MISS_COUNT = "blockCacheMissCount"; String BLOCK_COUNT_MISS_COUNT_DESC = "Number of requests for a block that missed the block cache."; String BLOCK_CACHE_PRIMARY_MISS_COUNT = "blockCacheMissCountPrimary"; String BLOCK_COUNT_PRIMARY_MISS_COUNT_DESC = "Number of requests for a block of primary replica that missed the block cache."; + String BLOCK_CACHE_MISS_CACHING_COUNT = "blockCacheMissCachingCount"; + String BLOCK_COUNT_MISS_CACHING_COUNT_DESC = + "Number of requests for a block that missed the block cache, for cacheable requests."; String BLOCK_CACHE_EVICTION_COUNT = "blockCacheEvictionCount"; String BLOCK_CACHE_EVICTION_COUNT_DESC = "Count of the number of blocks evicted from the block cache." diff --git a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapper.java b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapper.java index e2a50cec892..1e5c6c409ed 100644 --- a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapper.java +++ b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapper.java @@ -289,6 +289,11 @@ public interface MetricsRegionServerWrapper { */ long getBlockCachePrimaryHitCount(); + /** + * Get the count of hits to the block cache, for cacheable requests only. + */ + long getBlockCacheHitCachingCount(); + /** * Get the count of misses to the block cache. */ @@ -299,6 +304,11 @@ public interface MetricsRegionServerWrapper { */ long getBlockCachePrimaryMissCount(); + /** + * Get the count of misses to the block cache, for cacheable requests only. + */ + long getBlockCacheMissCachingCount(); + /** * Get the number of items evicted from the block cache. */ diff --git a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSourceImpl.java b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSourceImpl.java index bfb4bce506a..9852f00b56e 100644 --- a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSourceImpl.java +++ b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSourceImpl.java @@ -370,11 +370,16 @@ public class MetricsRegionServerSourceImpl extends BaseSourceImpl rsWrap.getBlockCacheHitCount()) .addCounter(Interns.info(BLOCK_CACHE_PRIMARY_HIT_COUNT, BLOCK_CACHE_PRIMARY_HIT_COUNT_DESC), rsWrap.getBlockCachePrimaryHitCount()) + .addCounter(Interns.info(BLOCK_CACHE_HIT_CACHING_COUNT, BLOCK_CACHE_HIT_CACHING_COUNT_DESC), + rsWrap.getBlockCacheHitCachingCount()) .addCounter(Interns.info(BLOCK_CACHE_MISS_COUNT, BLOCK_COUNT_MISS_COUNT_DESC), rsWrap.getBlockCacheMissCount()) .addCounter( Interns.info(BLOCK_CACHE_PRIMARY_MISS_COUNT, BLOCK_COUNT_PRIMARY_MISS_COUNT_DESC), rsWrap.getBlockCachePrimaryMissCount()) + .addCounter( + Interns.info(BLOCK_CACHE_MISS_CACHING_COUNT, BLOCK_COUNT_MISS_CACHING_COUNT_DESC), + rsWrap.getBlockCacheMissCachingCount()) .addCounter(Interns.info(BLOCK_CACHE_EVICTION_COUNT, BLOCK_CACHE_EVICTION_COUNT_DESC), rsWrap.getBlockCacheEvictedCount()) .addCounter( diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperImpl.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperImpl.java index 79ed5204ab2..26d3c050807 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperImpl.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperImpl.java @@ -328,6 +328,11 @@ class MetricsRegionServerWrapperImpl implements MetricsRegionServerWrapper { return this.cacheStats != null ? this.cacheStats.getPrimaryHitCount() : 0L; } + @Override + public long getBlockCacheHitCachingCount() { + return this.cacheStats != null ? this.cacheStats.getHitCachingCount() : 0L; + } + @Override public long getBlockCacheMissCount() { return this.cacheStats != null ? this.cacheStats.getMissCount() : 0L; @@ -338,6 +343,11 @@ class MetricsRegionServerWrapperImpl implements MetricsRegionServerWrapper { return this.cacheStats != null ? this.cacheStats.getPrimaryMissCount() : 0L; } + @Override + public long getBlockCacheMissCachingCount() { + return this.cacheStats != null ? this.cacheStats.getMissCachingCount() : 0L; + } + @Override public long getBlockCacheEvictedCount() { return this.cacheStats != null ? this.cacheStats.getEvictedCount() : 0L; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperStub.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperStub.java index bf514ef53b1..3ed0dab52e7 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperStub.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperStub.java @@ -322,6 +322,11 @@ public class MetricsRegionServerWrapperStub implements MetricsRegionServerWrappe return 422; } + @Override + public long getBlockCacheHitCachingCount() { + return 16; + } + @Override public long getBlockCacheMissCount() { return 417; @@ -332,6 +337,11 @@ public class MetricsRegionServerWrapperStub implements MetricsRegionServerWrappe return 421; } + @Override + public long getBlockCacheMissCachingCount() { + return 17; + } + @Override public long getBlockCacheEvictedCount() { return 418; diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegionServer.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegionServer.java index 82d50900376..891ae280511 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegionServer.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegionServer.java @@ -111,7 +111,9 @@ public class TestMetricsRegionServer { HELPER.assertGauge("blockCacheDataBlockCount", 300, serverSource); HELPER.assertGauge("blockCacheSize", 415, serverSource); HELPER.assertCounter("blockCacheHitCount", 416, serverSource); + HELPER.assertCounter("blockCacheHitCachingCount", 16, serverSource); HELPER.assertCounter("blockCacheMissCount", 417, serverSource); + HELPER.assertCounter("blockCacheMissCachingCount", 17, serverSource); HELPER.assertCounter("blockCacheEvictionCount", 418, serverSource); HELPER.assertGauge("blockCacheCountHitPercent", 98, serverSource); HELPER.assertGauge("blockCacheExpressHitPercent", 97, serverSource);