cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vi...@apache.org
Subject git commit: Convert speculative retry from milli second to micro second. patch by Vijay; reviewed by slebresne for CASSANDRA-5014
Date Fri, 28 Jun 2013 04:21:19 GMT
Updated Branches:
  refs/heads/trunk c1f10f823 -> c432e6733


Convert speculative retry from milli second to micro second.
patch by Vijay; reviewed by slebresne for CASSANDRA-5014

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

Branch: refs/heads/trunk
Commit: c432e673377d0b4b8f265fdb2e90fa7c77745260
Parents: c1f10f8
Author: Vijay Parthasarathy <vijay2win@gmail.com>
Authored: Thu Jun 27 21:08:38 2013 -0700
Committer: Vijay Parthasarathy <vijay2win@gmail.com>
Committed: Thu Jun 27 21:08:38 2013 -0700

----------------------------------------------------------------------
 src/java/org/apache/cassandra/config/CFMetaData.java    | 12 ++++++------
 src/java/org/apache/cassandra/db/ColumnFamilyStore.java |  9 +++++----
 .../apache/cassandra/service/AbstractReadExecutor.java  |  4 ++--
 3 files changed, 13 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/c432e673/src/java/org/apache/cassandra/config/CFMetaData.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/CFMetaData.java b/src/java/org/apache/cassandra/config/CFMetaData.java
index 38692b8..cf1c179 100644
--- a/src/java/org/apache/cassandra/config/CFMetaData.java
+++ b/src/java/org/apache/cassandra/config/CFMetaData.java
@@ -285,9 +285,9 @@ public final class CFMetaData
         }
 
         public final RetryType type;
-        public final long value;
+        public final double value;
 
-        private SpeculativeRetry(RetryType type, long value)
+        private SpeculativeRetry(RetryType type, double value)
         {
             this.type = type;
             this.value = value;
@@ -300,14 +300,14 @@ public final class CFMetaData
             {
                 if (name.endsWith(RetryType.PERCENTILE.toString()))
                 {
-                    long value = Long.parseLong(name.substring(0, name.length() - 10));
+                    double value = Double.parseDouble(name.substring(0, name.length() - 10));
                     if (value > 100 || value < 0)
                         throw new ConfigurationException("PERCENTILE should be between 0
and 100");
-                    return new SpeculativeRetry(RetryType.PERCENTILE, value);
+                    return new SpeculativeRetry(RetryType.PERCENTILE, (value / 100));
                 }
                 else if (name.endsWith("MS"))
                 {
-                    long value = Long.parseLong(name.substring(0, name.length() - 2));
+                    double value = Double.parseDouble(name.substring(0, name.length() - 2));
                     return new SpeculativeRetry(RetryType.CUSTOM, value);
                 }
                 else
@@ -339,7 +339,7 @@ public final class CFMetaData
             case PERCENTILE:
                 return value + "PERCENTILE";
             case CUSTOM:
-                return value + "MS";
+                return value + "ms";
             default:
                 return type.toString();
             }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c432e673/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
index 0a40457..643f405 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -303,12 +303,13 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
                 switch (retryPolicy.type)
                 {
                     case PERCENTILE:
-                        double percentile = retryPolicy.value / 100d;
-                        // get percentile and convert it to MS insted of dealing with micro
-                        sampleLatency = (long) (metric.readLatency.latency.getSnapshot().getValue(percentile)
/ 1000);
+                        // get percentile in nanos
+                        assert metric.readLatency.latency.durationUnit() == TimeUnit.MICROSECONDS;
+                        sampleLatency = (long) (metric.readLatency.latency.getSnapshot().getValue(retryPolicy.value)
* 1000d);
                         break;
                     case CUSTOM:
-                        sampleLatency = retryPolicy.value;
+                        // convert to nanos, since configuration is in millisecond
+                        sampleLatency = (long) (retryPolicy.value * 1000d * 1000d);
                         break;
                     default:
                         sampleLatency = Long.MAX_VALUE;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c432e673/src/java/org/apache/cassandra/service/AbstractReadExecutor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/AbstractReadExecutor.java b/src/java/org/apache/cassandra/service/AbstractReadExecutor.java
index 051085b..2ebc0b3 100644
--- a/src/java/org/apache/cassandra/service/AbstractReadExecutor.java
+++ b/src/java/org/apache/cassandra/service/AbstractReadExecutor.java
@@ -177,10 +177,10 @@ public abstract class AbstractReadExecutor
         void speculate()
         {
             // no latency information, or we're overloaded
-            if (cfs.sampleLatency > command.getTimeout())
+            if (cfs.sampleLatency > TimeUnit.MILLISECONDS.toNanos(command.getTimeout()))
                 return;
 
-            if (!handler.await(cfs.sampleLatency, TimeUnit.MILLISECONDS))
+            if (!handler.await(cfs.sampleLatency, TimeUnit.NANOSECONDS))
             {
                 InetAddress endpoint = unfiltered.get(handler.endpoints.size());
 


Mime
View raw message