Add properties to adjust FD initial value and max interval

Patch by brandonwilliams, reviewed by jbellis for CASSANDRA-4375
This commit is contained in:
Brandon Williams 2014-01-22 13:36:44 -06:00
parent 3575fdccb7
commit c0c31ed0f6
2 changed files with 29 additions and 2 deletions

View File

@ -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

View File

@ -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;
}