chukwa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asrab...@apache.org
Subject svn commit: r762141 - in /hadoop/chukwa/trunk: CHANGES.txt src/java/org/apache/hadoop/metrics/spi/AbstractMetricsContext.java
Date Sun, 05 Apr 2009 19:51:01 GMT
Author: asrabkin
Date: Sun Apr  5 19:51:01 2009
New Revision: 762141

URL: http://svn.apache.org/viewvc?rev=762141&view=rev
Log:
CHUKWA-92.  AbstractMetricsContext was using the wrong value (contributed by Jerome Boulon)

Modified:
    hadoop/chukwa/trunk/CHANGES.txt
    hadoop/chukwa/trunk/src/java/org/apache/hadoop/metrics/spi/AbstractMetricsContext.java

Modified: hadoop/chukwa/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/CHANGES.txt?rev=762141&r1=762140&r2=762141&view=diff
==============================================================================
--- hadoop/chukwa/trunk/CHANGES.txt (original)
+++ hadoop/chukwa/trunk/CHANGES.txt Sun Apr  5 19:51:01 2009
@@ -67,6 +67,8 @@
 
   BUG FIXES
 
+    CHUKWA-92.  AbstractMetricsContext was using the wrong value (Jerome Boulon via asrabkin)
+
     CHUKWA-70.  Rewrite FileAdaptor.  (Jerome Boulon via asrabkin)
 
     CHUKWA-93.  Fix NPE in SeqFileWriter.  (Jiaqi Tan via asrabkin)

Modified: hadoop/chukwa/trunk/src/java/org/apache/hadoop/metrics/spi/AbstractMetricsContext.java
URL: http://svn.apache.org/viewvc/hadoop/chukwa/trunk/src/java/org/apache/hadoop/metrics/spi/AbstractMetricsContext.java?rev=762141&r1=762140&r2=762141&view=diff
==============================================================================
--- hadoop/chukwa/trunk/src/java/org/apache/hadoop/metrics/spi/AbstractMetricsContext.java
(original)
+++ hadoop/chukwa/trunk/src/java/org/apache/hadoop/metrics/spi/AbstractMetricsContext.java
Sun Apr  5 19:51:01 2009
@@ -53,7 +53,7 @@
     
   private int period = MetricsContext.DEFAULT_PERIOD;
   private Timer timer = null;
-  private long lastRun = 0L;    
+  private boolean computeRate = true;    
   private Set<Updater> updaters = new HashSet<Updater>(1);
   private volatile boolean isMonitoring = false;
     
@@ -355,16 +355,12 @@
         else {
           Number newNumber = sum(updateNumber, currentNumber);
           metricMap.put(metricName, newNumber);
-          if (lastRun != 0) {
-            long duration = now -lastRun;
-            if (duration != 0) {
-              double rate = newNumber.doubleValue() * 60.0 / duration;
+          metricMap.put(metricName+"_raw", updateNumber);
+          if (computeRate ) {
+              double rate = updateNumber.doubleValue() * 60.0 / period;
               metricMap.put(metricName+"_rate", rate);
-            } else {
-              metricMap.put(metricName+"_rate", 0.0);
             }
-          }
-          lastRun = now;
+          computeRate = true;
         }
       }
     }



Mime
View raw message