hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject hbase git commit: HBASE-13369 Expose scanNext stats to region server level
Date Tue, 31 Mar 2015 22:27:49 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 f1601c0d1 -> bb65a8664


HBASE-13369 Expose scanNext stats to region server level


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

Branch: refs/heads/branch-1
Commit: bb65a8664ddf5824d278cc03dc6e41635f99eb83
Parents: f1601c0
Author: tedyu <yuzhihong@gmail.com>
Authored: Tue Mar 31 15:27:39 2015 -0700
Committer: tedyu <yuzhihong@gmail.com>
Committed: Tue Mar 31 15:27:39 2015 -0700

----------------------------------------------------------------------
 .../regionserver/MetricsRegionServerSource.java |  7 +++
 .../MetricsRegionServerSourceImpl.java          |  7 +++
 .../hbase/regionserver/MetricsRegionServer.java |  4 ++
 .../hbase/regionserver/RSRpcServices.java       |  3 ++
 .../regionserver/TestRegionServerMetrics.java   | 57 ++++++++++++++++++--
 5 files changed, 75 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/bb65a866/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSource.java
----------------------------------------------------------------------
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 a52090d..4c9296a 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
@@ -88,6 +88,13 @@ public interface MetricsRegionServerSource extends BaseSource {
   void updateReplay(long t);
 
   /**
+   * Update the scan size.
+   *
+   * @param scanSize size of the scan
+   */
+  void updateScannerNext(long scanSize);
+
+  /**
    * Increment the number of slow Puts that have happened.
    */
   void incrSlowPut();

http://git-wip-us.apache.org/repos/asf/hbase/blob/bb65a866/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSourceImpl.java
----------------------------------------------------------------------
diff --git a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSourceImpl.java
b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSourceImpl.java
index dc64e68..de629c8 100644
--- a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSourceImpl.java
+++ b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSourceImpl.java
@@ -42,6 +42,7 @@ public class MetricsRegionServerSourceImpl
   private final MetricHistogram incrementHisto;
   private final MetricHistogram appendHisto;
   private final MetricHistogram replayHisto;
+  private final MetricHistogram scanNextHisto;
 
   private final MutableCounterLong slowPut;
   private final MutableCounterLong slowDelete;
@@ -82,6 +83,7 @@ public class MetricsRegionServerSourceImpl
     slowAppend = getMetricsRegistry().newCounter(SLOW_APPEND_KEY, SLOW_APPEND_DESC, 0l);
     
     replayHisto = getMetricsRegistry().newHistogram(REPLAY_KEY);
+    scanNextHisto = getMetricsRegistry().newHistogram(SCAN_NEXT_KEY);
 
     splitTimeHisto = getMetricsRegistry().newHistogram(SPLIT_KEY);
     flushTimeHisto = getMetricsRegistry().newHistogram(FLUSH_KEY);
@@ -121,6 +123,11 @@ public class MetricsRegionServerSourceImpl
   }
 
   @Override
+  public void updateScannerNext(long scanSize) {
+    scanNextHisto.add(scanSize);
+  }
+
+  @Override
   public void incrSlowPut() {
    slowPut.incr();
   }

http://git-wip-us.apache.org/repos/asf/hbase/blob/bb65a866/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServer.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServer.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServer.java
index c3bf97e..9f98ba6 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServer.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServer.java
@@ -95,6 +95,10 @@ public class MetricsRegionServer {
     serverSource.updateReplay(t);
   }
 
+  public void updateScannerNext(long scanSize){
+    serverSource.updateScannerNext(scanSize);
+  }
+
   public void updateSplitTime(long t) {
     serverSource.updateSplitTime(t);
   }

http://git-wip-us.apache.org/repos/asf/hbase/blob/bb65a866/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
index 341ff3a..bb446d1 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java
@@ -2284,6 +2284,9 @@ public class RSRpcServices implements HBaseRPCErrorHandler,
               }
               region.updateReadRequestsCount(i);
               region.getMetrics().updateScanNext(totalCellSize);
+              if (regionServer.metricsRegionServer != null) {
+                regionServer.metricsRegionServer.updateScannerNext(totalCellSize);
+              }
             } finally {
               region.closeRegionOperation();
             }

http://git-wip-us.apache.org/repos/asf/hbase/blob/bb65a866/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerMetrics.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerMetrics.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerMetrics.java
index 0f80e42..4641d18 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerMetrics.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerMetrics.java
@@ -52,6 +52,8 @@ public class TestRegionServerMetrics {
   private static HBaseTestingUtility TEST_UTIL;
   private static MetricsRegionServer metricsRegionServer;
   private static MetricsRegionServerSource serverSource;
+  private static final int NUM_SCAN_NEXT = 30;
+  private static int numScanNext = 0;
 
   @BeforeClass
   public static void startCluster() throws Exception {
@@ -342,7 +344,6 @@ public class TestRegionServerMetrics {
     byte[] qualifier = Bytes.toBytes("qual");
     byte[] val = Bytes.toBytes("One");
 
-
     List<Put> puts = new ArrayList<>();
     for (int insertCount =0; insertCount < 100; insertCount++) {
       Put p = new Put(Bytes.toBytes("" + insertCount + "row"));
@@ -357,12 +358,13 @@ public class TestRegionServerMetrics {
       s.setCaching(1);
       ResultScanner resultScanners = t.getScanner(s);
 
-      for (int nextCount = 0; nextCount < 30; nextCount++) {
+      for (int nextCount = 0; nextCount < NUM_SCAN_NEXT; nextCount++) {
         Result result = resultScanners.next();
         assertNotNull(result);
         assertEquals(1, result.size());
       }
     }
+    numScanNext += NUM_SCAN_NEXT;
     try (RegionLocator locator = TEST_UTIL.getConnection().getRegionLocator(tableName)) {
       for ( HRegionLocation location: locator.getAllRegionLocations()) {
         HRegionInfo i = location.getRegionInfo();
@@ -374,8 +376,57 @@ public class TestRegionServerMetrics {
             "_table_"+tableNameString +
             "_region_" + i.getEncodedName()+
             "_metric";
-        metricsHelper.assertCounter(prefix + "_scanNextNumOps", 30, agg);
+        metricsHelper.assertCounter(prefix + "_scanNextNumOps", NUM_SCAN_NEXT, agg);
+      }
+      metricsHelper.assertCounterGt("ScanNext_num_ops", numScanNext, serverSource);
+    }
+  }
+
+  @Test
+  public void testScanNextForSmallScan() throws IOException {
+    String tableNameString = "testScanNextSmall";
+    TableName tableName = TableName.valueOf(tableNameString);
+    byte[] cf = Bytes.toBytes("d");
+    byte[] qualifier = Bytes.toBytes("qual");
+    byte[] val = Bytes.toBytes("One");
+
+    List<Put> puts = new ArrayList<>();
+    for (int insertCount =0; insertCount < 100; insertCount++) {
+      Put p = new Put(Bytes.toBytes("" + insertCount + "row"));
+      p.add(cf, qualifier, val);
+      puts.add(p);
+    }
+    try (HTable t = TEST_UTIL.createTable(tableName, cf)) {
+      t.put(puts);
+
+      Scan s = new Scan();
+      s.setSmall(true);
+      s.setCaching(1);
+      ResultScanner resultScanners = t.getScanner(s);
+
+      for (int nextCount = 0; nextCount < NUM_SCAN_NEXT; nextCount++) {
+        Result result = resultScanners.next();
+        assertNotNull(result);
+        assertEquals(1, result.size());
+      }
+    }
+    numScanNext += NUM_SCAN_NEXT;
+    try (RegionLocator locator = TEST_UTIL.getConnection().getRegionLocator(tableName)) {
+      int cnt = 0;
+      for (HRegionLocation location: locator.getAllRegionLocations()) {
+        cnt++;
+        HRegionInfo i = location.getRegionInfo();
+        MetricsRegionAggregateSource agg = rs.getRegion(i.getRegionName())
+            .getMetrics()
+            .getSource()
+            .getAggregateSource();
+        String prefix = "namespace_"+NamespaceDescriptor.DEFAULT_NAMESPACE_NAME_STR+
+            "_table_"+tableNameString +
+            "_region_" + i.getEncodedName()+
+            "_metric";
+        metricsHelper.assertCounter(prefix + "_scanNextNumOps", NUM_SCAN_NEXT, agg);
       }
+      metricsHelper.assertCounterGt("ScanNext_num_ops", numScanNext, serverSource);
     }
   }
 }


Mime
View raw message