accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [2/2] accumulo git commit: Rip out a bunch of code specific to how we used to configure metrics as metrics2 invalidates it.
Date Wed, 03 Dec 2014 18:29:09 GMT
Rip out a bunch of code specific to how we used to configure metrics as metrics2 invalidates
it.

Not sure if this is the best way to go -- will revert if we need to.


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

Branch: refs/heads/metrics2
Commit: ec8e49db2916826c6d3866d0361f60bd43b045d3
Parents: b0fbb0c
Author: Josh Elser <elserj@apache.org>
Authored: Wed Dec 3 13:28:21 2014 -0500
Committer: Josh Elser <elserj@apache.org>
Committed: Wed Dec 3 13:28:21 2014 -0500

----------------------------------------------------------------------
 .../server/metrics/AbstractMetricsImpl.java     | 152 ------------
 .../server/metrics/MetricsConfiguration.java    | 236 -------------------
 .../accumulo/server/util/TServerUtils.java      |  22 +-
 .../java/org/apache/accumulo/master/Master.java |   4 +-
 .../master/metrics/ReplicationMetrics.java      |   3 -
 .../apache/accumulo/tserver/TabletServer.java   |  49 +---
 .../metrics/TabletServerGeneralMetrics.java     | 160 +++++--------
 .../apache/accumulo/tserver/tablet/Tablet.java  |   6 +-
 8 files changed, 80 insertions(+), 552 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/ec8e49db/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 42ca83c..42fcc52 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
@@ -16,25 +16,15 @@
  */
 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.text.SimpleDateFormat;
-import java.util.Date;
 import java.util.Map.Entry;
 import java.util.concurrent.ConcurrentHashMap;
 
 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.MetricsRecordBuilder;
 import org.apache.hadoop.metrics2.MetricsSource;
@@ -116,54 +106,6 @@ public abstract class AbstractMetricsImpl implements MetricsSource {
 
   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());
-
-    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());
-    setupLogging();
-  }
-
   public void createMetric(String name) {
     registry.put(name, new Metric());
   }
@@ -188,109 +130,15 @@ public abstract class AbstractMetricsImpl implements MetricsSource
{
     return registry.get(name).getMax();
   }
 
-  private void setupLogging() throws IOException {
-    if (null == config.getMetricsConfiguration())
-      return;
-    // If we are already logging, then return
-    if (!currentlyLogging && config.getMetricsConfiguration().getBoolean(metricsPrefix
+ ".logging", false)) {
-      // Check to see if directory exists, else make it
-      String mDir = config.getMetricsConfiguration().getString("logging.dir");
-      if (null != mDir) {
-        File dir = new File(mDir);
-        if (!dir.isDirectory())
-          if (!dir.mkdir())
-            log.warn("Could not create log directory: " + dir);
-        logDir = dir;
-        // Create new log file
-        startNewLog();
-      }
-      currentlyLogging = true;
-    }
-  }
-
-  private void startNewLog() throws IOException {
-    if (null != logWriter) {
-      logWriter.flush();
-      logWriter.close();
-    }
-    logFile = new File(logDir, metricsPrefix + "-" + formatter.format(today) + ".log");
-    if (!logFile.exists()) {
-      if (!logFile.createNewFile()) {
-        log.error("Unable to create new log file");
-        currentlyLogging = false;
-        return;
-      }
-    }
-    logWriter = new OutputStreamWriter(new FileOutputStream(logFile, true), UTF_8);
-  }
-
-  private void writeToLog(String name) throws IOException {
-    if (null == logWriter)
-      return;
-    // Increment the date if we have to
-    Date now = new Date();
-    if (!DateUtils.isSameDay(today, now)) {
-      today = now;
-      startNewLog();
-    }
-    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();
       registry.get(name).addAvg(time);
       registry.get(name).addMin(time);
       registry.get(name).addMax(time);
-      // If we are not currently logging and should be, then initialize
-      if (!currentlyLogging && config.getMetricsConfiguration().getBoolean(metricsPrefix
+ ".logging", false)) {
-        try {
-          setupLogging();
-        } catch (IOException ioe) {
-          log.error("Error setting up log", ioe);
-        }
-      } else if (currentlyLogging && !config.getMetricsConfiguration().getBoolean(metricsPrefix
+ ".logging", false)) {
-        // if we are currently logging and shouldn't be, then close logs
-        try {
-          logWriter.flush();
-          logWriter.close();
-          logWriter = null;
-          logFile = null;
-        } catch (Exception e) {
-          log.error("Error stopping metrics logging", e);
-        }
-        currentlyLogging = false;
-      }
-      if (currentlyLogging) {
-        try {
-          writeToLog(name);
-        } catch (IOException ioe) {
-          log.error("Error writing to metrics log", ioe);
-        }
-      }
-    }
-  }
-
-  public boolean isEnabled() {
-    return config.isEnabled();
   }
 
   protected abstract ObjectName getObjectName();
 
   protected abstract String getMetricsPrefix();
 
-  @Override
-  protected void finalize() {
-    if (null != logWriter) {
-      try {
-        logWriter.close();
-      } catch (Exception e) {
-        // do nothing
-      } finally {
-        logWriter = null;
-      }
-    }
-    logFile = null;
-  }
-
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/ec8e49db/server/base/src/main/java/org/apache/accumulo/server/metrics/MetricsConfiguration.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/metrics/MetricsConfiguration.java
b/server/base/src/main/java/org/apache/accumulo/server/metrics/MetricsConfiguration.java
deleted file mode 100644
index 087ca12..0000000
--- a/server/base/src/main/java/org/apache/accumulo/server/metrics/MetricsConfiguration.java
+++ /dev/null
@@ -1,236 +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.server.metrics;
-
-import java.io.File;
-import java.util.Iterator;
-
-import org.apache.accumulo.core.util.Daemon;
-import org.apache.commons.configuration.AbstractFileConfiguration;
-import org.apache.commons.configuration.Configuration;
-import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.configuration.EnvironmentConfiguration;
-import org.apache.commons.configuration.SystemConfiguration;
-import org.apache.commons.configuration.XMLConfiguration;
-import org.apache.commons.configuration.event.ConfigurationEvent;
-import org.apache.commons.configuration.event.ConfigurationListener;
-import org.apache.commons.configuration.reloading.FileChangedReloadingStrategy;
-import org.apache.commons.lang.builder.ToStringBuilder;
-
-public class MetricsConfiguration {
-  
-  private static final org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(MetricsConfiguration.class);
-  
-  private static final String metricsFileName = "accumulo-metrics.xml";
-  
-  private static boolean alreadyWarned = false;
-  
-  private boolean notFound = false;
-  
-  private int notFoundCount = 0;
-  
-  private static SystemConfiguration sysConfig = null;
-  
-  private static EnvironmentConfiguration envConfig = null;
-  
-  private XMLConfiguration xConfig = null;
-  
-  private Configuration config = null;
-  
-  private final Object lock = new Object();
-  
-  private boolean needsReloading = false;
-  
-  private long lastCheckTime = 0;
-  
-  private static long CONFIG_FILE_CHECK_INTERVAL = 1000 * 60 * 10; // 10 minutes
-  
-  private static int CONFIG_FILE_CHECK_COUNTER = 100;
-  
-  public final static long CONFIG_FILE_RELOAD_DELAY = 60000;
-  
-  private MetricsConfigWatcher watcher = null;
-  
-  private boolean enabled = false;
-  
-  private String enabledName = null;
-  
-  /**
-   * Background thread that pokes the XMLConfiguration file to see if it has changed. If
it has, then the Configuration Listener will get an event.
-   * 
-   */
-  private class MetricsConfigWatcher extends Daemon {
-    public MetricsConfigWatcher() {}
-    
-    public void run() {
-      while (this.isAlive()) {
-        try {
-          Thread.sleep(MetricsConfiguration.CONFIG_FILE_RELOAD_DELAY);
-        } catch (InterruptedException ie) {
-          // Do Nothing
-        }
-        xConfig.getBoolean("master.enabled");
-      }
-    }
-  }
-  
-  /**
-   * ConfigurationListener that sets a flag to reload the XML config file
-   */
-  private class MetricsConfigListener implements ConfigurationListener {
-    public void configurationChanged(ConfigurationEvent event) {
-      if (event.getType() == AbstractFileConfiguration.EVENT_RELOAD)
-        needsReloading = true;
-    }
-  }
-  
-  public MetricsConfiguration(String name) {
-    // We are going to store the "enabled" parameter for this
-    // name as a shortcut so that it doesn't have to be looked
-    // up in the configuration so much.
-    this.enabledName = name + ".enabled";
-    getMetricsConfiguration();
-  }
-  
-  public Configuration getEnvironmentConfiguration() {
-    synchronized (MetricsConfiguration.class) {
-      if (null == envConfig)
-        envConfig = new EnvironmentConfiguration();
-      return envConfig;
-    }
-  }
-  
-  public Configuration getSystemConfiguration() {
-    synchronized (MetricsConfiguration.class) {
-      if (null == sysConfig)
-        sysConfig = new SystemConfiguration();
-      return sysConfig;
-    }
-  }
-  
-  public Configuration getMetricsConfiguration() {
-    if (notFound) {
-      if (notFoundCount <= CONFIG_FILE_CHECK_COUNTER) {
-        return null;
-      } else if ((notFoundCount > CONFIG_FILE_CHECK_COUNTER) && ((System.currentTimeMillis()
- lastCheckTime) > CONFIG_FILE_CHECK_INTERVAL)) {
-        notFoundCount = 0;
-        lastCheckTime = System.currentTimeMillis();
-        notFound = false;
-      } else {
-        notFoundCount++;
-      }
-    }
-    if (null == config || needsReloading)
-      synchronized (lock) {
-        if (needsReloading) {
-          loadConfiguration();
-        } else if (null == config) {
-          loadConfiguration();
-        }
-        needsReloading = false;
-      }
-    return config;
-  }
-  
-  private void loadConfiguration() {
-    // Check to see if ACCUMULO_HOME environment variable is set.
-    String ACUHOME = getEnvironmentConfiguration().getString("ACCUMULO_CONF_DIR");
-    if (null != ACUHOME) {
-      // Try to load the metrics properties file
-      File mFile = new File(ACUHOME, metricsFileName);
-      if (mFile.exists()) {
-        if (log.isDebugEnabled())
-          log.debug("Loading config file: " + mFile.getAbsolutePath());
-        try {
-          xConfig = new XMLConfiguration(mFile);
-          xConfig.append(getEnvironmentConfiguration());
-          xConfig.addConfigurationListener(new MetricsConfigListener());
-          xConfig.setReloadingStrategy(new FileChangedReloadingStrategy());
-          
-          // Start a background Thread that checks a property from the XMLConfiguration
-          // every so often to force the FileChangedReloadingStrategy to fire.
-          if (null == watcher || !watcher.isAlive()) {
-            watcher = new MetricsConfigWatcher();
-            watcher.start();
-          }
-          notFound = false;
-          alreadyWarned = false;
-        } catch (ConfigurationException ce) {
-          log.error("Error reading accumulo-metrics.xml file.");
-          notFound = true;
-          return;
-        }
-      } else {
-        if (!alreadyWarned)
-          log.warn("Unable to find metrics file: " + mFile.getAbsolutePath());
-        alreadyWarned = true;
-        notFound = true;
-        return;
-      }
-    } else {
-      if (!alreadyWarned)
-        log.warn("ACCUMULO_CONF_DIR variable not found in environment. Metrics collection
will be disabled.");
-      alreadyWarned = true;
-      notFound = true;
-      return;
-    }
-    if (xConfig != null) {
-      config = xConfig.interpolatedConfiguration();
-      // set the enabled boolean from the configuration
-      enabled = config.getBoolean(enabledName);
-      if (log.isDebugEnabled())
-        log.debug("Metrics collection enabled=" + enabled);
-    } else {
-      enabled = false;
-    }
-    
-  }
-  
-  public boolean isEnabled() {
-    // Force reload if necessary
-    if (null == getMetricsConfiguration())
-      return false;
-    return enabled;
-  }
-  
-  public static String toStringValue(Configuration config) {
-    ToStringBuilder tsb = new ToStringBuilder(MetricsConfiguration.class);
-    Iterator<?> keys = config.getKeys();
-    while (keys.hasNext()) {
-      tsb.append("\n");
-      String k = (String) keys.next();
-      Object v = config.getString(k);
-      if (null == v)
-        v = config.getList(k);
-      tsb.append(k, v.toString());
-    }
-    return tsb.toString();
-  }
-  
-  public static void main(String[] args) throws Exception {
-    MetricsConfiguration mc = new MetricsConfiguration("master");
-    while (true) {
-      // System.out.println(MetricsConfiguration.toStringValue(getSystemConfiguration()));
-      System.out.println("------------------------------------------------------------------------------------------------");
-      // System.out.println(MetricsConfiguration.toStringValue());
-      long t1 = System.currentTimeMillis();
-      System.out.println(mc.isEnabled() + " took: " + (System.currentTimeMillis() - t1));
-      Thread.sleep(1000);
-    }
-  }
-  
-}

http://git-wip-us.apache.org/repos/asf/accumulo/blob/ec8e49db/server/base/src/main/java/org/apache/accumulo/server/util/TServerUtils.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/TServerUtils.java b/server/base/src/main/java/org/apache/accumulo/server/util/TServerUtils.java
index d30f101..9bf40d1 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/TServerUtils.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/TServerUtils.java
@@ -70,7 +70,7 @@ public class TServerUtils {
 
   /**
    * Start a server, at the given port, or higher, if that port is not available.
-   * 
+   *
    * @param portHintProperty
    *          the port to attempt to open, can be zero, meaning "any available port"
    * @param processor
@@ -148,30 +148,20 @@ public class TServerUtils {
 
     TimedProcessor(TProcessor next, String serverName, String threadName) {
       this.other = next;
-      // Register the metrics MBean
-      try {
-        metrics = new ThriftMetrics(serverName, threadName);
-        metrics.register();
-      } catch (Exception e) {
-        log.error("Exception registering MBean with MBean Server", e);
-      }
+      metrics = new ThriftMetrics(serverName, threadName);
       idleStart = System.currentTimeMillis();
     }
 
     @Override
     public boolean process(TProtocol in, TProtocol out) throws TException {
       long now = 0;
-      if (metrics.isEnabled()) {
-        now = System.currentTimeMillis();
-        metrics.add(ThriftMetrics.idle, (now - idleStart));
-      }
+      now = System.currentTimeMillis();
+      metrics.add(ThriftMetrics.idle, (now - idleStart));
       try {
         return other.process(in, out);
       } finally {
-        if (metrics.isEnabled()) {
-          idleStart = System.currentTimeMillis();
-          metrics.add(ThriftMetrics.execute, idleStart - now);
-        }
+        idleStart = System.currentTimeMillis();
+        metrics.add(ThriftMetrics.execute, idleStart - now);
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/ec8e49db/server/master/src/main/java/org/apache/accumulo/master/Master.java
----------------------------------------------------------------------
diff --git a/server/master/src/main/java/org/apache/accumulo/master/Master.java b/server/master/src/main/java/org/apache/accumulo/master/Master.java
index d5d5145..61df06b 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/Master.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/Master.java
@@ -1127,8 +1127,8 @@ public class Master extends AccumuloServerContext implements LiveTServerSet.List
         replAddress.address.toString().getBytes(UTF_8), NodeExistsPolicy.OVERWRITE);
 
     try {
-      ReplicationMetrics beanImpl = new ReplicationMetrics(this);
-      beanImpl.register();
+      // Registers with the metrics system
+      new ReplicationMetrics(this);
     } catch (Exception e) {
       log.error("Error registering Replication metrics with JMX", e);
     }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/ec8e49db/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 28467ce..8436322 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,10 +31,7 @@ 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

http://git-wip-us.apache.org/repos/asf/accumulo/blob/ec8e49db/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 c94bf82..f4aa008 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
@@ -366,13 +366,6 @@ public class TabletServer extends AccumuloServerContext implements Runnable
{
     ThriftClientHandler() {
       super(TabletServer.this, watcher, fs);
       log.debug(ThriftClientHandler.class.getName() + " created");
-      // Register the metrics MBean
-      try {
-        updateMetrics.register();
-        scanMetrics.register();
-      } catch (Exception e) {
-        log.error("Exception registering MBean with MBean Server", e);
-      }
     }
 
     @Override
@@ -545,10 +538,8 @@ public class TabletServer extends AccumuloServerContext implements Runnable
{
 
         log.debug(String.format("ScanSess tid %s %s %,d entries in %.2f secs, nbTimes = [%s]
", TServerUtils.clientAddress.get(), ss.extent.getTableId()
             .toString(), ss.entriesReturned, (t2 - ss.startTime) / 1000.0, ss.nbTimes.toString()));
-        if (scanMetrics.isEnabled()) {
-          scanMetrics.add(TabletServerScanMetrics.scan, t2 - ss.startTime);
-          scanMetrics.add(TabletServerScanMetrics.resultSize, ss.entriesReturned);
-        }
+        scanMetrics.add(TabletServerScanMetrics.scan, t2 - ss.startTime);
+        scanMetrics.add(TabletServerScanMetrics.resultSize, ss.entriesReturned);
       }
     }
 
@@ -668,8 +659,7 @@ public class TabletServer extends AccumuloServerContext implements Runnable
{
       // Make sure user is real
       Durability durability = DurabilityImpl.fromThrift(tdurabilty);
       security.authenticateUser(credentials, credentials);
-      if (updateMetrics.isEnabled())
-        updateMetrics.add(TabletServerUpdateMetrics.permissionErrors, 0);
+      updateMetrics.add(TabletServerUpdateMetrics.permissionErrors, 0);
 
       UpdateSession us = new UpdateSession(new TservConstraintEnv(security, credentials),
credentials, durability);
       long sid = sessionManager.createSession(us, false);
@@ -700,8 +690,7 @@ public class TabletServer extends AccumuloServerContext implements Runnable
{
             // not serving tablet, so report all mutations as
             // failures
             us.failures.put(keyExtent, 0l);
-            if (updateMetrics.isEnabled())
-              updateMetrics.add(TabletServerUpdateMetrics.unknownTabletErrors, 0);
+            updateMetrics.add(TabletServerUpdateMetrics.unknownTabletErrors, 0);
           }
         } else {
           log.warn("Denying access to table " + keyExtent.getTableId() + " for user " + us.getUser());
@@ -709,8 +698,7 @@ public class TabletServer extends AccumuloServerContext implements Runnable
{
           us.authTimes.addStat(t2 - t1);
           us.currentTablet = null;
           us.authFailures.put(keyExtent, SecurityErrorCode.PERMISSION_DENIED);
-          if (updateMetrics.isEnabled())
-            updateMetrics.add(TabletServerUpdateMetrics.permissionErrors, 0);
+          updateMetrics.add(TabletServerUpdateMetrics.permissionErrors, 0);
           return;
         }
       } catch (ThriftSecurityException e) {
@@ -719,8 +707,7 @@ public class TabletServer extends AccumuloServerContext implements Runnable
{
         us.authTimes.addStat(t2 - t1);
         us.currentTablet = null;
         us.authFailures.put(keyExtent, e.getCode());
-        if (updateMetrics.isEnabled())
-          updateMetrics.add(TabletServerUpdateMetrics.permissionErrors, 0);
+        updateMetrics.add(TabletServerUpdateMetrics.permissionErrors, 0);
         return;
       }
     }
@@ -781,8 +768,7 @@ public class TabletServer extends AccumuloServerContext implements Runnable
{
           List<Mutation> mutations = entry.getValue();
           if (mutations.size() > 0) {
             try {
-              if (updateMetrics.isEnabled())
-                updateMetrics.add(TabletServerUpdateMetrics.mutationArraySize, mutations.size());
+              updateMetrics.add(TabletServerUpdateMetrics.mutationArraySize, mutations.size());
 
               CommitSession commitSession = tablet.prepareMutationsForCommit(us.cenv, mutations);
               if (commitSession == null) {
@@ -797,8 +783,7 @@ public class TabletServer extends AccumuloServerContext implements Runnable
{
 
             } catch (TConstraintViolationException e) {
               us.violations.add(e.getViolations());
-              if (updateMetrics.isEnabled())
-                updateMetrics.add(TabletServerUpdateMetrics.constraintViolations, 0);
+              updateMetrics.add(TabletServerUpdateMetrics.constraintViolations, 0);
 
               if (e.getNonViolators().size() > 0) {
                 // only log and commit mutations if there were some
@@ -900,18 +885,15 @@ public class TabletServer extends AccumuloServerContext implements Runnable
{
     }
 
     private void updateWalogWriteTime(long time) {
-      if (updateMetrics.isEnabled())
-        updateMetrics.add(TabletServerUpdateMetrics.waLogWriteTime, time);
+      updateMetrics.add(TabletServerUpdateMetrics.waLogWriteTime, time);
     }
 
     private void updateAvgCommitTime(long time, int size) {
-      if (updateMetrics.isEnabled())
-        updateMetrics.add(TabletServerUpdateMetrics.commitTime, (long) ((time) / (double)
size));
+      updateMetrics.add(TabletServerUpdateMetrics.commitTime, (long) ((time) / (double) size));
     }
 
     private void updateAvgPrepTime(long time, int size) {
-      if (updateMetrics.isEnabled())
-        updateMetrics.add(TabletServerUpdateMetrics.commitPrep, (long) ((time) / (double)
size));
+      updateMetrics.add(TabletServerUpdateMetrics.commitPrep, (long) ((time) / (double) size));
     }
 
     @Override
@@ -2438,14 +2420,7 @@ public class TabletServer extends AccumuloServerContext implements
Runnable {
     SimpleTimer.getInstance(aconf).schedule(replicationWorkThreadPoolResizer, 10000, 30000);
 
     try {
-      // Do this because interface not in same package.
-      TabletServerGeneralMetrics beanImpl = new TabletServerGeneralMetrics(this);
-      beanImpl.register();
-      // StandardMBean mbean = new StandardMBean(beanImpl, TabletServerGeneralMetricsMBean.class,
false);
-      // beanImpl.register(mbean);
-      mincMetrics.register();
-      scanMetrics.register();
-      updateMetrics.register();
+      new TabletServerGeneralMetrics(this);
     } catch (Exception e) {
       log.error("Error registering with JMX", e);
     }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/ec8e49db/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
index 917701d..13e4d1a 100644
--- 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
@@ -46,178 +46,134 @@ public class TabletServerGeneralMetrics extends AbstractMetricsImpl
implements T
   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())
+    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;
+    long result = 0;
+    for (Tablet tablet : server.getOnlineTablets()) {
+      result += tablet.getNumEntries();
     }
-    return 0;
+    return result;
   }
 
   @Override
   public long getEntriesInMemory() {
-    if (isEnabled()) {
-      long result = 0;
-      for (Tablet tablet : server.getOnlineTablets()) {
-        result += tablet.getNumEntriesInMemory();
-      }
-      return result;
+    long result = 0;
+    for (Tablet tablet : server.getOnlineTablets()) {
+      result += tablet.getNumEntriesInMemory();
     }
-    return 0;
+    return result;
   }
 
   @Override
   public long getIngest() {
-    if (isEnabled()) {
-      long result = 0;
-      for (Tablet tablet : server.getOnlineTablets()) {
-        result += tablet.getNumEntriesInMemory();
-      }
-      return result;
+    long result = 0;
+    for (Tablet tablet : server.getOnlineTablets()) {
+      result += tablet.getNumEntriesInMemory();
     }
-    return 0;
+    return result;
   }
 
   @Override
   public int getMajorCompactions() {
-    if (isEnabled()) {
-      int result = 0;
-      for (Tablet tablet : server.getOnlineTablets()) {
-        if (tablet.isMajorCompactionRunning())
-          result++;
-      }
-      return result;
+    int result = 0;
+    for (Tablet tablet : server.getOnlineTablets()) {
+      if (tablet.isMajorCompactionRunning())
+        result++;
     }
-    return 0;
+    return result;
   }
 
   @Override
   public int getMajorCompactionsQueued() {
-    if (isEnabled()) {
-      int result = 0;
-      for (Tablet tablet : server.getOnlineTablets()) {
-        if (tablet.isMajorCompactionQueued())
-          result++;
-      }
-      return result;
+    int result = 0;
+    for (Tablet tablet : server.getOnlineTablets()) {
+      if (tablet.isMajorCompactionQueued())
+        result++;
     }
-    return 0;
+    return result;
   }
 
   @Override
   public int getMinorCompactions() {
-    if (isEnabled()) {
-      int result = 0;
-      for (Tablet tablet : server.getOnlineTablets()) {
-        if (tablet.isMinorCompactionRunning())
-          result++;
-      }
-      return result;
+    int result = 0;
+    for (Tablet tablet : server.getOnlineTablets()) {
+      if (tablet.isMinorCompactionRunning())
+        result++;
     }
-    return 0;
+    return result;
   }
 
   @Override
   public int getMinorCompactionsQueued() {
-    if (isEnabled()) {
-      int result = 0;
-      for (Tablet tablet : server.getOnlineTablets()) {
-        if (tablet.isMinorCompactionQueued())
-          result++;
-      }
-      return result;
+    int result = 0;
+    for (Tablet tablet : server.getOnlineTablets()) {
+      if (tablet.isMinorCompactionQueued())
+        result++;
     }
-    return 0;
+    return result;
   }
 
   @Override
   public int getOnlineCount() {
-    if (isEnabled())
-      return server.getOnlineTablets().size();
-    return 0;
+    return server.getOnlineTablets().size();
   }
 
   @Override
   public int getOpeningCount() {
-    if (isEnabled())
-      return server.getOpeningCount();
-    return 0;
+    return server.getOpeningCount();
   }
 
   @Override
   public long getQueries() {
-    if (isEnabled()) {
-      long result = 0;
-      for (Tablet tablet : server.getOnlineTablets()) {
-        result += tablet.totalQueries();
-      }
-      return result;
+    long result = 0;
+    for (Tablet tablet : server.getOnlineTablets()) {
+      result += tablet.totalQueries();
     }
-    return 0;
+    return result;
   }
 
   @Override
   public int getUnopenedCount() {
-    if (isEnabled())
-      return server.getUnopenedCount();
-    return 0;
+    return server.getUnopenedCount();
   }
 
   @Override
   public String getName() {
-    if (isEnabled())
-      return server.getClientAddressString();
-    return "";
+    return server.getClientAddressString();
   }
 
   @Override
   public long getTotalMinorCompactions() {
-    if (isEnabled())
-      return server.getTotalMinorCompactions();
-    return 0;
+    return server.getTotalMinorCompactions();
   }
 
   @Override
   public double getHoldTime() {
-    if (isEnabled())
-      return server.getHoldTimeMillis() / 1000.;
-    return 0;
+    return server.getHoldTimeMillis() / 1000.;
   }
 
   @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;
+    int count = 0;
+    long result = 0;
+    for (Tablet tablet : server.getOnlineTablets()) {
+      result += tablet.getDatafiles().size();
+      count++;
     }
-    return 0;
+    if (count == 0)
+      return 0;
+    return result / (double) count;
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/accumulo/blob/ec8e49db/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
----------------------------------------------------------------------
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
index bc55c4f..6ecfa29 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
@@ -972,12 +972,10 @@ public class Tablet implements TabletCommitter {
         lastMinorCompactionFinishTime = System.currentTimeMillis();
       }
       TabletServerMinCMetrics minCMetrics = getTabletServer().getMinCMetrics();
-      if (minCMetrics.isEnabled())
-        minCMetrics.add(TabletServerMinCMetrics.minc, (lastMinorCompactionFinishTime - start));
+      minCMetrics.add(TabletServerMinCMetrics.minc, (lastMinorCompactionFinishTime - start));
       if (hasQueueTime) {
         timer.updateTime(Operation.MINOR, queued, start, count, failed);
-        if (minCMetrics.isEnabled())
-          minCMetrics.add(TabletServerMinCMetrics.queue, (start - queued));
+        minCMetrics.add(TabletServerMinCMetrics.queue, (start - queued));
       } else
         timer.updateTime(Operation.MINOR, start, count, failed);
     }


Mime
View raw message