hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e...@apache.org
Subject hbase git commit: HBASE-14082 Add replica id to JMX metrics names (Lei Chen)
Date Thu, 17 Sep 2015 02:12:37 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1.2 a229ac91f -> 9f420d0ac


HBASE-14082 Add replica id to JMX metrics names (Lei Chen)


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

Branch: refs/heads/branch-1.2
Commit: 9f420d0ac6175a7245efe68c27fc32458bca1b86
Parents: a229ac9
Author: Enis Soztutar <enis@apache.org>
Authored: Wed Sep 16 17:29:37 2015 -0700
Committer: Enis Soztutar <enis@apache.org>
Committed: Wed Sep 16 17:46:15 2015 -0700

----------------------------------------------------------------------
 .../hbase/regionserver/MetricsRegionSource.java |  2 ++
 .../regionserver/MetricsRegionWrapper.java      |  5 +++
 .../regionserver/MetricsRegionSourceImpl.java   |  3 ++
 .../TestMetricsRegionSourceImpl.java            |  8 +++++
 .../regionserver/MetricsRegionWrapperImpl.java  |  8 +++++
 .../regionserver/MetricsRegionWrapperStub.java  | 23 ++++++++++++++
 .../hbase/regionserver/TestMetricsRegion.java   | 32 ++++++++++++++++++--
 7 files changed, 78 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/9f420d0a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionSource.java
----------------------------------------------------------------------
diff --git a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionSource.java
b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionSource.java
index 8abbb1f..874be31 100644
--- a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionSource.java
+++ b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionSource.java
@@ -37,6 +37,8 @@ public interface MetricsRegionSource extends Comparable<MetricsRegionSource>
{
       "Number of files that were input for finished, successful or aborted, compactions";
   String COPROCESSOR_EXECUTION_STATISTICS = "coprocessorExecutionStatistics";
   String COPROCESSOR_EXECUTION_STATISTICS_DESC = "Statistics for coprocessor execution times";
+  String REPLICA_ID = "replicaid";
+  String REPLICA_ID_DESC = "The replica ID of a region. 0 is primary, otherwise is secondary";
 
   /**
    * Close the region's metrics as this region is closing.

http://git-wip-us.apache.org/repos/asf/hbase/blob/9f420d0a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionWrapper.java
----------------------------------------------------------------------
diff --git a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionWrapper.java
b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionWrapper.java
index cfc0b66..46bc37a 100644
--- a/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionWrapper.java
+++ b/hbase-hadoop-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionWrapper.java
@@ -90,4 +90,9 @@ public interface MetricsRegionWrapper {
    * Get the time spent by coprocessors in this region.
    */
   Map<String, DescriptiveStatistics> getCoprocessorExecutionStatistics();
+
+  /**
+   * Get the replica id of this region.
+   */
+  int getReplicaId();
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/9f420d0a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionSourceImpl.java
----------------------------------------------------------------------
diff --git a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionSourceImpl.java
b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionSourceImpl.java
index 0ecf2b2..bd123b9 100644
--- a/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionSourceImpl.java
+++ b/hbase-hadoop2-compat/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionSourceImpl.java
@@ -242,6 +242,9 @@ public class MetricsRegionSourceImpl implements MetricsRegionSource {
               regionNamePrefix + MetricsRegionServerSource.WRITE_REQUEST_COUNT,
               MetricsRegionServerSource.WRITE_REQUEST_COUNT_DESC),
           this.regionWrapper.getWriteRequestCount());
+      mrb.addCounter(Interns.info(regionNamePrefix + MetricsRegionSource.REPLICA_ID,
+              MetricsRegionSource.REPLICA_ID_DESC),
+          this.regionWrapper.getReplicaId());
 
       for (Map.Entry<String, DescriptiveStatistics> entry : this.regionWrapper
           .getCoprocessorExecutionStatistics()

http://git-wip-us.apache.org/repos/asf/hbase/blob/9f420d0a/hbase-hadoop2-compat/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegionSourceImpl.java
----------------------------------------------------------------------
diff --git a/hbase-hadoop2-compat/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegionSourceImpl.java
b/hbase-hadoop2-compat/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegionSourceImpl.java
index 9d60a8f..3242b67 100644
--- a/hbase-hadoop2-compat/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegionSourceImpl.java
+++ b/hbase-hadoop2-compat/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegionSourceImpl.java
@@ -133,5 +133,13 @@ public class TestMetricsRegionSourceImpl {
     public Map<String, DescriptiveStatistics> getCoprocessorExecutionStatistics() {
       return null;
     }
+
+    /**
+     * Always return 0 for testing
+     */
+    @Override
+    public int getReplicaId() {
+      return 0;
+    }
   }
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/9f420d0a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionWrapperImpl.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionWrapperImpl.java
b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionWrapperImpl.java
index 78df787..3f1da85 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionWrapperImpl.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MetricsRegionWrapperImpl.java
@@ -174,4 +174,12 @@ public class MetricsRegionWrapperImpl implements MetricsRegionWrapper,
Closeable
     return coprocessorTimes;
   }
 
+  /**
+   * Get the replica id of this region.
+   */
+  @Override
+  public int getReplicaId() {
+    return region.getRegionInfo().getReplicaId();
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/9f420d0a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/MetricsRegionWrapperStub.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/MetricsRegionWrapperStub.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/MetricsRegionWrapperStub.java
index 94ac356..2b1a9b7 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/MetricsRegionWrapperStub.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/MetricsRegionWrapperStub.java
@@ -24,6 +24,21 @@ import java.util.Map;
 import org.apache.commons.math.stat.descriptive.DescriptiveStatistics;
 
 public class MetricsRegionWrapperStub implements MetricsRegionWrapper {
+  int replicaid = 0;
+
+  /**
+   * Replica ID set to 0
+   */
+  public MetricsRegionWrapperStub() {
+    this.replicaid = 0;
+  }
+
+  /**
+   * Pass in replica ID
+   */
+  public MetricsRegionWrapperStub(int replicaid) {
+    this.replicaid = replicaid;
+  }
 
   @Override
   public String getTableName() {
@@ -94,4 +109,12 @@ public class MetricsRegionWrapperStub implements MetricsRegionWrapper
{
   public Map<String, DescriptiveStatistics> getCoprocessorExecutionStatistics() {
     return new HashMap<String, DescriptiveStatistics>();
   }
+
+  /**
+   * Get the replica id of this region.
+   */
+  @Override
+  public int getReplicaId() {
+    return replicaid;
+  }
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/9f420d0a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegion.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegion.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegion.java
index 0a9e427..1bb7915 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegion.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsRegion.java
@@ -35,9 +35,35 @@ public class TestMetricsRegion {
     MetricsRegion mr = new MetricsRegion(new MetricsRegionWrapperStub());
     MetricsRegionAggregateSource agg = mr.getSource().getAggregateSource();
 
-    HELPER.assertGauge("namespace_TestNS_table_MetricsRegionWrapperStub_region_DEADBEEF001_metric_storeCount",
101, agg);
-    HELPER.assertGauge("namespace_TestNS_table_MetricsRegionWrapperStub_region_DEADBEEF001_metric_storeFileCount",
102, agg);
-    HELPER.assertGauge("namespace_TestNS_table_MetricsRegionWrapperStub_region_DEADBEEF001_metric_memstoreSize",
103, agg);
+    HELPER.assertGauge(
+      "namespace_TestNS_table_MetricsRegionWrapperStub_region_DEADBEEF001_metric_storeCount",

+      101, agg);
+    HELPER.assertGauge(
+      "namespace_TestNS_table_MetricsRegionWrapperStub_region_DEADBEEF001_metric_storeFileCount",
+      102, agg);
+    HELPER.assertGauge(
+      "namespace_TestNS_table_MetricsRegionWrapperStub_region_DEADBEEF001_metric_memstoreSize",
+      103, agg);
+    HELPER.assertCounter(
+      "namespace_TestNS_table_MetricsRegionWrapperStub_region_DEADBEEF001_metric_replicaid",

+      0, agg);
+    mr.close();
+
+    // test region with replica id > 0
+    mr = new MetricsRegion(new MetricsRegionWrapperStub(1));
+    agg = mr.getSource().getAggregateSource();
+    HELPER.assertGauge(
+      "namespace_TestNS_table_MetricsRegionWrapperStub_region_DEADBEEF001_metric_storeCount",

+      101, agg);
+    HELPER.assertGauge(
+      "namespace_TestNS_table_MetricsRegionWrapperStub_region_DEADBEEF001_metric_storeFileCount",
+      102, agg);
+    HELPER.assertGauge(
+      "namespace_TestNS_table_MetricsRegionWrapperStub_region_DEADBEEF001_metric_memstoreSize",
+      103, agg);
+    HELPER.assertCounter(
+      "namespace_TestNS_table_MetricsRegionWrapperStub_region_DEADBEEF001_metric_replicaid",

+      1, agg);
     mr.close();
   }
 }


Mime
View raw message