hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From li...@apache.org
Subject svn commit: r1426297 - in /hbase/branches/0.89-fb/src: main/java/org/apache/hadoop/hbase/regionserver/ test/java/org/apache/hadoop/hbase/regionserver/
Date Thu, 27 Dec 2012 19:18:48 GMT
Author: liyin
Date: Thu Dec 27 19:18:48 2012
New Revision: 1426297

URL: http://svn.apache.org/viewvc?rev=1426297&view=rev
Log:
[HBASE-7276] Fix TestRegionServerMetrics.testNumReadsAndWrites to work with the recent changes
in HRegion metrics.

Author: adela

Summary:
-removed read counter increase in close();
-changed increment of read operation during getScanner from HRegion to HRegionServer

Test Plan: unit test is passing now

Reviewers: liyintang, andrewl

Reviewed By: liyintang

CC: hbase-eng@, kannan

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

Task ID: 1981461

Modified:
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
    hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
    hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerMetrics.java

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java?rev=1426297&r1=1426296&r2=1426297&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
(original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java
Thu Dec 27 19:18:48 2012
@@ -1666,7 +1666,6 @@ public class HRegion implements HeapSize
   }
 
   protected InternalScanner getScanner(Scan scan, List<KeyValueScanner> additionalScanners)
throws IOException {
-    readRequests.incrTotalRequestCount();
     newScannerLock.readLock().lock();
     try {
       if (this.closed.get()) {
@@ -3401,7 +3400,6 @@ public class HRegion implements HeapSize
 
     @Override
     public synchronized void close() {
-      readRequests.incrTotalRequestCount();
       if (storeHeap != null) {
         storeHeap.close();
         storeHeap = null;

Modified: hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java?rev=1426297&r1=1426296&r2=1426297&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
(original)
+++ hbase/branches/0.89-fb/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
Thu Dec 27 19:18:48 2012
@@ -2573,6 +2573,7 @@ public class HRegionServer implements HR
     }
     try {
       HRegion r = getRegion(regionName);
+      r.getReadRequest().incrTotalRequestCount();
       return addScanner(r.getScanner(scan));
     } catch (Throwable t) {
       throw convertThrowableToIOE(cleanup(t, "Failed openScanner"));

Modified: hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerMetrics.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerMetrics.java?rev=1426297&r1=1426296&r2=1426297&view=diff
==============================================================================
--- hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerMetrics.java
(original)
+++ hbase/branches/0.89-fb/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerMetrics.java
Thu Dec 27 19:18:48 2012
@@ -22,7 +22,9 @@ import static org.junit.Assert.assertEqu
 import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.List;
 import java.util.Map;
 
 import org.apache.commons.logging.Log;
@@ -31,6 +33,8 @@ import org.apache.hadoop.conf.Configurat
 import org.apache.hadoop.hbase.HBaseTestingUtility;
 import org.apache.hadoop.hbase.HColumnDescriptor;
 import org.apache.hadoop.hbase.HConstants;
+import org.apache.hadoop.hbase.HRegionInfo;
+import org.apache.hadoop.hbase.HServerAddress;
 import org.apache.hadoop.hbase.HTestConst;
 import org.apache.hadoop.hbase.KeyValue;
 import org.apache.hadoop.hbase.client.Delete;
@@ -222,17 +226,17 @@ public class TestRegionServerMetrics {
         NUM_COLS_PER_ROW, NUM_FLUSHES, NUM_REGIONS, 1000);
     final HRegionServer rs =
         testUtil.getMiniHBaseCluster().getRegionServer(0);
-
-    // This may not be necessary since we verify the number of reads and writes from atomic
-    // variables and not from collected metrics.
-    rs.doMetrics(); 
     
-    for (HRegion r : rs.getOnlineRegions()) {
-      Get g = new Get(new byte[]{});
-      rs.get(r.getRegionName(), g);
+    HRegion[] regions = rs.getOnlineRegionsAsArray();
+    int reads = rs.getNumReads().get();
+    int writes = rs.getNumWrites().get();
+    for (int i=0; i<regions.length;  i++) {
+      Get g = new Get(Bytes.toBytes("row" + i));
+      regions[i].get(g, null);
     }
-    Assert.assertEquals(rs.getOnlineRegions().size(), rs.getNumReads().get());
-    Assert.assertEquals(0, rs.getNumWrites().get());
+    rs.doMetrics();
+    assertEquals(regions.length, (rs.getNumReads().get() - reads));
+    assertEquals(0, (rs.getNumWrites().get() - writes));
   }
 
   @Test
@@ -310,7 +314,7 @@ public class TestRegionServerMetrics {
     long startValue = HRegion.getNumericPersistentMetric(storeMetricFullName);
 
     int compactionThreshold = conf.getInt("hbase.hstore.compaction.min", 
-    		HConstants.DEFAULT_MIN_FILES_TO_COMPACT);
+        HConstants.DEFAULT_MIN_FILES_TO_COMPACT);
     for (int i=0; i<=compactionThreshold; i++) {
       String rowName = "row" + i;
       byte[] ROW = Bytes.toBytes(rowName);
@@ -349,6 +353,6 @@ public class TestRegionServerMetrics {
     long compactionWriteSizeAfterCompactionAfterDelete = 
       HRegion.getNumericPersistentMetric(storeMetricFullName);
     Assert.assertTrue(compactionWriteSizeAfterCompactionAfterDelete 
-    	              == compactionWriteSizeAfterCompaction);
+                    == compactionWriteSizeAfterCompaction);
   }
-}
\ No newline at end of file
+}



Mime
View raw message