hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nspiegelb...@apache.org
Subject svn commit: r1181561 - /hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/RegionServerDynamicMetrics.java
Date Tue, 11 Oct 2011 02:20:28 GMT
Author: nspiegelberg
Date: Tue Oct 11 02:20:28 2011
New Revision: 1181561

URL: http://svn.apache.org/viewvc?rev=1181561&view=rev
Log:
Fix RegionServerDynamicMetrics to push NumOps metrics for every interval

Summary:
RegionServerDynamicMetrics uses the MBean
RegionServerDynamicStatistics to push out metrics. This MBean did not
have the functionality of dynamically updating the metrics list it uses.

Test Plan:
Verify metrics in dev cluster

Reviewed By: kannan
Reviewers: kannan, nspiegelberg, dhruba, hkuang, dms
Commenters: nspiegelberg, dhruba
CC: lshepard, mattwkelly, brent, pritam, kannan, ,
hbase@lists, nspiegelberg, dhruba
Revert Plan:
Tags:

- begin *PUBLIC* platform impact section -
Bugzilla: #
- end platform impact -

Differential Revision: 255866

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

Modified: hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/RegionServerDynamicMetrics.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/RegionServerDynamicMetrics.java?rev=1181561&r1=1181560&r2=1181561&view=diff
==============================================================================
--- hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/RegionServerDynamicMetrics.java
(original)
+++ hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/regionserver/metrics/RegionServerDynamicMetrics.java
Tue Oct 11 02:20:28 2011
@@ -20,10 +20,13 @@
 
 package org.apache.hadoop.hbase.regionserver.metrics;
 
+import java.lang.reflect.Method;
 import java.util.Map.Entry;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.hbase.regionserver.HRegion;
 import org.apache.hadoop.hbase.util.Pair;
 import org.apache.hadoop.metrics.MetricsContext;
@@ -51,6 +54,9 @@ public class RegionServerDynamicMetrics 
   private MetricsRecord metricsRecord;
   private MetricsContext context;
   private final RegionServerDynamicStatistics rsDynamicStatistics;
+  private Method updateMbeanInfoIfMetricsListChanged = null;
+  private static final Log LOG =
+    LogFactory.getLog(RegionServerDynamicStatistics.class);
 
   /**
    * The metrics variables are public:
@@ -65,6 +71,15 @@ public class RegionServerDynamicMetrics 
                             this.context,
                             "RegionServerDynamicStatistics");
     this.rsDynamicStatistics = new RegionServerDynamicStatistics(this.registry);
+    try {
+      updateMbeanInfoIfMetricsListChanged =
+        this.rsDynamicStatistics.getClass().getSuperclass()
+        .getDeclaredMethod("updateMbeanInfoIfMetricsListChanged",
+            new Class[]{});
+      updateMbeanInfoIfMetricsListChanged.setAccessible(true);
+    } catch (Exception e) {
+      LOG.error(e);
+    }
   }
 
   public static RegionServerDynamicMetrics newInstance() {
@@ -78,6 +93,14 @@ 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);
+      }
     }
     m.set(amt);
   }
@@ -89,6 +112,14 @@ 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);
+      }
     }
     if (numOps > 0) {
       m.inc(numOps, amt);



Mime
View raw message