You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by li...@apache.org on 2014/02/26 20:18:45 UTC

svn commit: r1572209 - in /hbase/branches/0.89-fb/src: main/java/org/apache/hadoop/hbase/regionserver/metrics/SchemaMetrics.java test/java/org/apache/hadoop/hbase/client/TestFromClientSide4.java

Author: liyin
Date: Wed Feb 26 19:18:45 2014
New Revision: 1572209

URL: http://svn.apache.org/r1572209
Log:
[0.89-fb] [HBASE-10291] Fix TestFromClientSide4

Author: arjen

Summary: Several of the tests in TestFromClientSide4 put some assertions on cache behavior and would test these using metrics. These assumptions changed however in D1112816, causing these tests to fail.

Test Plan: TestFromClientSide4 tests pass.

Reviewers: manukranthk, daviddeng

Reviewed By: manukranthk

Differential Revision: https://phabricator.fb.com/D1190804

Task ID: 3762230

Modified:
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/SchemaMetrics.java
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide4.java

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/SchemaMetrics.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/SchemaMetrics.java?rev=1572209&r1=1572208&r2=1572209&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/SchemaMetrics.java (original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/SchemaMetrics.java Wed Feb 26 19:18:45 2014
@@ -544,13 +544,21 @@ public class SchemaMetrics {
       boolean preload) {
     addToReadTime(blockCategory, isCompaction, timeMs);
     if (l1Cached || l2Cached) {
-      if (l1Cached) updateOnCacheHit(blockCategory, isCompaction);
-      if (l2Cached) updateOnL2CacheHit(blockCategory, isCompaction);
-      if (preload) updateOnPreloadCacheHit(blockCategory, isCompaction, timeMs);
+      if (l1Cached) {
+        updateOnCacheHit(blockCategory, isCompaction);
+      }
+      if (l2Cached) {
+        updateOnL2CacheHit(blockCategory, isCompaction);
+      }
+      if (preload) {
+        updateOnPreloadCacheHit(blockCategory, isCompaction, timeMs);
+      }
     } else {
       updateOnCacheMiss(blockCategory, isCompaction);
       updateOnL2CacheMiss(blockCategory, isCompaction);
-      if (preload) updateOnPreloadCacheMiss(blockCategory, isCompaction, timeMs);
+      if (preload) {
+        updateOnPreloadCacheMiss(blockCategory, isCompaction, timeMs);
+      }
     }
 
     if (this != ALL_SCHEMA_METRICS) {

Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide4.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide4.java?rev=1572209&r1=1572208&r2=1572209&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide4.java (original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide4.java Wed Feb 26 19:18:45 2014
@@ -152,8 +152,9 @@ public class TestFromClientSide4 {
           BlockMetricType.PRELOAD_CACHE_MISS, BlockCategory.DATA, false));
     // All the three values should be positive
     assertTrue(misses > 0 && hits > 0 && preloaderMiss > 0);
-    // Check that the cache misses ratio is at most 1/100
-    assertTrue(misses * 100 <= hits + misses);
+    // The blocks read by the preloader should always be less than or equal to
+    // the total number of misses.
+    assertTrue(preloaderMiss <= misses);
   }
 
   @Test
@@ -272,8 +273,9 @@ public class TestFromClientSide4 {
     assertTrue(misses > 0 && hits > 0 && preloaderMiss > 0);
     // Check that at least nine tenth of the blocks read by the preloader is used by the scanner
     assertTrue(9 * preloaderMiss <= 10 * hits);
-    // Check that the cache misses ratio is at most 1/10
-    assertTrue(misses * 10 <= hits + misses);
+    // The blocks read by the preloader should always be less than or equal to
+    // the total number of misses.
+    assertTrue(preloaderMiss <= misses);
   }
 
   @Test