Return-Path: X-Original-To: apmail-cassandra-commits-archive@www.apache.org Delivered-To: apmail-cassandra-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0093F10505 for ; Thu, 6 Feb 2014 21:07:56 +0000 (UTC) Received: (qmail 61825 invoked by uid 500); 6 Feb 2014 21:07:54 -0000 Delivered-To: apmail-cassandra-commits-archive@cassandra.apache.org Received: (qmail 61768 invoked by uid 500); 6 Feb 2014 21:07:53 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 61758 invoked by uid 99); 6 Feb 2014 21:07:53 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Feb 2014 21:07:53 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 32B108A3B81; Thu, 6 Feb 2014 21:07:53 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: brandonwilliams@apache.org To: commits@cassandra.apache.org Date: Thu, 06 Feb 2014 21:07:53 -0000 Message-Id: <08305fe678534fb28d6c51c06a5a6e46@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/3] git commit: Failure detector correctly converts initial value to nanos Patch by brandonwilliams reviewed by jbellis for CASSANDRA-6658 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 Authored: Thu Feb 6 15:05:29 2014 -0600 Committer: Brandon Williams 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; }