diff --git a/CHANGES.txt b/CHANGES.txt index 1570e805739..dddf2dcc98a 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -16,6 +16,8 @@ Release 0.91.0 - Unreleased HBASE-2001 Coprocessors: Colocate user code with regions (Mingjie Lai via Andrew Purtell) HBASE-3290 Max Compaction Size (Nicolas Spiegelberg via Stack) + HBASE-3292 Expose block cache hit/miss/evict counts into region server + metrics NEW FEATURES HBASE-3287 Add option to cache blocks on hfile write and evict blocks on diff --git a/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java b/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java index 2c711be3285..26b4c10a626 100644 --- a/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java +++ b/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java @@ -94,6 +94,7 @@ import org.apache.hadoop.hbase.client.coprocessor.ExecResult; import org.apache.hadoop.hbase.executor.ExecutorService; import org.apache.hadoop.hbase.executor.ExecutorService.ExecutorType; import org.apache.hadoop.hbase.io.hfile.LruBlockCache; +import org.apache.hadoop.hbase.io.hfile.LruBlockCache.CacheStats; import org.apache.hadoop.hbase.ipc.CoprocessorProtocol; import org.apache.hadoop.hbase.ipc.HBaseRPC; import org.apache.hadoop.hbase.ipc.HBaseRPCErrorHandler; @@ -1161,6 +1162,10 @@ public class HRegionServer implements HRegionInterface, HBaseRPCErrorHandler, this.metrics.blockCacheCount.set(lruBlockCache.size()); this.metrics.blockCacheFree.set(lruBlockCache.getFreeSize()); this.metrics.blockCacheSize.set(lruBlockCache.getCurrentSize()); + CacheStats cacheStats = lruBlockCache.getStats(); + this.metrics.blockCacheHitCount.set(cacheStats.getHitCount()); + this.metrics.blockCacheMissCount.set(cacheStats.getMissCount()); + this.metrics.blockCacheEvictedCount.set(lruBlockCache.getEvictedCount()); double ratio = lruBlockCache.getStats().getHitRatio(); int percent = (int) (ratio * 100); this.metrics.blockCacheHitRatio.set(percent); diff --git a/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/RegionServerMetrics.java b/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/RegionServerMetrics.java index b3072565061..8b0b43f0038 100644 --- a/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/RegionServerMetrics.java +++ b/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/RegionServerMetrics.java @@ -86,6 +86,21 @@ public class RegionServerMetrics implements Updater { */ public final MetricsLongValue blockCacheCount = new MetricsLongValue("blockCacheCount", registry); + /** + * Block cache hit count. + */ + public final MetricsLongValue blockCacheHitCount = new MetricsLongValue("blockCacheHitCount", registry); + + /** + * Block cache miss count. + */ + public final MetricsLongValue blockCacheMissCount = new MetricsLongValue("blockCacheMissCount", registry); + + /** + * Block cache evict count. + */ + public final MetricsLongValue blockCacheEvictedCount = new MetricsLongValue("blockCacheEvictedCount", registry); + /** * Block hit ratio. */ @@ -228,6 +243,9 @@ public class RegionServerMetrics implements Updater { this.blockCacheSize.pushMetric(this.metricsRecord); this.blockCacheFree.pushMetric(this.metricsRecord); this.blockCacheCount.pushMetric(this.metricsRecord); + this.blockCacheHitCount.pushMetric(this.metricsRecord); + this.blockCacheMissCount.pushMetric(this.metricsRecord); + this.blockCacheEvictedCount.pushMetric(this.metricsRecord); this.blockCacheHitRatio.pushMetric(this.metricsRecord); this.blockCacheHitCachingRatio.pushMetric(this.metricsRecord); @@ -336,6 +354,12 @@ public class RegionServerMetrics implements Updater { Long.valueOf(this.blockCacheFree.get())); sb = Strings.appendKeyValue(sb, this.blockCacheCount.getName(), Long.valueOf(this.blockCacheCount.get())); + sb = Strings.appendKeyValue(sb, this.blockCacheHitCount.getName(), + Long.valueOf(this.blockCacheHitCount.get())); + sb = Strings.appendKeyValue(sb, this.blockCacheMissCount.getName(), + Long.valueOf(this.blockCacheMissCount.get())); + sb = Strings.appendKeyValue(sb, this.blockCacheEvictedCount.getName(), + Long.valueOf(this.blockCacheEvictedCount.get())); sb = Strings.appendKeyValue(sb, this.blockCacheHitRatio.getName(), Long.valueOf(this.blockCacheHitRatio.get())); sb = Strings.appendKeyValue(sb, this.blockCacheHitCachingRatio.getName(),