cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject [2/2] git commit: Merge branch 'cassandra-1.2' into trunk
Date Thu, 24 Jan 2013 17:01:56 GMT
Updated Branches:
  refs/heads/trunk 47e789187 -> 152213469


Merge branch 'cassandra-1.2' into trunk

Conflicts:
	src/java/org/apache/cassandra/cql/CFPropDefs.java
	src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/15221346
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/15221346
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/15221346

Branch: refs/heads/trunk
Commit: 152213469cb9037d82e3e7f65d65e70b5e9bcd25
Parents: 47e7891 360d1a2
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Thu Jan 24 18:01:40 2013 +0100
Committer: Sylvain Lebresne <sylvain@datastax.com>
Committed: Thu Jan 24 18:01:40 2013 +0100

----------------------------------------------------------------------
 CHANGES.txt                                        |    2 +-
 NEWS.txt                                           |    2 +
 .../org/apache/cassandra/config/CFMetaData.java    |   35 ++++++++-
 src/java/org/apache/cassandra/cql/CFPropDefs.java  |    6 +-
 .../cassandra/cql/CreateColumnFamilyStatement.java |    3 +-
 src/java/org/apache/cassandra/cql3/CFPropDefs.java |    7 ++
 .../db/compaction/AbstractCompactionStrategy.java  |   67 +++++++++++++--
 .../db/compaction/LeveledCompactionStrategy.java   |   39 ++++++---
 .../compaction/SizeTieredCompactionStrategy.java   |   61 ++++++++++++--
 .../apache/cassandra/thrift/CassandraServer.java   |    3 +
 10 files changed, 192 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/15221346/CHANGES.txt
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/15221346/src/java/org/apache/cassandra/config/CFMetaData.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/config/CFMetaData.java
index d4cac2b,c829fa3..2c62139
--- a/src/java/org/apache/cassandra/config/CFMetaData.java
+++ b/src/java/org/apache/cassandra/config/CFMetaData.java
@@@ -17,9 -17,9 +17,10 @@@
   */
  package org.apache.cassandra.config;
  
 +import java.io.DataInput;
  import java.lang.reflect.Constructor;
  import java.lang.reflect.InvocationTargetException;
+ import java.lang.reflect.Method;
  import java.nio.ByteBuffer;
  import java.util.*;
  
@@@ -877,8 -829,44 +878,36 @@@ public final class CFMetaDat
  
          if (!cfm.comparator.isCompatibleWith(comparator))
              throw new ConfigurationException("comparators do not match or are not compatible.");
 -        if (cfm.subcolumnComparator == null)
 -        {
 -            if (subcolumnComparator != null)
 -                throw new ConfigurationException("subcolumncomparators do not match.");
 -            // else, it's null and we're good.
 -        }
 -        else if (!cfm.subcolumnComparator.isCompatibleWith(subcolumnComparator))
 -            throw new ConfigurationException("subcolumncomparators do not match or are note
compatible.");
      }
  
+     public static void validateCompactionOptions(Class<? extends AbstractCompactionStrategy>
strategyClass, Map<String, String> options) throws ConfigurationException
+     {
+         try
+         {
+             if (options == null)
+                 return;
+ 
+             Method validateMethod = strategyClass.getMethod("validateOptions", Map.class);
+             Map<String, String> unknownOptions = (Map<String, String>) validateMethod.invoke(null,
options);
+             if (!unknownOptions.isEmpty())
+                 throw new ConfigurationException(String.format("Properties specified %s
are not understood by %s", unknownOptions.keySet(), strategyClass.getSimpleName()));
+         }
+         catch (NoSuchMethodException e)
+         {
+             logger.warn("Compaction Strategy {} does not have a static validateOptions method.
Validation ignored", strategyClass.getName());
+         }
+         catch (InvocationTargetException e)
+         {
+             if (e.getTargetException() instanceof ConfigurationException)
+                 throw (ConfigurationException) e.getTargetException();
+             throw new ConfigurationException("Failed to validate compaction options");
+         }
+         catch (Exception e)
+         {
+             throw new ConfigurationException("Failed to validate compaction options");
+         }
+     }
+ 
      public static Class<? extends AbstractCompactionStrategy> createCompactionStrategy(String
className) throws ConfigurationException
      {
          className = className.contains(".") ? className : "org.apache.cassandra.db.compaction."
+ className;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/15221346/src/java/org/apache/cassandra/cql/CFPropDefs.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/cql/CFPropDefs.java
index 1918667,b488ecf..6bbb9ad
--- a/src/java/org/apache/cassandra/cql/CFPropDefs.java
+++ b/src/java/org/apache/cassandra/cql/CFPropDefs.java
@@@ -175,17 -171,8 +175,19 @@@ public class CFPropDefs 
                          KW_MINCOMPACTIONTHRESHOLD,
                          CFMetaData.DEFAULT_MIN_COMPACTION_THRESHOLD));
          }
-         
+ 
 +        Integer defaultTimeToLive = getPropertyInt(KW_DEFAULT_TIME_TO_LIVE, null);
 +
 +        if (defaultTimeToLive != null)
 +        {
 +            if (defaultTimeToLive < 0)
 +                throw new InvalidRequestException(String.format("%s cannot be smaller than
%s, (default %s)",
 +                        KW_DEFAULT_TIME_TO_LIVE,
 +                        0,
 +                        CFMetaData.DEFAULT_DEFAULT_TIME_TO_LIVE));
 +        }
++
+         CFMetaData.validateCompactionOptions(compactionStrategyClass, compactionStrategyOptions);
      }
  
      /** Map a keyword to the corresponding value */

http://git-wip-us.apache.org/repos/asf/cassandra/blob/15221346/src/java/org/apache/cassandra/cql/CreateColumnFamilyStatement.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/15221346/src/java/org/apache/cassandra/cql3/CFPropDefs.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/cql3/CFPropDefs.java
index cbe1561,c546cfc..5d0b249
--- a/src/java/org/apache/cassandra/cql3/CFPropDefs.java
+++ b/src/java/org/apache/cassandra/cql3/CFPropDefs.java
@@@ -89,20 -85,16 +89,27 @@@ public class CFPropDefs extends Propert
  
              compactionStrategyClass = CFMetaData.createCompactionStrategy(strategy);
              compactionOptions.remove(COMPACTION_STRATEGY_CLASS_KEY);
+ 
+             CFMetaData.validateCompactionOptions(compactionStrategyClass, compactionOptions);
          }
 +
 +        Integer defaultTimeToLive = getInt(KW_DEFAULT_TIME_TO_LIVE, null);
 +
 +        if (defaultTimeToLive != null)
 +        {
 +            if (defaultTimeToLive < 0)
 +                throw new ConfigurationException(String.format("%s cannot be smaller than
%s, (default %s)",
 +                        KW_DEFAULT_TIME_TO_LIVE,
 +                        0,
 +                        CFMetaData.DEFAULT_DEFAULT_TIME_TO_LIVE));
 +        }
      }
  
+     public Class<? extends AbstractCompactionStrategy> getCompactionStrategy()
+     {
+         return compactionStrategyClass;
+     }
+ 
      public Map<String, String> getCompactionOptions() throws SyntaxException
      {
          Map<String, String> compactionOptions = getMap(KW_COMPACTION);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/15221346/src/java/org/apache/cassandra/db/compaction/LeveledCompactionStrategy.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/15221346/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
index cb585d2,64ed744..74538c0
--- a/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
+++ b/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
@@@ -52,12 -54,7 +54,6 @@@ public class SizeTieredCompactionStrate
          bucketLow = optionValue == null ? DEFAULT_BUCKET_LOW : Double.parseDouble(optionValue);
          optionValue = options.get(BUCKET_HIGH_KEY);
          bucketHigh = optionValue == null ? DEFAULT_BUCKET_HIGH : Double.parseDouble(optionValue);
-         if (bucketHigh <= bucketLow)
-         {
-             logger.warn("Bucket low/high marks for {} incorrect, using defaults.", cfs.name);
-             bucketLow = DEFAULT_BUCKET_LOW;
-             bucketHigh = DEFAULT_BUCKET_HIGH;
-         }
 -
          cfs.setCompactionThresholds(cfs.metadata.getMinCompactionThreshold(), cfs.metadata.getMaxCompactionThreshold());
      }
  
@@@ -227,6 -224,59 +223,59 @@@
          return Long.MAX_VALUE;
      }
  
+     public static Map<String, String> validateOptions(Map<String, String> options)
throws ConfigurationException
+     {
+         Map<String, String> uncheckedOptions = AbstractCompactionStrategy.validateOptions(options);
+ 
+         String optionValue = options.get(MIN_SSTABLE_SIZE_KEY);
+         try
+         {
+             long minSSTableSize = optionValue == null ? DEFAULT_MIN_SSTABLE_SIZE : Long.parseLong(optionValue);
+             if (minSSTableSize < 0)
+             {
+                 throw new ConfigurationException(String.format("%s must be non negative:
%d", MIN_SSTABLE_SIZE_KEY, minSSTableSize));
+             }
+         }
+         catch (NumberFormatException e)
+         {
+             throw new ConfigurationException(String.format("%s is not a parsable int (base10)
for %s", optionValue, MIN_SSTABLE_SIZE_KEY), e);
+         }
+ 
+         double bucketLow, bucketHigh;
+         optionValue = options.get(BUCKET_LOW_KEY);
+         try
+         {
+             bucketLow = optionValue == null ? DEFAULT_BUCKET_LOW : Double.parseDouble(optionValue);
+         }
+         catch (NumberFormatException e)
+         {
+             throw new ConfigurationException(String.format("%s is not a parsable int (base10)
for %s", optionValue, DEFAULT_BUCKET_LOW), e);
+         }
+ 
+         optionValue = options.get(BUCKET_HIGH_KEY);
+         try
+         {
+             bucketHigh = optionValue == null ? DEFAULT_BUCKET_HIGH : Double.parseDouble(optionValue);
+         }
+         catch (NumberFormatException e)
+         {
+             throw new ConfigurationException(String.format("%s is not a parsable int (base10)
for %s", optionValue, DEFAULT_BUCKET_HIGH), e);
+         }
+ 
+         if (bucketHigh <= bucketLow)
+         {
 -            throw new ConfigurationException(String.format("BucketHigh value (%s) is less
than or equal BucketLow value (%s)", bucketHigh, bucketLow));
++            throw new ConfigurationException(String.format("Bucket high value (%s) is less
than or equal bucket low value (%s)", bucketHigh, bucketLow));
+         }
+ 
+         uncheckedOptions.remove(MIN_SSTABLE_SIZE_KEY);
+         uncheckedOptions.remove(BUCKET_LOW_KEY);
+         uncheckedOptions.remove(BUCKET_HIGH_KEY);
+         uncheckedOptions.remove(CFPropDefs.KW_MINCOMPACTIONTHRESHOLD);
+         uncheckedOptions.remove(CFPropDefs.KW_MAXCOMPACTIONTHRESHOLD);
+ 
+         return uncheckedOptions;
+     }
+ 
      public String toString()
      {
          return String.format("SizeTieredCompactionStrategy[%s/%s]",

http://git-wip-us.apache.org/repos/asf/cassandra/blob/15221346/src/java/org/apache/cassandra/thrift/CassandraServer.java
----------------------------------------------------------------------


Mime
View raw message