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 5220f2d82b23..75269e571816 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
@@ -632,4 +632,6 @@ public interface MetricsRegionServerSource extends BaseSource, JvmPauseMonitorSo
String SCANNER_LEASE_EXPIRED_COUNT = "scannerLeaseExpiredCount";
String SCANNER_LEASE_EXPIRED_COUNT_DESC =
"Count of scanners which were expired due to scanner lease timeout";
+ String CURRENT_REGION_CACHE_RATIO = "currentRegionCacheRatio";
+ String CURRENT_REGION_CACHE_RATIO_DESC = "The percentage of caching completed for this region.";
}
diff --git a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionWrapper.java b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionWrapper.java
index 3115603aabfc..4d8a028d89b1 100644
--- a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionWrapper.java
+++ b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionWrapper.java
@@ -65,6 +65,11 @@ public interface MetricsRegionWrapper {
*/
long getStoreFileSize();
+ /**
+ * Gets the current cache % ratio for this region.
+ */
+ float getCurrentRegionCacheRatio();
+
/**
* Get the total number of read requests that have been issued against this region
*/
diff --git a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionSourceImpl.java b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionSourceImpl.java
index 0c20456e8cb6..92ecaa580885 100644
--- a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionSourceImpl.java
+++ b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionSourceImpl.java
@@ -233,6 +233,10 @@ void snapshot(MetricsRecordBuilder mrb, boolean ignored) {
this.regionWrapper.getNumReferenceFiles());
mrb.addGauge(Interns.info(regionNamePrefix + MetricsRegionServerSource.STOREFILE_SIZE,
MetricsRegionServerSource.STOREFILE_SIZE_DESC), this.regionWrapper.getStoreFileSize());
+ mrb.addGauge(
+ Interns.info(regionNamePrefix + MetricsRegionServerSource.CURRENT_REGION_CACHE_RATIO,
+ MetricsRegionServerSource.CURRENT_REGION_CACHE_RATIO_DESC),
+ this.regionWrapper.getCurrentRegionCacheRatio());
mrb.addCounter(
Interns.info(regionNamePrefix + MetricsRegionSource.COMPACTIONS_COMPLETED_COUNT,
MetricsRegionSource.COMPACTIONS_COMPLETED_DESC),
diff --git a/hbase-hadoop2-compat/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegionSourceImpl.java b/hbase-hadoop2-compat/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegionSourceImpl.java
index 3fe116a11a77..2c8205085d1e 100644
--- a/hbase-hadoop2-compat/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegionSourceImpl.java
+++ b/hbase-hadoop2-compat/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegionSourceImpl.java
@@ -116,6 +116,11 @@ public long getStoreFileSize() {
return 0;
}
+ @Override
+ public float getCurrentRegionCacheRatio() {
+ return 0;
+ }
+
@Override
public long getReadRequestCount() {
return 0;
diff --git a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/RegionListTmpl.jamon b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/RegionListTmpl.jamon
index 0df4d2763b0b..e77318437e04 100644
--- a/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/RegionListTmpl.jamon
+++ b/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/regionserver/RegionListTmpl.jamon
@@ -38,6 +38,7 @@
org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos.RegionLoad;
org.apache.hadoop.hbase.client.RegionReplicaUtil;
org.apache.hadoop.hbase.regionserver.MetricsRegionWrapper;
+ org.apache.hadoop.util.StringUtils;
org.apache.hadoop.util.StringUtils.TraditionalBinaryPrefix;
%import>
<%if (onlineRegions != null && onlineRegions.size() > 0) %>
@@ -172,6 +173,7 @@
Bloom Size |
Data Locality |
Len Of Biggest Cell |
+ % Cached |
@@ -237,6 +239,7 @@
<% bloomSizeStr %> |
<% load.getDataLocality() %> |
<% String.format("%,1d", lenOfBiggestCellInRegion) %> |
+ <% StringUtils.formatPercent(load.getCurrentRegionCachedRatio(), 2) %> |
%if>
%for>
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/BlockCache.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/BlockCache.java
index ed9e7dee5c11..5b11035ebe73 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/BlockCache.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/BlockCache.java
@@ -154,21 +154,16 @@ default boolean isMetaBlock(BlockType blockType) {
/**
* Notifies the cache implementation that the given file has been fully cached (all its blocks
* made into the cache).
- * @param fileName the file that has been completely cached.
+ * @param fileName the file that has been completely cached.
+ * @param totalBlockCount the total of blocks cached for this file.
+ * @param dataBlockCount number of DATA block type cached.
+ * @param size the size, in bytes, cached.
*/
default void notifyFileCachingCompleted(Path fileName, int totalBlockCount, int dataBlockCount,
long size) {
// noop
}
- /**
- * Notifies the cache implementation that the given file had a block evicted
- * @param fileName the file had a block evicted.
- */
- default void notifyFileBlockEvicted(String fileName) {
- // noop
- }
-
/**
* Checks whether there's enough space left in the cache to accommodate the passed block. This
* method may not be overridden by all implementing classes. In such cases, the returned Optional
@@ -230,4 +225,14 @@ default Optional getBlockSize(BlockCacheKey key) {
default Optional