Author: jbellis Date: Tue May 25 14:12:27 2010 New Revision: 948052 URL: http://svn.apache.org/viewvc?rev=948052&view=rev Log: Expose setting of phi in the FailureDetector, for trunk. patch by Brandon Williams; reviewed by jbellis for CASSANDRA-1053
Modified: cassandra/trunk/conf/cassandra.yaml cassandra/trunk/src/java/org/apache/cassandra/config/Config.java cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java cassandra/trunk/src/java/org/apache/cassandra/gms/FailureDetector.java cassandra/trunk/src/java/org/apache/cassandra/gms/FailureDetectorMBean.java Modified: cassandra/trunk/conf/cassandra.yaml URL: http://svn.apache.org/viewvc/cassandra/trunk/conf/cassandra.yaml?rev=948052&r1=948051&r2=948052&view=diff ============================================================================== --- cassandra/trunk/conf/cassandra.yaml (original) +++ cassandra/trunk/conf/cassandra.yaml Tue May 25 14:12:27 2010 @@ -109,6 +109,10 @@ commitlog_sync_period_in_ms: 10000 # Time to wait for a reply from other nodes before failing the command rpc_timeout_in_ms: 10000 +# phi value that must be reached for a host to be marked down. +# most users should never need to adjust this. +# phi_convict_threshold: 8 + # time to wait before garbage collecting tombstones (deletion markers) gc_grace_seconds: 864000 Modified: cassandra/trunk/src/java/org/apache/cassandra/config/Config.java URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/config/Config.java?rev=948052&r1=948051&r2=948052&view=diff ============================================================================== --- cassandra/trunk/src/java/org/apache/cassandra/config/Config.java (original) +++ cassandra/trunk/src/java/org/apache/cassandra/config/Config.java Tue May 25 14:12:27 2010 @@ -28,6 +28,8 @@ public class Config { public String initial_token; public Long rpc_timeout_in_ms = new Long(2000); + + public Integer phi_convict_threshold = 8; public Integer concurrent_reads = 8; public Integer concurrent_writes = 32; Modified: cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java?rev=948052&r1=948051&r2=948052&view=diff ============================================================================== --- cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java (original) +++ cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java Tue May 25 14:12:27 2010 @@ -202,6 +202,12 @@ public class DatabaseDescriptor throw new ConfigurationException("Invalid partitioner class " + conf.partitioner); } + /* phi convict threshold for FailureDetector */ + if (conf.phi_convict_threshold < 5 || conf.phi_convict_threshold > 16) + { + throw new ConfigurationException("phi_convict_threshold must be between 5 and 16"); + } + /* Thread per pool */ if (conf.concurrent_reads != null && conf.concurrent_reads < 2) { @@ -745,6 +751,11 @@ public class DatabaseDescriptor return conf.rpc_timeout_in_ms; } + public static int getPhiConvictThreshold() + { + return conf.phi_convict_threshold; + } + public static int getConsistencyThreads() { return consistencyThreads; Modified: cassandra/trunk/src/java/org/apache/cassandra/gms/FailureDetector.java URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/gms/FailureDetector.java?rev=948052&r1=948051&r2=948052&view=diff ============================================================================== --- cassandra/trunk/src/java/org/apache/cassandra/gms/FailureDetector.java (original) +++ cassandra/trunk/src/java/org/apache/cassandra/gms/FailureDetector.java Tue May 25 14:12:27 2010 @@ -29,6 +29,7 @@ import javax.management.ObjectName; import org.apache.commons.lang.StringUtils; import java.net.InetAddress; +import org.apache.cassandra.config.DatabaseDescriptor; import org.apache.cassandra.utils.FBUtilities; import org.apache.cassandra.utils.BoundedStatsDeque; import org.slf4j.Logger; @@ -44,7 +45,7 @@ public class FailureDetector implements public static final IFailureDetector instance = new FailureDetector(); private static Logger logger_ = LoggerFactory.getLogger(FailureDetector.class); private static final int sampleSize_ = 1000; - private static final int phiConvictThreshold_ = 8; + private static int phiConvictThreshold_; /* The Failure Detector has to have been up for at least 1 min. */ private static final long uptimeThreshold_ = 60000; /* The time when the module was instantiated. */ @@ -55,6 +56,7 @@ public class FailureDetector implements public FailureDetector() { + phiConvictThreshold_ = DatabaseDescriptor.getPhiConvictThreshold(); creationTime_ = System.currentTimeMillis(); // Register this instance with JMX try @@ -109,6 +111,16 @@ public class FailureDetector implements throw new IOError(e); } } + + public void setPhiConvictThreshold(int phi) + { + phiConvictThreshold_ = phi; + } + + public int getPhiConvictThreshold() + { + return phiConvictThreshold_; + } public boolean isAlive(InetAddress ep) { Modified: cassandra/trunk/src/java/org/apache/cassandra/gms/FailureDetectorMBean.java URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/gms/FailureDetectorMBean.java?rev=948052&r1=948051&r2=948052&view=diff ============================================================================== --- cassandra/trunk/src/java/org/apache/cassandra/gms/FailureDetectorMBean.java (original) +++ cassandra/trunk/src/java/org/apache/cassandra/gms/FailureDetectorMBean.java Tue May 25 14:12:27 2010 @@ -21,4 +21,8 @@ package org.apache.cassandra.gms; public interface FailureDetectorMBean { public void dumpInterArrivalTimes(); + + public void setPhiConvictThreshold(int phi); + + public int getPhiConvictThreshold(); }