Author: xedin Date: Fri Oct 14 21:35:54 2011 New Revision: 1183510 URL: http://svn.apache.org/viewvc?rev=1183510&view=rev Log: ColumnFamily min_compaction_threshold should be >= 2 patch by Pavel Yaskevich; reviewed by Brandon Williams for CASSANDRA-3342
Modified: cassandra/branches/cassandra-0.8/CHANGES.txt cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/thrift/ThriftValidation.java Modified: cassandra/branches/cassandra-0.8/CHANGES.txt URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/CHANGES.txt?rev=1183510&r1=1183509&r2=1183510&view=diff ============================================================================== --- cassandra/branches/cassandra-0.8/CHANGES.txt (original) +++ cassandra/branches/cassandra-0.8/CHANGES.txt Fri Oct 14 21:35:54 2011 @@ -14,7 +14,7 @@ (CASSANDRA-3214) * (Hadoop) accept comma delimited lists of initial thrift connections (CASSANDRA-3185) - + * ColumnFamily min_compaction_threshold should be >= 2 (CASSANDRA-3342) 0.8.7 * Kill server on wrapped OOME such as from FileChannel.map (CASSANDRA-3201) Modified: cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/thrift/ThriftValidation.java URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/thrift/ThriftValidation.java?rev=1183510&r1=1183509&r2=1183510&view=diff ============================================================================== --- cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/thrift/ThriftValidation.java (original) +++ cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/thrift/ThriftValidation.java Fri Oct 14 21:35:54 2011 @@ -679,19 +679,11 @@ public class ThriftValidation { if (cf_def.isSetMin_compaction_threshold() && cf_def.isSetMax_compaction_threshold()) { - if ((cf_def.min_compaction_threshold > cf_def.max_compaction_threshold) - && cf_def.max_compaction_threshold != 0) - { - throw new ConfigurationException("min_compaction_threshold cannot be greater than max_compaction_threshold"); - } + validateMinCompactionThreshold(cf_def.min_compaction_threshold, cf_def.max_compaction_threshold); } else if (cf_def.isSetMin_compaction_threshold()) { - if (cf_def.min_compaction_threshold > CFMetaData.DEFAULT_MAX_COMPACTION_THRESHOLD) - { - throw new ConfigurationException(String.format("min_compaction_threshold cannot be greather than max_compaction_threshold (default %d)", - CFMetaData.DEFAULT_MAX_COMPACTION_THRESHOLD)); - } + validateMinCompactionThreshold(cf_def.min_compaction_threshold, CFMetaData.DEFAULT_MAX_COMPACTION_THRESHOLD); } else if (cf_def.isSetMax_compaction_threshold()) { @@ -706,6 +698,16 @@ public class ThriftValidation } } + public static void validateMinCompactionThreshold(int min_compaction_threshold, int max_compaction_threshold) throws ConfigurationException + { + if (min_compaction_threshold <= 1) + throw new ConfigurationException("min_compaction_threshold cannot be less than 2."); + + if (min_compaction_threshold > max_compaction_threshold && max_compaction_threshold != 0) + throw new ConfigurationException(String.format("min_compaction_threshold cannot be greater than max_compaction_threshold %d", + max_compaction_threshold)); + } + public static void validateMemtableSettings(org.apache.cassandra.thrift.CfDef cf_def) throws ConfigurationException { if (cf_def.isSetMemtable_flush_after_mins())