You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ap...@apache.org on 2016/08/25 00:45:30 UTC

[2/2] hbase git commit: Amend HBASE-16448 Custom metrics for custom replication endpoints

Amend HBASE-16448 Custom metrics for custom replication endpoints

Add missing support in hbase-hadoop1-compat


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

Branch: refs/heads/0.98
Commit: e78008700bcf30443cdd94b206575d8bb2ce31f8
Parents: 6fbdc38
Author: Andrew Purtell <ap...@apache.org>
Authored: Wed Aug 24 17:44:21 2016 -0700
Committer: Andrew Purtell <ap...@apache.org>
Committed: Wed Aug 24 17:44:21 2016 -0700

----------------------------------------------------------------------
 .../MetricsReplicationGlobalSourceSource.java   | 64 ++++++++++++++-
 .../MetricsReplicationSourceSourceImpl.java     | 82 +++++++++++++++++---
 2 files changed, 135 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/e7800870/hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/replication/regionserver/MetricsReplicationGlobalSourceSource.java
----------------------------------------------------------------------
diff --git a/hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/replication/regionserver/MetricsReplicationGlobalSourceSource.java b/hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/replication/regionserver/MetricsReplicationGlobalSourceSource.java
index 620b764..ee59b1c 100644
--- a/hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/replication/regionserver/MetricsReplicationGlobalSourceSource.java
+++ b/hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/replication/regionserver/MetricsReplicationGlobalSourceSource.java
@@ -22,7 +22,7 @@ import org.apache.hadoop.metrics2.lib.MetricMutableCounterLong;
 import org.apache.hadoop.metrics2.lib.MetricMutableGaugeLong;
 
 public class MetricsReplicationGlobalSourceSource implements MetricsReplicationSourceSource {
-
+  private final MetricsReplicationSource rms;
   private final MetricMutableGaugeLong ageOfLastShippedOpGauge;
   private long ageOfLastShipped; // Hadoop 1 metrics don't let you read from gauges
   private final MetricMutableGaugeLong sizeOfLogQueueGauge;
@@ -36,7 +36,7 @@ public class MetricsReplicationGlobalSourceSource implements MetricsReplicationS
   private final MetricMutableCounterLong logReadInBytesCounter;
 
   public MetricsReplicationGlobalSourceSource(MetricsReplicationSourceImpl rms) {
-
+    this.rms = rms;
     ageOfLastShippedOpGauge = rms.getMetricsRegistry().getLongGauge(SOURCE_AGE_OF_LAST_SHIPPED_OP, 0L);
 
     sizeOfLogQueueGauge = rms.getMetricsRegistry().getLongGauge(SOURCE_SIZE_OF_LOG_QUEUE, 0L);
@@ -115,4 +115,64 @@ public class MetricsReplicationGlobalSourceSource implements MetricsReplicationS
   public long getLastShippedAge() {
     return ageOfLastShipped;
   }
+
+  @Override
+  public void init() {
+    rms.init();
+  }
+
+  @Override
+  public void setGauge(String gaugeName, long value) {
+    rms.setGauge(gaugeName, value);
+  }
+
+  @Override
+  public void incGauge(String gaugeName, long delta) {
+    rms.incGauge(gaugeName, delta);
+  }
+
+  @Override
+  public void decGauge(String gaugeName, long delta) {
+    rms.decGauge(gaugeName, delta);
+  }
+
+  @Override
+  public void removeMetric(String key) {
+    rms.removeMetric(key);
+  }
+
+  @Override
+  public void incCounters(String counterName, long delta) {
+    rms.incCounters(counterName, delta);
+  }
+
+  @Override
+  public void updateHistogram(String name, long value) {
+    rms.updateHistogram(name, value);
+  }
+
+  @Override
+  public void updateQuantile(String name, long value) {
+    rms.updateQuantile(name, value);
+  }
+
+  @Override
+  public String getMetricsContext() {
+    return rms.getMetricsContext();
+  }
+
+  @Override
+  public String getMetricsDescription() {
+    return rms.getMetricsDescription();
+  }
+
+  @Override
+  public String getMetricsJmxContext() {
+    return rms.getMetricsJmxContext();
+  }
+
+  @Override
+  public String getMetricsName() {
+    return rms.getMetricsName();
+  }
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/e7800870/hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/replication/regionserver/MetricsReplicationSourceSourceImpl.java
----------------------------------------------------------------------
diff --git a/hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/replication/regionserver/MetricsReplicationSourceSourceImpl.java b/hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/replication/regionserver/MetricsReplicationSourceSourceImpl.java
index 21a6cb3..e15af46 100644
--- a/hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/replication/regionserver/MetricsReplicationSourceSourceImpl.java
+++ b/hbase-hadoop1-compat/src/main/java/org/apache/hadoop/hbase/replication/regionserver/MetricsReplicationSourceSourceImpl.java
@@ -31,6 +31,8 @@ public class MetricsReplicationSourceSourceImpl implements MetricsReplicationSou
   private final String logEditsFilteredKey;
   private final String shippedBatchesKey;
   private final String shippedOpsKey;
+  private String keyPrefix;
+
   @Deprecated
   private final String shippedKBsKey;
   private final String shippedBytesKey;
@@ -50,32 +52,33 @@ public class MetricsReplicationSourceSourceImpl implements MetricsReplicationSou
   public MetricsReplicationSourceSourceImpl(MetricsReplicationSourceImpl rms, String id) {
     this.rms = rms;
     this.id = id;
+    this.keyPrefix = "source." + this.id + ".";
 
-    ageOfLastShippedOpKey = "source." + id + ".ageOfLastShippedOp";
+    ageOfLastShippedOpKey = this.keyPrefix + ".ageOfLastShippedOp";
     ageOfLastShippedOpGauge = rms.getMetricsRegistry().getLongGauge(ageOfLastShippedOpKey, 0L);
 
-    sizeOfLogQueueKey = "source." + id + ".sizeOfLogQueue";
+    sizeOfLogQueueKey = this.keyPrefix + ".sizeOfLogQueue";
     sizeOfLogQueueGauge = rms.getMetricsRegistry().getLongGauge(sizeOfLogQueueKey, 0L);
 
-    shippedBatchesKey = "source." + this.id + ".shippedBatches";
+    shippedBatchesKey = this.keyPrefix + ".shippedBatches";
     shippedBatchesCounter = rms.getMetricsRegistry().getLongCounter(shippedBatchesKey, 0L);
 
-    shippedOpsKey = "source." + this.id + ".shippedOps";
+    shippedOpsKey = this.keyPrefix + ".shippedOps";
     shippedOpsCounter = rms.getMetricsRegistry().getLongCounter(shippedOpsKey, 0L);
 
-    shippedKBsKey = "source." + this.id + ".shippedKBs";
+    shippedKBsKey = this.keyPrefix + ".shippedKBs";
     shippedKBsCounter = rms.getMetricsRegistry().getLongCounter(shippedKBsKey, 0L);
 
-    shippedBytesKey = "source." + this.id + ".shippedBytes";
+    shippedBytesKey = this.keyPrefix + ".shippedBytes";
     shippedBytesCounter = rms.getMetricsRegistry().getLongCounter(shippedBytesKey, 0L);
 
-    logReadInBytesKey = "source." + this.id + ".logReadInBytes";
+    logReadInBytesKey = this.keyPrefix + ".logReadInBytes";
     logReadInBytesCounter = rms.getMetricsRegistry().getLongCounter(logReadInBytesKey, 0L);
 
-    logReadInEditsKey = "source." + id + ".logEditsRead";
+    logReadInEditsKey = this.keyPrefix + ".logEditsRead";
     logReadInEditsCounter = rms.getMetricsRegistry().getLongCounter(logReadInEditsKey, 0L);
 
-    logEditsFilteredKey = "source." + id + ".logEditsFiltered";
+    logEditsFilteredKey = this.keyPrefix + ".logEditsFiltered";
     logEditsFilteredCounter = rms.getMetricsRegistry().getLongCounter(logEditsFilteredKey, 0L);
   }
 
@@ -140,4 +143,65 @@ public class MetricsReplicationSourceSourceImpl implements MetricsReplicationSou
   public long getLastShippedAge() {
     return ageOfLastShipped;
   }
+
+
+  @Override
+  public void init() {
+    rms.init();
+  }
+
+  @Override
+  public void setGauge(String gaugeName, long value) {
+    rms.setGauge(this.keyPrefix + gaugeName, value);
+  }
+
+  @Override
+  public void incGauge(String gaugeName, long delta) {
+    rms.incGauge(this.keyPrefix + gaugeName, delta);
+  }
+
+  @Override
+  public void decGauge(String gaugeName, long delta) {
+    rms.decGauge(this.keyPrefix + gaugeName, delta);
+  }
+
+  @Override
+  public void removeMetric(String key) {
+    rms.removeMetric(this.keyPrefix + key);
+  }
+
+  @Override
+  public void incCounters(String counterName, long delta) {
+    rms.incCounters(this.keyPrefix + counterName, delta);
+  }
+
+  @Override
+  public void updateHistogram(String name, long value) {
+    rms.updateHistogram(this.keyPrefix + name, value);
+  }
+
+  @Override
+  public void updateQuantile(String name, long value) {
+    rms.updateQuantile(this.keyPrefix + name, value);
+  }
+
+  @Override
+  public String getMetricsContext() {
+    return rms.getMetricsContext();
+  }
+
+  @Override
+  public String getMetricsDescription() {
+    return rms.getMetricsDescription();
+  }
+
+  @Override
+  public String getMetricsJmxContext() {
+    return rms.getMetricsJmxContext();
+  }
+
+  @Override
+  public String getMetricsName() {
+    return rms.getMetricsName();
+  }
 }