hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1374398 - /hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/RegionServerDynamicMetrics.java
Date Fri, 17 Aug 2012 19:03:05 GMT
Author: stack
Date: Fri Aug 17 19:03:05 2012
New Revision: 1374398

URL: http://svn.apache.org/viewvc?rev=1374398&view=rev
Log:
HBASE-6602 Region Server Dynamic Metrics can cause high cpu usage.

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

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/RegionServerDynamicMetrics.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/RegionServerDynamicMetrics.java?rev=1374398&r1=1374397&r2=1374398&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/RegionServerDynamicMetrics.java
(original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/RegionServerDynamicMetrics.java
Fri Aug 17 19:03:05 2012
@@ -62,6 +62,7 @@ public class RegionServerDynamicMetrics 
     LogFactory.getLog(RegionServerDynamicStatistics.class);
   
   private boolean reflectionInitialized = false;
+  private boolean needsUpdateMessage = false;
   private Field recordMetricMapField;
   private Field registryMetricMapField;
 
@@ -100,14 +101,7 @@ public class RegionServerDynamicMetrics 
     MetricsLongValue m = (MetricsLongValue)registry.get(name);
     if (m == null) {
       m = new MetricsLongValue(name, this.registry);
-      try {
-        if (updateMbeanInfoIfMetricsListChanged != null) {
-          updateMbeanInfoIfMetricsListChanged.invoke(this.rsDynamicStatistics,
-              new Object[]{});
-        }
-      } catch (Exception e) {
-        LOG.error(e);
-      }
+      this.needsUpdateMessage = true;
     }
     m.set(amt);
   }
@@ -119,14 +113,7 @@ public class RegionServerDynamicMetrics 
     MetricsTimeVaryingRate m = (MetricsTimeVaryingRate)registry.get(name);
     if (m == null) {
       m = new MetricsTimeVaryingRate(name, this.registry);
-      try {
-        if (updateMbeanInfoIfMetricsListChanged != null) {
-          updateMbeanInfoIfMetricsListChanged.invoke(this.rsDynamicStatistics,
-              new Object[]{});
-        }
-      } catch (Exception e) {
-        LOG.error(e);
-      }
+      this.needsUpdateMessage = true;
     }
     if (numOps > 0) {
       m.inc(numOps, amt);
@@ -139,7 +126,7 @@ public class RegionServerDynamicMetrics 
    */
   @SuppressWarnings("rawtypes")
   public void clear() {
-    
+    this.needsUpdateMessage = true;
     // If this is the first clear use reflection to get the two maps that hold copies of
our 
     // metrics on the hadoop metrics side. We have to use reflection because there is not

     // remove metrics on the hadoop side. If we can't get them then clearing old metrics

@@ -210,6 +197,21 @@ public class RegionServerDynamicMetrics 
           value.getSecond().getAndSet(0));
     }
 
+    // If there are new metrics sending this message to jmx tells it to update everything.
+    // This is not ideal we should just move to metrics2 that has full support for dynamic
metrics.
+    if (needsUpdateMessage) {
+      try {
+        if (updateMbeanInfoIfMetricsListChanged != null) {
+          updateMbeanInfoIfMetricsListChanged.invoke(this.rsDynamicStatistics,
+              new Object[]{});
+        }
+      } catch (Exception e) {
+        LOG.error(e);
+      }
+      needsUpdateMessage = false;
+    }
+
+
     synchronized (registry) {
       // Iterate through the registry to propagate the different rpc metrics.
       for (String metricName : registry.getKeyList() ) {



Mime
View raw message