cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject [1/3] git commit: Failure detector correctly converts initial value to nanos Patch by brandonwilliams reviewed by jbellis for CASSANDRA-6658
Date Thu, 06 Feb 2014 21:07:53 GMT
Updated Branches:
  refs/heads/cassandra-2.0 5f64af63a -> ce9c8c2cd
  refs/heads/trunk d5c5734c8 -> ff2a92c13


Failure detector correctly converts initial value to nanos
Patch by brandonwilliams reviewed by jbellis for CASSANDRA-6658


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

Branch: refs/heads/cassandra-2.0
Commit: ce9c8c2cde6e336e8bb8aa74b5d2c9241a0e606e
Parents: 5f64af6
Author: Brandon Williams <brandonwilliams@apache.org>
Authored: Thu Feb 6 15:05:29 2014 -0600
Committer: Brandon Williams <brandonwilliams@apache.org>
Committed: Thu Feb 6 15:05:29 2014 -0600

----------------------------------------------------------------------
 CHANGES.txt                                        |  1 +
 .../org/apache/cassandra/gms/FailureDetector.java  | 17 ++++++++---------
 2 files changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/ce9c8c2c/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 6e3c2c2..85c6533 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.0.6
+ * Failure detector correctly converts initial value to nanos (CASSANDRA-6658)
  * Add nodetool taketoken to relocate vnodes (CASSANDRA-4445)
  * Fix upgradesstables NPE for non-CF-based indexes (CASSANDRA-6645)
  * Improve nodetool cfhistograms formatting (CASSANDRA-6360)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ce9c8c2c/src/java/org/apache/cassandra/gms/FailureDetector.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/gms/FailureDetector.java b/src/java/org/apache/cassandra/gms/FailureDetector.java
index a7eb82f..36776bc 100644
--- a/src/java/org/apache/cassandra/gms/FailureDetector.java
+++ b/src/java/org/apache/cassandra/gms/FailureDetector.java
@@ -23,6 +23,7 @@ import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.*;
 import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.TimeUnit;
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 
@@ -45,7 +46,7 @@ public class FailureDetector implements IFailureDetector, FailureDetectorMBean
 {
     public static final String MBEAN_NAME = "org.apache.cassandra.net:type=FailureDetector";
     private static final int SAMPLE_SIZE = 1000;
-    protected static final int INITIAL_VALUE = getInitialValue();
+    protected static final long INITIAL_VALUE_NANOS = TimeUnit.NANOSECONDS.convert(getInitialValue(),
TimeUnit.MILLISECONDS);
 
     public static final IFailureDetector instance = new FailureDetector();
     private static final Logger logger = LoggerFactory.getLogger(FailureDetector.class);
@@ -73,7 +74,7 @@ public class FailureDetector implements IFailureDetector, FailureDetectorMBean
         }
     }
 
-    private static int getInitialValue()
+    private static long getInitialValue()
     {
         String newvalue = System.getProperty("cassandra.fd_initial_value_ms");
         if (newvalue != null)
@@ -296,29 +297,27 @@ class ArrivalWindow
     // change.
     private final double PHI_FACTOR = 1.0 / Math.log(10.0);
 
-    private static final long MILLI_TO_NANO = 1000000L;
-
     // in the event of a long partition, never record an interval longer than the rpc timeout,
     // since if a host is regularly experiencing connectivity problems lasting this long
we'd
     // rather mark it down quickly instead of adapting
     // this value defaults to the same initial value the FD is seeded with
-    private final long MAX_INTERVAL_IN_NANO = getMaxInterval() * MILLI_TO_NANO;
+    private final long MAX_INTERVAL_IN_NANO = getMaxInterval();
 
     ArrivalWindow(int size)
     {
         arrivalIntervals = new BoundedStatsDeque(size);
     }
 
-    private static int getMaxInterval()
+    private static long getMaxInterval()
     {
         String newvalue = System.getProperty("cassandra.fd_max_interval_ms");
         if (newvalue != null)
         {
             logger.info("Overriding FD MAX_INTERVAL to {}ms", newvalue);
-            return Integer.parseInt(newvalue);
+            return TimeUnit.NANOSECONDS.convert(Integer.parseInt(newvalue), TimeUnit.MILLISECONDS);
         }
         else
-            return FailureDetector.INITIAL_VALUE;
+            return FailureDetector.INITIAL_VALUE_NANOS;
     }
 
     synchronized void add(long value)
@@ -337,7 +336,7 @@ class ArrivalWindow
             // We use a very large initial interval since the "right" average depends on
the cluster size
             // and it's better to err high (false negatives, which will be corrected by waiting
a bit longer)
             // than low (false positives, which cause "flapping").
-            arrivalIntervals.add(FailureDetector.INITIAL_VALUE);
+            arrivalIntervals.add(FailureDetector.INITIAL_VALUE_NANOS);
         }
         tLast = value;
     }


Mime
View raw message