accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject accumulo git commit: Keep a reference to the MutableMetric and update it via that instead of the metricsregistry
Date Thu, 04 Dec 2014 17:40:02 GMT
Repository: accumulo
Updated Branches:
  refs/heads/metrics2-backwardscompat 6bc63eb0b -> a056b1ca0


Keep a reference to the MutableMetric and update it via that instead of the metricsregistry

MetricsRegistry.add only lets you update MutableStat and will fail on anything else. Helpful.


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

Branch: refs/heads/metrics2-backwardscompat
Commit: a056b1ca0534aee85c57e4c484093979a424adde
Parents: 6bc63eb
Author: Josh Elser <elserj@apache.org>
Authored: Thu Dec 4 12:39:14 2014 -0500
Committer: Josh Elser <elserj@apache.org>
Committed: Thu Dec 4 12:39:14 2014 -0500

----------------------------------------------------------------------
 .../metrics/Metrics2TabletServerMetrics.java    | 62 +++++++++++---------
 1 file changed, 34 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/a056b1ca/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/Metrics2TabletServerMetrics.java
----------------------------------------------------------------------
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/Metrics2TabletServerMetrics.java
b/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/Metrics2TabletServerMetrics.java
index c21632b..70f2a2e 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/Metrics2TabletServerMetrics.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/Metrics2TabletServerMetrics.java
@@ -25,6 +25,8 @@ import org.apache.hadoop.metrics2.MetricsSource;
 import org.apache.hadoop.metrics2.MetricsSystem;
 import org.apache.hadoop.metrics2.lib.Interns;
 import org.apache.hadoop.metrics2.lib.MetricsRegistry;
+import org.apache.hadoop.metrics2.lib.MutableGaugeLong;
+import org.apache.hadoop.metrics2.lib.MutableStat;
 
 /**
  *
@@ -38,25 +40,27 @@ public class Metrics2TabletServerMetrics implements Metrics, MetricsSource
{
   private final MetricsSystem system;
   private final MetricsRegistry registry;
 
+  private final MutableStat entries, entriesInMemory, filesPerTablet;
+  private final MutableGaugeLong activeMajcs, queuedMajcs, activeMincs, queuedMincs, onlineTablets,
openingTablets, unopenedTablets, queries, totalMincs;
+
   Metrics2TabletServerMetrics(TabletServer tserver, MetricsSystem system) {
     this.tserver = tserver;
     this.system = system;
     this.registry = new MetricsRegistry(Interns.info("TabletServerMetrics", "General TabletServer
Metrics"));
 
-    registry.newStat(ENTRIES, "Number of entries", "Ops", "Count");
-    registry.newStat(ENTRIES_IN_MEM, "Number of entries in memory", "Ops", "Count");
-    registry.newStat(FILES_PER_TABLET, "Number of files per tablet", "Ops", "Files", true);
-
-    registry.newGauge(Interns.info(ACTIVE_MAJCS, "Number of active major compactions"), 0l);
-    registry.newGauge(Interns.info("queuedMajCs", "Number of queued major compactions"),
0l);
-    registry.newGauge(Interns.info("activeMinCs", "Number of active minor compactions"),
0l);
-    registry.newGauge(Interns.info("queuedMinCs", "Number of queued minor compactions"),
0l);
-    registry.newGauge(Interns.info("onlineTablets", "Number of online tablets"), 0l);
-    registry.newGauge(Interns.info("openingTablets", "Number of opening tablets"), 0l);
-    registry.newGauge(Interns.info("unopenedTablets", "Number of unopened tablets"), 0l);
-    registry.newGauge(Interns.info("queries", "Number of queries"), 0l);
-    registry.newGauge(Interns.info("totalMinCs", "Total number of minor compactions performed"),
0l);
+    entries = registry.newStat(ENTRIES, "Number of entries", "Ops", "Count");
+    entriesInMemory = registry.newStat(ENTRIES_IN_MEM, "Number of entries in memory", "Ops",
"Count");
+    filesPerTablet = registry.newStat(FILES_PER_TABLET, "Number of files per tablet", "Ops",
"Files", true);
 
+    activeMajcs = registry.newGauge(Interns.info(ACTIVE_MAJCS, "Number of active major compactions"),
0l);
+    queuedMajcs = registry.newGauge(Interns.info(QUEUED_MAJCS, "Number of queued major compactions"),
0l);
+    activeMincs = registry.newGauge(Interns.info(ACTIVE_MINCS, "Number of active minor compactions"),
0l);
+    queuedMincs = registry.newGauge(Interns.info(QUEUED_MINCS, "Number of queued minor compactions"),
0l);
+    onlineTablets = registry.newGauge(Interns.info(ONLINE_TABLETS, "Number of online tablets"),
0l);
+    openingTablets = registry.newGauge(Interns.info(OPENING_TABLETS, "Number of opening tablets"),
0l);
+    unopenedTablets = registry.newGauge(Interns.info(UNOPENED_TABLETS, "Number of unopened
tablets"), 0l);
+    queries = registry.newGauge(Interns.info(QUERIES, "Number of queries"), 0l);
+    totalMincs = registry.newGauge(Interns.info(TOTAL_MINCS, "Total number of minor compactions
performed"), 0l);
   }
 
   @Override
@@ -75,31 +79,33 @@ public class Metrics2TabletServerMetrics implements Metrics, MetricsSource
{
   }
 
   protected void snapshot() {
-    registry.add(ENTRIES, getEntries());
-    registry.add(ENTRIES_IN_MEM, getEntriesInMemory());
-    registry.add(FILES_PER_TABLET, (long) this.getAverageFilesPerTablet());
+    entries.add(getEntries());
+    entriesInMemory.add(getEntriesInMemory());
+    filesPerTablet.add((long) getAverageFilesPerTablet());
 
-    registry.add(ACTIVE_MAJCS, getMajorCompactions());
-    registry.add(QUEUED_MAJCS, getMajorCompactionsQueued());
-    registry.add(ACTIVE_MINCS, getMinorCompactions());
-    registry.add(QUEUED_MINCS, getMinorCompactionsQueued());
-    registry.add(ONLINE_TABLETS, getOnlineCount());
-    registry.add(OPENING_TABLETS, getOpeningCount());
-    registry.add(UNOPENED_TABLETS, getUnopenedCount());
-    registry.add(QUERIES, getQueries());
-    registry.add(TOTAL_MINCS, getTotalMinorCompactions());
+    activeMajcs.set(getMajorCompactions());
+    queuedMajcs.set(getMajorCompactionsQueued());
+    activeMincs.set(getMinorCompactions());
+    queuedMincs.set(getMinorCompactionsQueued());
+    onlineTablets.set(getOnlineCount());
+    openingTablets.set(getOpeningCount());
+    unopenedTablets.set(getUnopenedCount());
+    queries.set(getQueries());
+    totalMincs.set(getTotalMinorCompactions());
   }
 
   @Override
   public void getMetrics(MetricsCollector collector, boolean all) {
     MetricsRecordBuilder builder = collector.addRecord("Accumulo").setContext("tserver");
 
+    // Update each MutableMetric with the new value
     snapshot();
 
-    // TODO Some day, MetricsRegistry will also support the MetricsGaugeDouble
-    builder.addGauge(Interns.info(HOLD_TIME, "Time commits held"), getHoldTime());
-
+    // Add then all to the builder
     registry.snapshot(builder, all);
+
+    // TODO Some day, MetricsRegistry will also support the MetricsGaugeDouble or allow us
to instantiate it directly
+    builder.addGauge(Interns.info(HOLD_TIME, "Time commits held"), getHoldTime());
   }
 
   public long getEntries() {


Mime
View raw message