accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [2/4] accumulo git commit: ACCUMULO-1817 Initial stub out of existing JMX MBeans exposed via metrics2
Date Tue, 02 Dec 2014 22:12:01 GMT
ACCUMULO-1817 Initial stub out of existing JMX MBeans exposed via metrics2


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

Branch: refs/heads/metrics2
Commit: 3cf622398f24fefa691b5db265fe8d688e58278b
Parents: 4fb52f9
Author: Josh Elser <elserj@apache.org>
Authored: Tue Nov 25 15:24:47 2014 -0500
Committer: Josh Elser <elserj@apache.org>
Committed: Tue Dec 2 17:11:46 2014 -0500

----------------------------------------------------------------------
 .../server/metrics/AbstractMetricsImpl.java     | 126 +++++-----
 .../accumulo/server/metrics/ThriftMetrics.java  |   9 +
 .../master/metrics/ReplicationMetrics.java      |   5 +
 .../apache/accumulo/tserver/TabletServer.java   |  32 ++-
 .../metrics/TabletServerGeneralMetrics.java     | 233 +++++++++++++++++++
 .../TabletServerGeneralMetricsMBean.java        |  50 ++++
 .../tserver/metrics/TabletServerMBean.java      |  50 ----
 .../tserver/metrics/TabletServerMBeanImpl.java  | 206 ----------------
 .../metrics/TabletServerMinCMetrics.java        |  45 ++--
 .../metrics/TabletServerScanMetrics.java        |  45 ++--
 .../metrics/TabletServerUpdateMetrics.java      |  75 +++---
 11 files changed, 493 insertions(+), 383 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/3cf62239/server/base/src/main/java/org/apache/accumulo/server/metrics/AbstractMetricsImpl.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/metrics/AbstractMetricsImpl.java
b/server/base/src/main/java/org/apache/accumulo/server/metrics/AbstractMetricsImpl.java
index 54ca8de..570feb7 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/metrics/AbstractMetricsImpl.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/metrics/AbstractMetricsImpl.java
@@ -17,155 +17,169 @@
 package org.apache.accumulo.server.metrics;
 
 import static java.nio.charset.StandardCharsets.UTF_8;
+import static org.apache.hadoop.metrics2.lib.Interns.info;
 
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
-import java.lang.management.ManagementFactory;
 import java.text.SimpleDateFormat;
 import java.util.Date;
+import java.util.Map.Entry;
 import java.util.concurrent.ConcurrentHashMap;
 
-import javax.management.MBeanServer;
 import javax.management.ObjectName;
 import javax.management.StandardMBean;
 
 import org.apache.commons.lang.builder.ToStringBuilder;
 import org.apache.commons.lang.builder.ToStringStyle;
 import org.apache.commons.lang.time.DateUtils;
+import org.apache.hadoop.metrics2.MetricsCollector;
+import org.apache.hadoop.metrics2.MetricsSource;
+
+public abstract class AbstractMetricsImpl implements MetricsSource {
+
+  @Override
+  public void getMetrics(MetricsCollector collector, boolean all) {
+    for (Entry<String,Metric> entry : registry.entrySet()) {
+      String name = entry.getKey();
+      Metric metric = entry.getValue();
+      collector.addRecord("Accumulo").setContext(getMetricsPrefix()).addGauge(info(name,
name + " count"), metric.getCount())
+          .addGauge(info(name, name + " min"), metric.getMin()).addGauge(info(name, name
+ " max"), metric.getMax())
+          .addGauge(info(name, name + " avg"), metric.getAvg());
+    }
+  }
 
-public abstract class AbstractMetricsImpl {
-  
   public class Metric {
-    
+
     private long count = 0;
     private long avg = 0;
     private long min = 0;
     private long max = 0;
-    
+
     public long getCount() {
       return count;
     }
-    
+
     public long getAvg() {
       return avg;
     }
-    
+
     public long getMin() {
       return min;
     }
-    
+
     public long getMax() {
       return max;
     }
-    
+
     public void incCount() {
       count++;
     }
-    
+
     public void addAvg(long a) {
       if (a < 0)
         return;
       avg = (long) ((avg * .8) + (a * .2));
     }
-    
+
     public void addMin(long a) {
       if (a < 0)
         return;
       min = Math.min(min, a);
     }
-    
+
     public void addMax(long a) {
       if (a < 0)
         return;
       max = Math.max(max, a);
     }
-    
+
     @Override
     public String toString() {
-      return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("count",
count).append("average", avg).append("minimum", min).append("maximum", max).toString();
+      return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).append("count",
count).append("average", avg).append("minimum", min)
+          .append("maximum", max).toString();
     }
-    
+
   }
-  
+
   static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(AbstractMetricsImpl.class);
-  
-  private static ConcurrentHashMap<String,Metric> registry = new ConcurrentHashMap<String,Metric>();
-  
+
+  private ConcurrentHashMap<String,Metric> registry = new ConcurrentHashMap<String,Metric>();
+
   private boolean currentlyLogging = false;
-  
+
   private File logDir = null;
-  
+
   private String metricsPrefix = null;
-  
+
   private Date today = new Date();
-  
+
   private File logFile = null;
-  
+
   private Writer logWriter = null;
-  
+
   private SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
-  
+
   private SimpleDateFormat logFormatter = new SimpleDateFormat("yyyyMMddhhmmssz");
-  
+
   private MetricsConfiguration config = null;
-  
+
   public AbstractMetricsImpl() {
     this.metricsPrefix = getMetricsPrefix();
     config = new MetricsConfiguration(metricsPrefix);
   }
-  
+
   /**
    * Registers a StandardMBean with the MBean Server
    */
   public void register(StandardMBean mbean) throws Exception {
     // Register this object with the MBeanServer
-    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-    if (null == getObjectName())
-      throw new IllegalArgumentException("MBean object name must be set.");
-    mbs.registerMBean(mbean, getObjectName());
-    
+    // MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+    // if (null == getObjectName())
+    // throw new IllegalArgumentException("MBean object name must be set.");
+    // mbs.registerMBean(mbean, getObjectName());
+
     setupLogging();
   }
-  
+
   /**
    * Registers this MBean with the MBean Server
    */
   public void register() throws Exception {
     // Register this object with the MBeanServer
-    MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
-    if (null == getObjectName())
-      throw new IllegalArgumentException("MBean object name must be set.");
-    mbs.registerMBean(this, getObjectName());
+    // MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
+    // if (null == getObjectName())
+    // throw new IllegalArgumentException("MBean object name must be set.");
+    // mbs.registerMBean(this, getObjectName());
     setupLogging();
   }
-  
+
   public void createMetric(String name) {
     registry.put(name, new Metric());
   }
-  
+
   public Metric getMetric(String name) {
     return registry.get(name);
   }
-  
+
   public long getMetricCount(String name) {
     return registry.get(name).getCount();
   }
-  
+
   public long getMetricAvg(String name) {
     return registry.get(name).getAvg();
   }
-  
+
   public long getMetricMin(String name) {
     return registry.get(name).getMin();
   }
-  
+
   public long getMetricMax(String name) {
     return registry.get(name).getMax();
   }
-  
+
   private void setupLogging() throws IOException {
     if (null == config.getMetricsConfiguration())
       return;
@@ -176,7 +190,7 @@ public abstract class AbstractMetricsImpl {
       if (null != mDir) {
         File dir = new File(mDir);
         if (!dir.isDirectory())
-          if (!dir.mkdir()) 
+          if (!dir.mkdir())
             log.warn("Could not create log directory: " + dir);
         logDir = dir;
         // Create new log file
@@ -185,7 +199,7 @@ public abstract class AbstractMetricsImpl {
       currentlyLogging = true;
     }
   }
-  
+
   private void startNewLog() throws IOException {
     if (null != logWriter) {
       logWriter.flush();
@@ -201,7 +215,7 @@ public abstract class AbstractMetricsImpl {
     }
     logWriter = new OutputStreamWriter(new FileOutputStream(logFile, true), UTF_8);
   }
-  
+
   private void writeToLog(String name) throws IOException {
     if (null == logWriter)
       return;
@@ -213,7 +227,7 @@ public abstract class AbstractMetricsImpl {
     }
     logWriter.append(logFormatter.format(now)).append(" Metric: ").append(name).append(":
").append(registry.get(name).toString()).append("\n");
   }
-  
+
   public void add(String name, long time) {
     if (isEnabled()) {
       registry.get(name).incCount();
@@ -248,15 +262,15 @@ public abstract class AbstractMetricsImpl {
       }
     }
   }
-  
+
   public boolean isEnabled() {
     return config.isEnabled();
   }
-  
+
   protected abstract ObjectName getObjectName();
-  
+
   protected abstract String getMetricsPrefix();
-  
+
   @Override
   protected void finalize() {
     if (null != logWriter) {
@@ -270,5 +284,5 @@ public abstract class AbstractMetricsImpl {
     }
     logFile = null;
   }
-  
+
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/3cf62239/server/base/src/main/java/org/apache/accumulo/server/metrics/ThriftMetrics.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/metrics/ThriftMetrics.java
b/server/base/src/main/java/org/apache/accumulo/server/metrics/ThriftMetrics.java
index cf7d3d5..7e63a6d 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/metrics/ThriftMetrics.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/metrics/ThriftMetrics.java
@@ -47,39 +47,48 @@ public class ThriftMetrics extends AbstractMetricsImpl implements ThriftMetricsM
     return METRICS_PREFIX;
   }
   
+  @Override
   public void reset() {
     createMetric(idle);
     createMetric(execute);
   }
   
+  @Override
   public long getExecutionAvgTime() {
     return this.getMetricAvg(execute);
   }
   
+  @Override
   public long getExecutionCount() {
     return this.getMetricCount(execute);
   }
   
+  @Override
   public long getExecutionMaxTime() {
     return this.getMetricMax(execute);
   }
   
+  @Override
   public long getExecutionMinTime() {
     return this.getMetricMin(execute);
   }
   
+  @Override
   public long getIdleAvgTime() {
     return this.getMetricAvg(idle);
   }
   
+  @Override
   public long getIdleCount() {
     return this.getMetricCount(idle);
   }
   
+  @Override
   public long getIdleMaxTime() {
     return this.getMetricMax(idle);
   }
   
+  @Override
   public long getIdleMinTime() {
     return this.getMetricMin(idle);
   }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/3cf62239/server/master/src/main/java/org/apache/accumulo/master/metrics/ReplicationMetrics.java
----------------------------------------------------------------------
diff --git a/server/master/src/main/java/org/apache/accumulo/master/metrics/ReplicationMetrics.java
b/server/master/src/main/java/org/apache/accumulo/master/metrics/ReplicationMetrics.java
index 39112d0..28467ce 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/metrics/ReplicationMetrics.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/metrics/ReplicationMetrics.java
@@ -31,6 +31,10 @@ import org.apache.accumulo.core.replication.ReplicationTarget;
 import org.apache.accumulo.master.Master;
 import org.apache.accumulo.server.metrics.AbstractMetricsImpl;
 import org.apache.accumulo.server.replication.ReplicationUtil;
+import org.apache.accumulo.server.security.SystemCredentials;
+import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * JMX bindings to expose 'high-level' metrics about Replication
@@ -47,6 +51,7 @@ public class ReplicationMetrics extends AbstractMetricsImpl implements Replicati
     this.master = master;
     objectName = new ObjectName("accumulo.server.metrics:service=Replication Metrics,name=ReplicationMBean,instance="
+ Thread.currentThread().getName());
     replicationUtil = new ReplicationUtil(master);
+    DefaultMetricsSystem.initialize(getMetricsPrefix()).register(ReplicationMetricsMBean.class.getSimpleName(),
Thread.currentThread().getName(), this);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/accumulo/blob/3cf62239/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
----------------------------------------------------------------------
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
index d4447ab..2fd753d 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
@@ -49,9 +49,8 @@ import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.locks.ReentrantLock;
 
-import javax.management.StandardMBean;
-
 import com.google.common.net.HostAndPort;
+
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.AccumuloException;
 import org.apache.accumulo.core.client.AccumuloSecurityException;
@@ -199,8 +198,7 @@ import org.apache.accumulo.tserver.log.TabletServerLogger;
 import org.apache.accumulo.tserver.mastermessage.MasterMessage;
 import org.apache.accumulo.tserver.mastermessage.SplitReportMessage;
 import org.apache.accumulo.tserver.mastermessage.TabletStatusMessage;
-import org.apache.accumulo.tserver.metrics.TabletServerMBean;
-import org.apache.accumulo.tserver.metrics.TabletServerMBeanImpl;
+import org.apache.accumulo.tserver.metrics.TabletServerGeneralMetrics;
 import org.apache.accumulo.tserver.metrics.TabletServerMinCMetrics;
 import org.apache.accumulo.tserver.metrics.TabletServerScanMetrics;
 import org.apache.accumulo.tserver.metrics.TabletServerUpdateMetrics;
@@ -230,6 +228,8 @@ import org.apache.hadoop.fs.FSError;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.io.Text;
+import org.apache.hadoop.metrics2.MetricsSystem;
+import org.apache.hadoop.metrics2.lib.DefaultMetricsSystem;
 import org.apache.log4j.Logger;
 import org.apache.thrift.TException;
 import org.apache.thrift.TProcessor;
@@ -254,8 +254,12 @@ public class TabletServer extends AccumuloServerContext implements Runnable
{
 
   private final TabletServerLogger logger;
 
-  private final TabletServerMinCMetrics mincMetrics = new TabletServerMinCMetrics();
+  private final MetricsSystem metricsSystem;
 
+  public MetricsSystem getMetricsSystem() {
+    return metricsSystem;
+  }
+  private final TabletServerMinCMetrics mincMetrics;
   public TabletServerMinCMetrics getMinCMetrics() {
     return mincMetrics;
   }
@@ -337,13 +341,18 @@ public class TabletServer extends AccumuloServerContext implements Runnable
{
     logger = new TabletServerLogger(this, walogMaxSize, syncCounter, flushCounter);
     this.resourceManager = new TabletServerResourceManager(this, fs);
     this.security = AuditedSecurityOperation.getInstance(this);
+
+    metricsSystem = DefaultMetricsSystem.initialize("TabletServer");
+    mincMetrics = new TabletServerMinCMetrics(metricsSystem);
+    updateMetrics = new TabletServerUpdateMetrics(metricsSystem);
+    scanMetrics = new TabletServerScanMetrics(metricsSystem);
   }
 
   private final SessionManager sessionManager;
 
-  private final TabletServerUpdateMetrics updateMetrics = new TabletServerUpdateMetrics();
+  private final TabletServerUpdateMetrics updateMetrics;
 
-  private final TabletServerScanMetrics scanMetrics = new TabletServerScanMetrics();
+  private final TabletServerScanMetrics scanMetrics;
 
   private final WriteTracker writeTracker = new WriteTracker();
 
@@ -2430,10 +2439,13 @@ public class TabletServer extends AccumuloServerContext implements
Runnable {
 
     try {
       // Do this because interface not in same package.
-      TabletServerMBeanImpl beanImpl = new TabletServerMBeanImpl(this);
-      StandardMBean mbean = new StandardMBean(beanImpl, TabletServerMBean.class, false);
-      beanImpl.register(mbean);
+      TabletServerGeneralMetrics beanImpl = new TabletServerGeneralMetrics(this);
+      beanImpl.register();
+      // StandardMBean mbean = new StandardMBean(beanImpl, TabletServerGeneralMetricsMBean.class,
false);
+      // beanImpl.register(mbean);
       mincMetrics.register();
+      scanMetrics.register();
+      updateMetrics.register();
     } catch (Exception e) {
       log.error("Error registering with JMX", e);
     }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/3cf62239/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerGeneralMetrics.java
----------------------------------------------------------------------
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerGeneralMetrics.java
b/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerGeneralMetrics.java
new file mode 100644
index 0000000..917701d
--- /dev/null
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerGeneralMetrics.java
@@ -0,0 +1,233 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.tserver.metrics;
+
+import static org.apache.hadoop.metrics2.lib.Interns.info;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import org.apache.accumulo.server.metrics.AbstractMetricsImpl;
+import org.apache.accumulo.tserver.TabletServer;
+import org.apache.accumulo.tserver.tablet.Tablet;
+import org.apache.hadoop.metrics2.MetricsCollector;
+import org.apache.hadoop.metrics2.MetricsRecordBuilder;
+
+public class TabletServerGeneralMetrics extends AbstractMetricsImpl implements TabletServerGeneralMetricsMBean
{
+
+  private static final String METRICS_PREFIX = "tserver.general";
+  private static ObjectName OBJECT_NAME = null;
+
+  final TabletServer server;
+
+  public TabletServerGeneralMetrics(TabletServer server) throws MalformedObjectNameException
{
+    super();
+    this.server = server;
+    OBJECT_NAME = new ObjectName("accumulo.server.metrics:service=TServerInfo,name=TabletServerGeneralMetricsMBean,instance="
+        + Thread.currentThread().getName());
+    server.getMetricsSystem().register(TabletServerGeneralMetricsMBean.class.getSimpleName(),
this.getClass().getSimpleName(), this);
+  }
+
+  @Override
+  public void getMetrics(MetricsCollector collector, boolean all) {
+    MetricsRecordBuilder builder = collector.addRecord("Accumulo").setContext(getMetricsPrefix());
+
+    builder.addGauge(info("entries", "Entries"), getEntries())
+    .addGauge(info("entriesInMemory", "Entries in memory"), getEntriesInMemory())
+    .addGauge(info("ingest", "Ingest rate"), getIngest())
+    .addGauge(info("majorCompactions", "Active major compactions"), getMajorCompactions())
+    .addGauge(info("queuedMajorCompactions", "Queued major compactions"), getMajorCompactionsQueued())
+    .addGauge(info("minorCompaction", "Active minor compactions"), getMinorCompactions())
+    .addGauge(info("queuedMinorCompactions", "Queued minor compactions"), getMinorCompactionsQueued())
+    .addGauge(info("onlineTablets", "Online Tablets"), getOnlineCount())
+    .addGauge(info("openingTablets", "Opening Tablets"), getOpeningCount())
+    .addGauge(info("unopenedTablets", "Unopened Tablets"), getUnopenedCount())
+    .addGauge(info("queries", "Queries"), getQueries())
+    .addGauge(info("totalMinorCompactions", "Total minor compactions"), getTotalMinorCompactions())
+    .addGauge(info("holdTime", "Hold time"), getHoldTime())
+        .addGauge(info("avgFilesPerTablet", "Average number of files per Tablet"), getAverageFilesPerTablet());
+  }
+
+  @Override
+  public long getEntries() {
+    if (isEnabled()) {
+      long result = 0;
+      for (Tablet tablet : server.getOnlineTablets()) {
+        result += tablet.getNumEntries();
+      }
+      return result;
+    }
+    return 0;
+  }
+
+  @Override
+  public long getEntriesInMemory() {
+    if (isEnabled()) {
+      long result = 0;
+      for (Tablet tablet : server.getOnlineTablets()) {
+        result += tablet.getNumEntriesInMemory();
+      }
+      return result;
+    }
+    return 0;
+  }
+
+  @Override
+  public long getIngest() {
+    if (isEnabled()) {
+      long result = 0;
+      for (Tablet tablet : server.getOnlineTablets()) {
+        result += tablet.getNumEntriesInMemory();
+      }
+      return result;
+    }
+    return 0;
+  }
+
+  @Override
+  public int getMajorCompactions() {
+    if (isEnabled()) {
+      int result = 0;
+      for (Tablet tablet : server.getOnlineTablets()) {
+        if (tablet.isMajorCompactionRunning())
+          result++;
+      }
+      return result;
+    }
+    return 0;
+  }
+
+  @Override
+  public int getMajorCompactionsQueued() {
+    if (isEnabled()) {
+      int result = 0;
+      for (Tablet tablet : server.getOnlineTablets()) {
+        if (tablet.isMajorCompactionQueued())
+          result++;
+      }
+      return result;
+    }
+    return 0;
+  }
+
+  @Override
+  public int getMinorCompactions() {
+    if (isEnabled()) {
+      int result = 0;
+      for (Tablet tablet : server.getOnlineTablets()) {
+        if (tablet.isMinorCompactionRunning())
+          result++;
+      }
+      return result;
+    }
+    return 0;
+  }
+
+  @Override
+  public int getMinorCompactionsQueued() {
+    if (isEnabled()) {
+      int result = 0;
+      for (Tablet tablet : server.getOnlineTablets()) {
+        if (tablet.isMinorCompactionQueued())
+          result++;
+      }
+      return result;
+    }
+    return 0;
+  }
+
+  @Override
+  public int getOnlineCount() {
+    if (isEnabled())
+      return server.getOnlineTablets().size();
+    return 0;
+  }
+
+  @Override
+  public int getOpeningCount() {
+    if (isEnabled())
+      return server.getOpeningCount();
+    return 0;
+  }
+
+  @Override
+  public long getQueries() {
+    if (isEnabled()) {
+      long result = 0;
+      for (Tablet tablet : server.getOnlineTablets()) {
+        result += tablet.totalQueries();
+      }
+      return result;
+    }
+    return 0;
+  }
+
+  @Override
+  public int getUnopenedCount() {
+    if (isEnabled())
+      return server.getUnopenedCount();
+    return 0;
+  }
+
+  @Override
+  public String getName() {
+    if (isEnabled())
+      return server.getClientAddressString();
+    return "";
+  }
+
+  @Override
+  public long getTotalMinorCompactions() {
+    if (isEnabled())
+      return server.getTotalMinorCompactions();
+    return 0;
+  }
+
+  @Override
+  public double getHoldTime() {
+    if (isEnabled())
+      return server.getHoldTimeMillis() / 1000.;
+    return 0;
+  }
+
+  @Override
+  public double getAverageFilesPerTablet() {
+    if (isEnabled()) {
+      int count = 0;
+      long result = 0;
+      for (Tablet tablet : server.getOnlineTablets()) {
+        result += tablet.getDatafiles().size();
+        count++;
+      }
+      if (count == 0)
+        return 0;
+      return result / (double) count;
+    }
+    return 0;
+  }
+
+  @Override
+  protected ObjectName getObjectName() {
+    return OBJECT_NAME;
+  }
+
+  @Override
+  protected String getMetricsPrefix() {
+    return METRICS_PREFIX;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/3cf62239/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerGeneralMetricsMBean.java
----------------------------------------------------------------------
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerGeneralMetricsMBean.java
b/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerGeneralMetricsMBean.java
new file mode 100644
index 0000000..bd4af26
--- /dev/null
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerGeneralMetricsMBean.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.accumulo.tserver.metrics;
+
+public interface TabletServerGeneralMetricsMBean {
+
+  int getOnlineCount();
+
+  int getOpeningCount();
+
+  int getUnopenedCount();
+
+  int getMajorCompactions();
+
+  int getMajorCompactionsQueued();
+
+  int getMinorCompactions();
+
+  int getMinorCompactionsQueued();
+
+  long getEntries();
+
+  long getEntriesInMemory();
+
+  long getQueries();
+
+  long getIngest();
+
+  long getTotalMinorCompactions();
+
+  double getHoldTime();
+
+  String getName();
+
+  double getAverageFilesPerTablet();
+}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/3cf62239/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerMBean.java
----------------------------------------------------------------------
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerMBean.java
b/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerMBean.java
deleted file mode 100644
index 3b7a637..0000000
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerMBean.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.tserver.metrics;
-
-public interface TabletServerMBean {
-  
-  int getOnlineCount();
-  
-  int getOpeningCount();
-  
-  int getUnopenedCount();
-  
-  int getMajorCompactions();
-  
-  int getMajorCompactionsQueued();
-  
-  int getMinorCompactions();
-  
-  int getMinorCompactionsQueued();
-  
-  long getEntries();
-  
-  long getEntriesInMemory();
-  
-  long getQueries();
-  
-  long getIngest();
-  
-  long getTotalMinorCompactions();
-  
-  double getHoldTime();
-  
-  String getName();
-  
-  double getAverageFilesPerTablet();
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/3cf62239/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerMBeanImpl.java
----------------------------------------------------------------------
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerMBeanImpl.java
b/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerMBeanImpl.java
deleted file mode 100644
index 3970379..0000000
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerMBeanImpl.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.accumulo.tserver.metrics;
-
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import org.apache.accumulo.server.metrics.AbstractMetricsImpl;
-import org.apache.accumulo.tserver.TabletServer;
-import org.apache.accumulo.tserver.tablet.Tablet;
-
-public class TabletServerMBeanImpl extends AbstractMetricsImpl implements TabletServerMBean
{
-
-  private static final String METRICS_PREFIX = "tserver";
-  private static ObjectName OBJECT_NAME = null;
-
-  final TabletServer server;
-  
-  public TabletServerMBeanImpl(TabletServer server) throws MalformedObjectNameException {
-    this.server = server;
-    OBJECT_NAME = new ObjectName("accumulo.server.metrics:service=TServerInfo,name=TabletServerMBean,instance="
+ Thread.currentThread().getName());
-  }
-  
-  @Override
-  public long getEntries() {
-    if (isEnabled()) {
-      long result = 0;
-      for (Tablet tablet : server.getOnlineTablets()) {
-        result += tablet.getNumEntries();
-      }
-      return result;
-    }
-    return 0;
-  }
-
-  @Override
-  public long getEntriesInMemory() {
-    if (isEnabled()) {
-      long result = 0;
-      for (Tablet tablet : server.getOnlineTablets()) {
-        result += tablet.getNumEntriesInMemory();
-      }
-      return result;
-    }
-    return 0;
-  }
-
-  @Override
-  public long getIngest() {
-    if (isEnabled()) {
-      long result = 0;
-      for (Tablet tablet : server.getOnlineTablets()) {
-        result += tablet.getNumEntriesInMemory();
-      }
-      return result;
-    }
-    return 0;
-  }
-
-  @Override
-  public int getMajorCompactions() {
-    if (isEnabled()) {
-      int result = 0;
-      for (Tablet tablet : server.getOnlineTablets()) {
-        if (tablet.isMajorCompactionRunning())
-          result++;
-      }
-      return result;
-    }
-    return 0;
-  }
-
-  @Override
-  public int getMajorCompactionsQueued() {
-    if (isEnabled()) {
-      int result = 0;
-      for (Tablet tablet : server.getOnlineTablets()) {
-        if (tablet.isMajorCompactionQueued())
-          result++;
-      }
-      return result;
-    }
-    return 0;
-  }
-
-  @Override
-  public int getMinorCompactions() {
-    if (isEnabled()) {
-      int result = 0;
-      for (Tablet tablet : server.getOnlineTablets()) {
-        if (tablet.isMinorCompactionRunning())
-          result++;
-      }
-      return result;
-    }
-    return 0;
-  }
-
-  @Override
-  public int getMinorCompactionsQueued() {
-    if (isEnabled()) {
-      int result = 0;
-      for (Tablet tablet : server.getOnlineTablets()) {
-        if (tablet.isMinorCompactionQueued())
-          result++;
-      }
-      return result;
-    }
-    return 0;
-  }
-
-  @Override
-  public int getOnlineCount() {
-    if (isEnabled())
-      return server.getOnlineTablets().size();
-    return 0;
-  }
-
-  @Override
-  public int getOpeningCount() {
-    if (isEnabled())
-      return server.getOpeningCount();
-    return 0;
-  }
-
-  @Override
-  public long getQueries() {
-    if (isEnabled()) {
-      long result = 0;
-      for (Tablet tablet : server.getOnlineTablets()) {
-        result += tablet.totalQueries();
-      }
-      return result;
-    }
-    return 0;
-  }
-
-  @Override
-  public int getUnopenedCount() {
-    if (isEnabled())
-      return server.getUnopenedCount();
-    return 0;
-  }
-
-  @Override
-  public String getName() {
-    if (isEnabled())
-      return server.getClientAddressString();
-    return "";
-  }
-
-  @Override
-  public long getTotalMinorCompactions() {
-    if (isEnabled())
-      return server.getTotalMinorCompactions();
-    return 0;
-  }
-
-  @Override
-  public double getHoldTime() {
-    if (isEnabled())
-      return server.getHoldTimeMillis() / 1000.;
-    return 0;
-  }
-
-  @Override
-  public double getAverageFilesPerTablet() {
-    if (isEnabled()) {
-      int count = 0;
-      long result = 0;
-      for (Tablet tablet : server.getOnlineTablets()) {
-        result += tablet.getDatafiles().size();
-        count++;
-      }
-      if (count == 0)
-        return 0;
-      return result / (double) count;
-    }
-    return 0;
-  }
-
-  @Override
-  protected ObjectName getObjectName() {
-    return OBJECT_NAME;
-  }
-
-  @Override
-  protected String getMetricsPrefix() {
-    return METRICS_PREFIX;
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/3cf62239/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerMinCMetrics.java
----------------------------------------------------------------------
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerMinCMetrics.java
b/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerMinCMetrics.java
index a89bb45..25eb0f5 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerMinCMetrics.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerMinCMetrics.java
@@ -19,16 +19,17 @@ package org.apache.accumulo.tserver.metrics;
 import javax.management.ObjectName;
 
 import org.apache.accumulo.server.metrics.AbstractMetricsImpl;
+import org.apache.hadoop.metrics2.MetricsSystem;
 
 public class TabletServerMinCMetrics extends AbstractMetricsImpl implements TabletServerMinCMetricsMBean
{
-  
+
   static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(TabletServerMinCMetrics.class);
-  
+
   private static final String METRICS_PREFIX = "tserver.minc";
-  
+
   private static ObjectName OBJECT_NAME = null;
-  
-  public TabletServerMinCMetrics() {
+
+  public TabletServerMinCMetrics(MetricsSystem metricsSystem) {
     super();
     reset();
     try {
@@ -36,53 +37,63 @@ public class TabletServerMinCMetrics extends AbstractMetricsImpl implements
Tabl
     } catch (Exception e) {
       log.error("Exception setting MBean object name", e);
     }
+    metricsSystem.register(TabletServerMinCMetricsMBean.class.getSimpleName(), this.getClass().getSimpleName(),
this);
   }
-  
+
   @Override
   protected ObjectName getObjectName() {
     return OBJECT_NAME;
   }
-  
+
   @Override
   protected String getMetricsPrefix() {
     return METRICS_PREFIX;
   }
-  
+
+  @Override
   public long getMinorCompactionMinTime() {
     return this.getMetricMin(minc);
   }
-  
+
+  @Override
   public long getMinorCompactionAvgTime() {
     return this.getMetricAvg(minc);
   }
-  
+
+  @Override
   public long getMinorCompactionCount() {
     return this.getMetricCount(minc);
   }
-  
+
+  @Override
   public long getMinorCompactionMaxTime() {
     return this.getMetricMax(minc);
   }
-  
+
+  @Override
   public long getMinorCompactionQueueAvgTime() {
     return this.getMetricAvg(queue);
   }
-  
+
+  @Override
   public long getMinorCompactionQueueCount() {
     return this.getMetricCount(queue);
   }
-  
+
+  @Override
   public long getMinorCompactionQueueMaxTime() {
     return this.getMetricMax(queue);
   }
-  
+
+  @Override
   public long getMinorCompactionQueueMinTime() {
     return this.getMetricMin(minc);
   }
-  
+
+  @Override
   public void reset() {
     createMetric("minc");
     createMetric("queue");
   }
-  
+
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/3cf62239/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerScanMetrics.java
----------------------------------------------------------------------
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerScanMetrics.java
b/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerScanMetrics.java
index 142f171..6dfd7d7 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerScanMetrics.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerScanMetrics.java
@@ -19,16 +19,17 @@ package org.apache.accumulo.tserver.metrics;
 import javax.management.ObjectName;
 
 import org.apache.accumulo.server.metrics.AbstractMetricsImpl;
+import org.apache.hadoop.metrics2.MetricsSystem;
 
 public class TabletServerScanMetrics extends AbstractMetricsImpl implements TabletServerScanMetricsMBean
{
-  
+
   static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(TabletServerScanMetrics.class);
-  
+
   public static final String METRICS_PREFIX = "tserver.scan";
-  
+
   static ObjectName OBJECT_NAME = null;
-  
-  public TabletServerScanMetrics() {
+
+  public TabletServerScanMetrics(MetricsSystem metricsSystem) {
     super();
     reset();
     try {
@@ -36,53 +37,63 @@ public class TabletServerScanMetrics extends AbstractMetricsImpl implements
Tabl
     } catch (Exception e) {
       log.error("Exception setting MBean object name", e);
     }
+    metricsSystem.register(TabletServerScanMetricsMBean.class.getSimpleName(), Thread.currentThread().getName(),
this);
   }
-  
+
   @Override
   protected ObjectName getObjectName() {
     return OBJECT_NAME;
   }
-  
+
   @Override
   protected String getMetricsPrefix() {
     return METRICS_PREFIX;
   }
-  
+
+  @Override
   public long getResultAvgSize() {
     return this.getMetricAvg(resultSize);
   }
-  
+
+  @Override
   public long getResultCount() {
     return this.getMetricCount(resultSize);
   }
-  
+
+  @Override
   public long getResultMaxSize() {
     return this.getMetricMax(resultSize);
   }
-  
+
+  @Override
   public long getResultMinSize() {
     return this.getMetricMin(resultSize);
   }
-  
+
+  @Override
   public long getScanAvgTime() {
     return this.getMetricAvg(scan);
   }
-  
+
+  @Override
   public long getScanCount() {
     return this.getMetricCount(scan);
   }
-  
+
+  @Override
   public long getScanMaxTime() {
     return this.getMetricMax(scan);
   }
-  
+
+  @Override
   public long getScanMinTime() {
     return this.getMetricMin(scan);
   }
-  
+
+  @Override
   public void reset() {
     createMetric(scan);
     createMetric(resultSize);
   }
-  
+
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/3cf62239/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerUpdateMetrics.java
----------------------------------------------------------------------
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerUpdateMetrics.java
b/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerUpdateMetrics.java
index b23fb1a..072a101 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerUpdateMetrics.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/metrics/TabletServerUpdateMetrics.java
@@ -19,16 +19,17 @@ package org.apache.accumulo.tserver.metrics;
 import javax.management.ObjectName;
 
 import org.apache.accumulo.server.metrics.AbstractMetricsImpl;
+import org.apache.hadoop.metrics2.MetricsSystem;
 
 public class TabletServerUpdateMetrics extends AbstractMetricsImpl implements TabletServerUpdateMetricsMBean
{
-  
+
   static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(TabletServerUpdateMetrics.class);
-  
+
   private static final String METRICS_PREFIX = "tserver.update";
-  
+
   private static ObjectName OBJECT_NAME = null;
-  
-  public TabletServerUpdateMetrics() {
+
+  public TabletServerUpdateMetrics(MetricsSystem metricsSystem) {
     super();
     reset();
     try {
@@ -37,90 +38,110 @@ public class TabletServerUpdateMetrics extends AbstractMetricsImpl implements
Ta
     } catch (Exception e) {
       log.error("Exception setting MBean object name", e);
     }
+    metricsSystem.register(TabletServerUpdateMetricsMBean.class.getSimpleName(), Thread.currentThread().getName(),
this);
   }
-  
+
   @Override
   protected ObjectName getObjectName() {
     return OBJECT_NAME;
   }
-  
+
   @Override
   protected String getMetricsPrefix() {
     return METRICS_PREFIX;
   }
-  
+
+  @Override
   public long getPermissionErrorCount() {
     return this.getMetricCount(permissionErrors);
   }
-  
+
+  @Override
   public long getUnknownTabletErrorCount() {
     return this.getMetricCount(unknownTabletErrors);
   }
-  
+
+  @Override
   public long getMutationArrayAvgSize() {
     return this.getMetricAvg(mutationArraySize);
   }
-  
+
+  @Override
   public long getMutationArrayMinSize() {
     return this.getMetricMin(mutationArraySize);
   }
-  
+
+  @Override
   public long getMutationArrayMaxSize() {
     return this.getMetricMax(mutationArraySize);
   }
-  
+
+  @Override
   public long getCommitPrepCount() {
     return this.getMetricCount(commitPrep);
   }
-  
+
+  @Override
   public long getCommitPrepMinTime() {
     return this.getMetricMin(commitPrep);
   }
-  
+
+  @Override
   public long getCommitPrepMaxTime() {
     return this.getMetricMax(commitPrep);
   }
-  
+
+  @Override
   public long getCommitPrepAvgTime() {
     return this.getMetricAvg(commitPrep);
   }
-  
+
+  @Override
   public long getConstraintViolationCount() {
     return this.getMetricCount(constraintViolations);
   }
-  
+
+  @Override
   public long getWALogWriteCount() {
     return this.getMetricCount(waLogWriteTime);
   }
-  
+
+  @Override
   public long getWALogWriteMinTime() {
     return this.getMetricMin(waLogWriteTime);
   }
-  
+
+  @Override
   public long getWALogWriteMaxTime() {
     return this.getMetricMax(waLogWriteTime);
   }
-  
+
+  @Override
   public long getWALogWriteAvgTime() {
     return this.getMetricAvg(waLogWriteTime);
   }
-  
+
+  @Override
   public long getCommitCount() {
     return this.getMetricCount(commitTime);
   }
-  
+
+  @Override
   public long getCommitMinTime() {
     return this.getMetricMin(commitTime);
   }
-  
+
+  @Override
   public long getCommitMaxTime() {
     return this.getMetricMax(commitTime);
   }
-  
+
+  @Override
   public long getCommitAvgTime() {
     return this.getMetricAvg(commitTime);
   }
-  
+
+  @Override
   public void reset() {
     createMetric(permissionErrors);
     createMetric(unknownTabletErrors);
@@ -130,5 +151,5 @@ public class TabletServerUpdateMetrics extends AbstractMetricsImpl implements
Ta
     createMetric(waLogWriteTime);
     createMetric(commitTime);
   }
-  
+
 }


Mime
View raw message