You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by ec...@apache.org on 2012/10/30 21:58:46 UTC

svn commit: r1403865 - /hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/OperationMetrics.java

Author: eclark
Date: Tue Oct 30 20:58:45 2012
New Revision: 1403865

URL: http://svn.apache.org/viewvc?rev=1403865&view=rev
Log:
HBASE-7073 OperationMetrics needs to cache the value of hbase.metrics.exposeOperationTimes

Modified:
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/OperationMetrics.java

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/OperationMetrics.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/OperationMetrics.java?rev=1403865&r1=1403864&r2=1403865&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/OperationMetrics.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/OperationMetrics.java Tue Oct 30 20:58:45 2012
@@ -51,11 +51,12 @@ public class OperationMetrics {
   private static final String CONF_KEY =
       "hbase.metrics.exposeOperationTimes";
 
-  private String tableName = null;
-  private String regionName = null;
-  private String regionMetrixPrefix = null;
-  private Configuration conf = null;
-  
+  private final String tableName;
+  private final String regionName;
+  private final String regionMetrixPrefix;
+  private final Configuration conf;
+  private final boolean exposeTimes;
+
 
   /**
    * Create a new OperationMetrics
@@ -78,6 +79,14 @@ public class OperationMetrics {
       }
       this.regionMetrixPrefix =
           SchemaMetrics.generateRegionMetricsPrefix(this.tableName, this.regionName);
+      this.exposeTimes = this.conf.getBoolean(CONF_KEY, true);
+    } else {
+      //Make all the final values happy.
+      this.conf = null;
+      this.tableName = null;
+      this.regionName = null;
+      this.regionMetrixPrefix = null;
+      this.exposeTimes = false;
     }
   }
   
@@ -212,7 +221,7 @@ public class OperationMetrics {
   }
 
   private void doSafeIncTimeVarying(String prefix, String key, long value) {
-    if (conf.getBoolean(CONF_KEY, true)) {
+    if (exposeTimes) {
       if (prefix != null && !prefix.isEmpty() && key != null && !key.isEmpty()) {
         String m = prefix + key;
         RegionMetricsStorage.incrTimeVaryingMetric(m, value);