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:25:44 GMT
Repository: hbase
Updated Branches:
  refs/heads/master 619d34487 -> 64941c615


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/64941c61
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/64941c61
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/64941c61

Branch: refs/heads/master
Commit: 64941c6151b24dd48595327b3a2a0252389a3de8
Parents: 619d344
Author: tedyu <yuzhihong@gmail.com>
Authored: Tue Mar 31 15:25:36 2015 -0700
Committer: tedyu <yuzhihong@gmail.com>
Committed: Tue Mar 31 15:25:36 2015 -0700

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


http://git-wip-us.apache.org/repos/asf/hbase/blob/64941c61/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 518709e..e5c79ad 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/64941c61/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 0c9e7dc..fab2a49 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/64941c61/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/64941c61/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 b0fd9eb..a0761ec 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
@@ -2294,6 +2294,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/64941c61/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 3767513..d813575 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
@@ -53,6 +53,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 {
@@ -329,7 +331,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"));
@@ -344,12 +345,59 @@ 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();
+        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.assertCounter("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)) {
       for ( HRegionLocation location: locator.getAllRegionLocations()) {
         HRegionInfo i = location.getRegionInfo();
@@ -361,8 +409,9 @@ public class TestRegionServerMetrics {
             "_table_"+tableNameString +
             "_region_" + i.getEncodedName()+
             "_metric";
-        metricsHelper.assertCounter(prefix + "_scanNextNumOps", 30, agg);
+        metricsHelper.assertCounter(prefix + "_scanNextNumOps", NUM_SCAN_NEXT, agg);
       }
+      metricsHelper.assertCounter("ScanNext_num_ops", numScanNext, serverSource);
     }
   }
 }


Mime
View raw message