hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From syuanji...@apache.org
Subject [03/17] hbase git commit: HBASE-14778 Make block cache hit percentages not integer in the metrics system
Date Thu, 12 Nov 2015 21:58:52 GMT
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/ea795213
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/ea795213
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/ea795213

Branch: refs/heads/hbase-12439
Commit: ea795213b216d8d58cce10bb6336d6fa9e54f3ab
Parents: 1a6ec1b
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:25:59 2015 -0800

----------------------------------------------------------------------
 .../MetricsRegionServerWrapper.java             | 14 +++---
 .../MetricsRegionServerWrapperImpl.java         | 47 ++++++++++++--------
 .../MetricsRegionServerWrapperStub.java         |  8 ++--
 3 files changed, 40 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/ea795213/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 05800c2..7851770 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.
@@ -341,20 +341,20 @@ public interface MetricsRegionServerWrapper {
   /**
    * Gets the hit percent to the mob file cache.
    */
-  int getMobFileCacheHitPercent();
+  double getMobFileCacheHitPercent();
 
   /**
    * @return Count of hedged read operations
    */
-  public long getHedgedReadOps();
+  long getHedgedReadOps();
 
   /**
    * @return Count of times a hedged read beat out the primary read.
    */
-  public long getHedgedReadWins();
+  long getHedgedReadWins();
 
   /**
    * @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/ea795213/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 8ad1f33..b206749 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
@@ -74,8 +74,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;
@@ -330,15 +330,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() {
@@ -425,12 +435,12 @@ class MetricsRegionServerWrapperImpl
   }
 
   @Override
-  public int getPercentFileLocal() {
+  public double getPercentFileLocal() {
     return percentFileLocal;
   }
 
   @Override
-  public int getPercentFileLocalSecondaryRegions() {
+  public double getPercentFileLocalSecondaryRegions() {
     return percentFileLocalSecondaryRegions;
   }
 
@@ -538,8 +548,8 @@ class MetricsRegionServerWrapperImpl
   }
 
   @Override
-  public int getMobFileCacheHitPercent() {
-    return (int) (mobFileCacheHitRatio * 100);
+  public double getMobFileCacheHitPercent() {
+    return mobFileCacheHitRatio * 100;
   }
 
   /**
@@ -572,8 +582,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;
@@ -589,7 +599,7 @@ class MetricsRegionServerWrapperImpl
       long tempMobFlushedCellsSize = 0;
       long tempMobScanCellsCount = 0;
       long tempMobScanCellsSize = 0;
-      long tempBlockedRequestsCount = 0L;
+      long tempBlockedRequestsCount = 0;
 
       for (Region r : regionServer.getOnlineRegionsLocalContext()) {
         tempNumMutationsWithoutWAL += r.getNumMutationsWithoutWAL();
@@ -636,13 +646,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.
@@ -650,7 +661,7 @@ class MetricsRegionServerWrapperImpl
       if (lastRan == 0) {
         lastRan = currentTime - period;
       }
-      //If we've time traveled keep the last requests per second.
+      // If we've time traveled keep the last requests per second.
       if ((currentTime - lastRan) > 0) {
         long currentRequestCount = getTotalRequestCount();
         requestsPerSecond = (currentRequestCount - lastRequestCount) /
@@ -665,7 +676,7 @@ class MetricsRegionServerWrapperImpl
           (metaProvider == null ? 0 : metaProvider.getNumLogFiles());
       walFileSize = (provider == null ? 0 : provider.getLogFileSize()) +
           (provider == null ? 0 : provider.getLogFileSize());
-      //Copy over computed values so that no thread sees half computed values.
+      // Copy over computed values so that no thread sees half computed values.
       numStores = tempNumStores;
       numStoreFiles = tempNumStoreFiles;
       memstoreSize = tempMemstoreSize;
@@ -698,7 +709,7 @@ class MetricsRegionServerWrapperImpl
       mobScanCellsSize = tempMobScanCellsSize;
       mobFileCacheAccessCount = mobFileCache.getAccessCount();
       mobFileCacheMissCount = mobFileCache.getMissCount();
-      mobFileCacheHitRatio = mobFileCache.getHitRatio();
+      mobFileCacheHitRatio = Double.isNaN(mobFileCache.getHitRatio())?0:mobFileCache.getHitRatio();
       mobFileCacheEvictedCount = mobFileCache.getEvictedFileCount();
       mobFileCacheCount = mobFileCache.getCacheSize();
       blockedRequestsCount = tempBlockedRequestsCount;

http://git-wip-us.apache.org/repos/asf/hbase/blob/ea795213/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 a74461f..1c3e8bf 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;
   }
 
@@ -347,7 +347,7 @@ public class MetricsRegionServerWrapperStub implements MetricsRegionServerWrappe
   }
 
   @Override
-  public int getMobFileCacheHitPercent() {
+  public double getMobFileCacheHitPercent() {
     return 50;
   }
 }


Mime
View raw message