Add properties to adjust FD initial value and max interval Patch by brandonwilliams, reviewed by jbellis for CASSANDRA-4375
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/c0c31ed0 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/c0c31ed0 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/c0c31ed0 Branch: refs/heads/trunk Commit: c0c31ed0f654da1a73aeae4e51440332495fdbec Parents: 3575fdc Author: Brandon Williams <[email protected]> Authored: Wed Jan 22 13:36:44 2014 -0600 Committer: Brandon Williams <[email protected]> Committed: Wed Jan 22 13:37:50 2014 -0600 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../apache/cassandra/gms/FailureDetector.java | 30 ++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/c0c31ed0/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index 639e17c..524ffb7 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -14,6 +14,7 @@ * Paginate batchlog replay (CASSANDRA-6569) * skip blocking on streaming during drain (CASSANDRA-6603) * Improve error message when schema doesn't match loaded sstable (CASSANDRA-6262) + * Add properties to adjust FD initial value and max interval (CASSANDRA-4375) 1.2.13 http://git-wip-us.apache.org/repos/asf/cassandra/blob/c0c31ed0/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 ee47997..7a35c34 100644 --- a/src/java/org/apache/cassandra/gms/FailureDetector.java +++ b/src/java/org/apache/cassandra/gms/FailureDetector.java @@ -45,6 +45,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(); public static final IFailureDetector instance = new FailureDetector(); private static final Logger logger = LoggerFactory.getLogger(FailureDetector.class); @@ -72,6 +73,18 @@ public class FailureDetector implements IFailureDetector, FailureDetectorMBean } } + private static int getInitialValue() + { + String newvalue = System.getProperty("cassandra.fd_initial_value_ms"); + if (newvalue != null) + { + logger.info("Overriding FD INITIAL_VALUE to {}ms", newvalue); + return Integer.parseInt(newvalue); + } + else + return Gossiper.intervalInMillis * 30; + } + public String getAllEndpointStates() { StringBuilder sb = new StringBuilder(); @@ -280,13 +293,26 @@ class ArrivalWindow // 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 - private final double MAX_INTERVAL_IN_MS = DatabaseDescriptor.getRpcTimeout(); + // this value defaults to the same initial value the FD is seeded with + private final int MAX_INTERVAL_IN_MS = getMaxInterval(); ArrivalWindow(int size) { arrivalIntervals = new BoundedStatsDeque(size); } + private static int 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); + } + else + return FailureDetector.INITIAL_VALUE; + } + synchronized void add(double value) { if (tLast > 0L) @@ -302,7 +328,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(Gossiper.intervalInMillis * 30); + arrivalIntervals.add(FailureDetector.INITIAL_VALUE); } tLast = value; }
