hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject hbase git commit: HBASE-13369 Expose scanNext stats to region server level
Date Sat, 25 Apr 2015 19:18:58 GMT
Repository: hbase
Updated Branches:
  refs/heads/0.98 a401a45e4 -> 612598de3


HBASE-13369 Expose scanNext stats to region server level

Amending-Author: Andrew Purtell <apurtell@apache.org>

Conflicts:
	hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestRegionServerMetrics.java


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

Branch: refs/heads/0.98
Commit: 612598de3fb1ea096944dcbbf7ebe614120b9b9a
Parents: a401a45
Author: tedyu <yuzhihong@gmail.com>
Authored: Tue Mar 31 15:25:36 2015 -0700
Committer: Andrew Purtell <apurtell@apache.org>
Committed: Sat Apr 25 11:40:52 2015 -0700

----------------------------------------------------------------------
 .../regionserver/MetricsRegionServerSource.java |  7 +++
 .../MetricsRegionServerSourceImpl.java          |  8 +++
 .../MetricsRegionServerSourceImpl.java          |  7 +++
 .../hbase/regionserver/HRegionServer.java       |  3 +
 .../hbase/regionserver/MetricsRegionServer.java |  4 ++
 .../regionserver/TestRegionServerMetrics.java   | 63 ++++++++++++++++++--
 6 files changed, 88 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/612598de/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 9af6de2..2b21f11 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/612598de/hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSourceImpl.java
----------------------------------------------------------------------
diff --git a/hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSourceImpl.java
b/hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSourceImpl.java
index e08adde..0d8a010 100644
--- a/hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSourceImpl.java
+++ b/hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionServerSourceImpl.java
@@ -39,6 +39,8 @@ public class MetricsRegionServerSourceImpl
   private final MetricHistogram incrementHisto;
   private final MetricHistogram appendHisto;
   private final MetricHistogram replayHisto;
+  private final MetricHistogram scanNextHisto;
+
   private final MetricMutableCounterLong slowPut;
   private final MetricMutableCounterLong slowDelete;
   private final MetricMutableCounterLong slowGet;
@@ -78,6 +80,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);
@@ -117,6 +120,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/612598de/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 934a4f6..71e1d28 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/612598de/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
index 0ee03c2..db3edaf 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/HRegionServer.java
@@ -3311,6 +3311,9 @@ public class HRegionServer implements ClientProtos.ClientService.BlockingInterfa
               }
               region.readRequestsCount.add(i);
               region.getMetrics().updateScanNext(totalKvSize);
+              if (metricsRegionServer != null) {
+                metricsRegionServer.updateScannerNext(totalKvSize);
+              }
             } finally {
               region.closeRegionOperation();
             }

http://git-wip-us.apache.org/repos/asf/hbase/blob/612598de/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/612598de/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 3757e66..cad3d93 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
@@ -54,8 +54,9 @@ public class TestRegionServerMetrics {
   private static HBaseTestingUtility TEST_UTIL;
   private static MetricsRegionServer metricsRegionServer;
   private static MetricsRegionServerSource serverSource;
+  private static final int NUM_SCAN_NEXT = 30;
 
-  @BeforeClass
+  @BeforeClass  
   public static void startCluster() throws Exception {
     metricsHelper = CompatibilityFactory.getInstance(MetricsAssertHelper.class);
     TEST_UTIL = new HBaseTestingUtility();
@@ -355,7 +356,6 @@ public class TestRegionServerMetrics {
     byte[] qualifier = Bytes.toBytes("qual");
     byte[] val = Bytes.toBytes("One");
 
-
     TEST_UTIL.createTable(tableName, cf);
     HTable t = new HTable(conf, tableName);
     t.setAutoFlush(false, true);
@@ -371,11 +371,62 @@ public class TestRegionServerMetrics {
     s.setCaching(1);
     ResultScanner resultScanners = t.getScanner(s);
 
-    for (int nextCount = 0; nextCount < 30; nextCount++) {
+    long numScanNext = metricsHelper.getCounter("ScanNext_num_ops", serverSource);
+    for (int nextCount = 0; nextCount < NUM_SCAN_NEXT; nextCount++) {
+      Result result = resultScanners.next();
+      assertNotNull(result);
+      assertEquals(1, result.size());
+    }
+    numScanNext += NUM_SCAN_NEXT;
+    metricsHelper.assertCounter("ScanNext_num_ops", numScanNext, serverSource);
+    for ( HRegionInfo i:t.getRegionLocations().keySet()) {
+      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);
+    }
+
+    HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
+    admin.disableTable(tableName);
+    admin.deleteTable(tableName);
+  }
+
+  @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");
+
+    TEST_UTIL.createTable(tableName, cf);
+    HTable t = new HTable(conf, tableName);
+    t.setAutoFlush(false, true);
+    for (int insertCount =0; insertCount < 100; insertCount++) {
+      Put p = new Put(Bytes.toBytes("" + insertCount + "row"));
+      p.add(cf, qualifier, val);
+      t.put(p);
+    }
+    t.flushCommits();
+
+    Scan s = new Scan();
+    s.setSmall(true);
+    s.setCaching(1);
+    ResultScanner resultScanners = t.getScanner(s);
+
+    long numScanNext = metricsHelper.getCounter("ScanNext_num_ops", serverSource);
+    for (int nextCount = 0; nextCount < NUM_SCAN_NEXT; nextCount++) {
       Result result = resultScanners.next();
       assertNotNull(result);
       assertEquals(1, result.size());
     }
+    numScanNext += NUM_SCAN_NEXT;
+    metricsHelper.assertCounter("ScanNext_num_ops", numScanNext, serverSource);
     for ( HRegionInfo i:t.getRegionLocations().keySet()) {
       MetricsRegionAggregateSource agg = rs.getRegion(i.getRegionName())
           .getMetrics()
@@ -385,7 +436,11 @@ public class TestRegionServerMetrics {
           "_table_"+tableNameString +
           "_region_" + i.getEncodedName()+
           "_metric";
-      metricsHelper.assertCounter(prefix + "_scanNextNumOps", 30, agg);
+      metricsHelper.assertCounter(prefix + "_scanNextNumOps", NUM_SCAN_NEXT, agg);
     }
+
+    HBaseAdmin admin = TEST_UTIL.getHBaseAdmin();
+    admin.disableTable(tableName);
+    admin.deleteTable(tableName);
   }
 }


Mime
View raw message