cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject [4/5] git commit: getRecentLatency returns zero instead of infinity
Date Thu, 03 Apr 2014 23:35:11 GMT
getRecentLatency returns zero instead of infinity

Patch by Benedict, reviewed by brandonwilliams for CASSANDRA-6920


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/4b09b8de
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/4b09b8de
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/4b09b8de

Branch: refs/heads/cassandra-2.0
Commit: 4b09b8deb33bd87d0714797e2e862221bd8735ab
Parents: bc89517
Author: Brandon Williams <brandonwilliams@apache.org>
Authored: Thu Apr 3 18:30:43 2014 -0500
Committer: Brandon Williams <brandonwilliams@apache.org>
Committed: Thu Apr 3 18:30:43 2014 -0500

----------------------------------------------------------------------
 src/java/org/apache/cassandra/metrics/LatencyMetrics.java | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/4b09b8de/src/java/org/apache/cassandra/metrics/LatencyMetrics.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/metrics/LatencyMetrics.java b/src/java/org/apache/cassandra/metrics/LatencyMetrics.java
index b53449c..b456e2a 100644
--- a/src/java/org/apache/cassandra/metrics/LatencyMetrics.java
+++ b/src/java/org/apache/cassandra/metrics/LatencyMetrics.java
@@ -98,10 +98,12 @@ public class LatencyMetrics
     }
 
     @Deprecated
-    public double getRecentLatency()
+    public synchronized double getRecentLatency()
     {
         long ops = latency.count();
         long n = totalLatency.count();
+        if (ops == lastOpCount)
+            return 0;
         try
         {
             return ((double) n - lastLatency) / (ops - lastOpCount);


Mime
View raw message