You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by gr...@apache.org on 2010/11/23 16:12:42 UTC

svn commit: r1038155 - /qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/stats/StatisticsCounter.java

Author: grkvlt
Date: Tue Nov 23 15:12:42 2010
New Revision: 1038155

URL: http://svn.apache.org/viewvc?rev=1038155&view=rev
Log:
QPID-2932: Move all AtomicLong operations to end of sample period.

Modified:
    qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/stats/StatisticsCounter.java

Modified: qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/stats/StatisticsCounter.java
URL: http://svn.apache.org/viewvc/qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/stats/StatisticsCounter.java?rev=1038155&r1=1038154&r2=1038155&view=diff
==============================================================================
--- qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/stats/StatisticsCounter.java (original)
+++ qpid/branches/0.5.x-dev/qpid/java/broker/src/main/java/org/apache/qpid/server/stats/StatisticsCounter.java Tue Nov 23 15:12:42 2010
@@ -32,7 +32,7 @@ public class StatisticsCounter
 {
     private static final Logger _log = LoggerFactory.getLogger(StatisticsCounter.class);
     
-    public static final long DEFAULT_SAMPLE_PERIOD = Long.getLong("qpid.statistics.samplePeriod", 1000L); // 1s
+    public static final long DEFAULT_SAMPLE_PERIOD = Long.getLong("qpid.statistics.samplePeriod", 2000L); // 2s
     public static final boolean DISABLE_STATISTICS = Boolean.getBoolean("qpid.statistics.disable");
     
     private static final String COUNTER = "counter";
@@ -89,18 +89,18 @@ public class StatisticsCounter
         {
             if (_last.compareAndSet(lastSample, thisSample))
             {
-                long rate = _temp.getAndSet(0L);
-                _rate.set(rate);
+                long current = _temp.getAndSet(0L);
+                _rate.set(current);
+                long peak;
+                while (current > (peak = _peak.get()))
+                {
+                    _peak.compareAndSet(peak, current);
+                }
             }
         }
         
         _total.addAndGet(value);
-        long current = _temp.addAndGet(value);
-        long peak;
-        while (current > (peak = _peak.get()))
-        {
-            _peak.compareAndSet(peak, current);
-        }
+        _temp.addAndGet(value);
     }
     
     /**
@@ -126,6 +126,7 @@ public class StatisticsCounter
 
     public double getPeak()
     {
+        update();
         return (double) _peak.get() / ((double) _period / 1000.0d);
     }
 



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org