hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ecl...@apache.org
Subject hbase git commit: HBASE-14778 Make block cache hit percentages not integer in the metrics system
Date Tue, 10 Nov 2015 20:29:52 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1.2 f4c70bfc1 -> 444e40134


HBASE-14778 Make block cache hit percentages not integer in the metrics system


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/444e4013
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/444e4013
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/444e4013

Branch: refs/heads/branch-1.2
Commit: 444e4013480969ba6cdc4d7a0fecf1765e5432d4
Parents: f4c70bf
Author: Elliott Clark <eclark@apache.org>
Authored: Fri Nov 6 10:21:36 2015 -0800
Committer: Elliott Clark <eclark@apache.org>
Committed: Tue Nov 10 12:29:22 2015 -0800

----------------------------------------------------------------------
 .../MetricsRegionServerWrapper.java             |  8 ++---
 .../MetricsRegionServerWrapperImpl.java         | 36 +++++++++++++-------
 .../MetricsRegionServerWrapperStub.java         |  6 ++--
 3 files changed, 30 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/444e4013/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapper.java
----------------------------------------------------------------------
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 885d3a6..5ea81a3 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
@@ -151,12 +151,12 @@ public interface MetricsRegionServerWrapper {
   /**
    * Get the percent of HFiles' that are local.
    */
-  int getPercentFileLocal();
+  double getPercentFileLocal();
 
   /**
    * Get the percent of HFiles' that are local for secondary region replicas.
    */
-  int getPercentFileLocalSecondaryRegions();
+  double getPercentFileLocalSecondaryRegions();
 
   /**
    * Get the size of the split queue
@@ -231,7 +231,7 @@ public interface MetricsRegionServerWrapper {
   /**
    * Get the percent of requests with the block cache turned on that hit the block cache.
    */
-  int getBlockCacheHitCachingPercent();
+  double getBlockCacheHitCachingPercent();
 
   /**
    * Force a re-computation of the metrics.
@@ -276,5 +276,5 @@ public interface MetricsRegionServerWrapper {
   /**
    * @return Count of requests blocked because the memstore size is larger than blockingMemStoreSize
    */
-  public long getBlockedRequestsCount();
+  long getBlockedRequestsCount();
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/444e4013/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperImpl.java
----------------------------------------------------------------------
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 0a18fef..c83b70e 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
@@ -69,8 +69,8 @@ class MetricsRegionServerWrapperImpl
   private volatile long totalStaticBloomSize = 0;
   private volatile long numMutationsWithoutWAL = 0;
   private volatile long dataInMemoryWithoutWAL = 0;
-  private volatile int percentFileLocal = 0;
-  private volatile int percentFileLocalSecondaryRegions = 0;
+  private volatile double percentFileLocal = 0;
+  private volatile double percentFileLocalSecondaryRegions = 0;
   private volatile long flushedCellsCount = 0;
   private volatile long compactedCellsCount = 0;
   private volatile long majorCompactedCellsCount = 0;
@@ -290,15 +290,25 @@ class MetricsRegionServerWrapperImpl
     if (this.cacheStats == null) {
       return 0;
     }
-    return (int) (this.cacheStats.getHitRatio() * 100);
+    double ratio = this.cacheStats.getHitRatio();
+    if (Double.isNaN(ratio)) {
+      ratio = 0;
+    }
+    return (ratio * 100);
   }
 
   @Override
-  public int getBlockCacheHitCachingPercent() {
+  public double getBlockCacheHitCachingPercent() {
     if (this.cacheStats == null) {
       return 0;
     }
-    return (int) (this.cacheStats.getHitCachingRatio() * 100);
+
+    double ratio = this.cacheStats.getHitCachingRatio();
+
+    if (Double.isNaN(ratio)) {
+      ratio = 0;
+    }
+    return (ratio * 100);
   }
 
   @Override public void forceRecompute() {
@@ -385,12 +395,12 @@ class MetricsRegionServerWrapperImpl
   }
 
   @Override
-  public int getPercentFileLocal() {
+  public double getPercentFileLocal() {
     return percentFileLocal;
   }
 
   @Override
-  public int getPercentFileLocalSecondaryRegions() {
+  public double getPercentFileLocalSecondaryRegions() {
     return percentFileLocalSecondaryRegions;
   }
 
@@ -465,8 +475,8 @@ class MetricsRegionServerWrapperImpl
       long tempTotalStaticBloomSize = 0;
       long tempNumMutationsWithoutWAL = 0;
       long tempDataInMemoryWithoutWAL = 0;
-      int tempPercentFileLocal = 0;
-      int tempPercentFileLocalSecondaryRegions = 0;
+      double tempPercentFileLocal = 0;
+      double tempPercentFileLocalSecondaryRegions = 0;
       long tempFlushedCellsCount = 0;
       long tempCompactedCellsCount = 0;
       long tempMajorCompactedCellsCount = 0;
@@ -509,13 +519,14 @@ class MetricsRegionServerWrapperImpl
 
       float localityIndex = hdfsBlocksDistribution.getBlockLocalityIndex(
           regionServer.getServerName().getHostname());
-      tempPercentFileLocal = (int) (localityIndex * 100);
+      tempPercentFileLocal = Double.isNaN(tempBlockedRequestsCount) ? 0 : (localityIndex
* 100);
 
       float localityIndexSecondaryRegions = hdfsBlocksDistributionSecondaryRegions
           .getBlockLocalityIndex(regionServer.getServerName().getHostname());
-      tempPercentFileLocalSecondaryRegions = (int) (localityIndexSecondaryRegions * 100);
+      tempPercentFileLocalSecondaryRegions =
+          Double.isNaN(localityIndexSecondaryRegions) ? 0 : (localityIndexSecondaryRegions
* 100);
 
-      //Compute the number of requests per second
+      // Compute the number of requests per second
       long currentTime = EnvironmentEdgeManager.currentTime();
 
       // assume that it took PERIOD seconds to start the executor.
@@ -524,7 +535,6 @@ class MetricsRegionServerWrapperImpl
         lastRan = currentTime - period;
       }
 
-
       //If we've time traveled keep the last requests per second.
       if ((currentTime - lastRan) > 0) {
         long currentRequestCount = getTotalRequestCount();

http://git-wip-us.apache.org/repos/asf/hbase/blob/444e4013/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerWrapperStub.java
----------------------------------------------------------------------
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 33fa5c3..65e4ebd 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
@@ -126,12 +126,12 @@ public class MetricsRegionServerWrapperStub implements MetricsRegionServerWrappe
   }
 
   @Override
-  public int getPercentFileLocal() {
+  public double getPercentFileLocal() {
     return 99;
   }
 
   @Override
-  public int getPercentFileLocalSecondaryRegions() {
+  public double getPercentFileLocalSecondaryRegions() {
     return 99;
   }
 
@@ -206,7 +206,7 @@ public class MetricsRegionServerWrapperStub implements MetricsRegionServerWrappe
   }
 
   @Override
-  public int getBlockCacheHitCachingPercent() {
+  public double getBlockCacheHitCachingPercent() {
     return 97;
   }
 


Mime
View raw message