Author: jbellis
Date: Tue May 24 13:34:46 2011
New Revision: 1127037

URL: http://svn.apache.org/viewvc?rev=1127037&view=rev
Log:
avoid instantiating DatabaseDescriptor in JDBC
patch by Aaron Morton; reviewed by jbellis for CASSANDRA-2694

Modified:
    cassandra/branches/cassandra-0.8.0/CHANGES.txt
    
cassandra/branches/cassandra-0.8.0/src/java/org/apache/cassandra/config/CFMetaData.java
    
cassandra/branches/cassandra-0.8.0/src/java/org/apache/cassandra/thrift/ThriftValidation.java

Modified: cassandra/branches/cassandra-0.8.0/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8.0/CHANGES.txt?rev=1127037&r1=1127036&r2=1127037&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8.0/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.8.0/CHANGES.txt Tue May 24 13:34:46 2011
@@ -9,6 +9,7 @@
  * only provide replication_factor to strategy_options "help" for
    SimpleStrategy, OldNetworkTopologyStrategy (CASSANDRA-2678)
  * fix exception adding validators to non-string columns (CASSANDRA-2696)
+ * avoid instantiating DatabaseDescriptor in JDBC (CASSANDRA-2694)
 
 
 0.8.0-rc1

Modified: 
cassandra/branches/cassandra-0.8.0/src/java/org/apache/cassandra/config/CFMetaData.java
URL: 
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8.0/src/java/org/apache/cassandra/config/CFMetaData.java?rev=1127037&r1=1127036&r2=1127037&view=diff
==============================================================================
--- 
cassandra/branches/cassandra-0.8.0/src/java/org/apache/cassandra/config/CFMetaData.java
 (original)
+++ 
cassandra/branches/cassandra-0.8.0/src/java/org/apache/cassandra/config/CFMetaData.java
 Tue May 24 13:34:46 2011
@@ -639,9 +639,6 @@ public final class CFMetaData
 
         applyImplicitDefaults(cf_def);
 
-        validateMinMaxCompactionThresholds(cf_def);
-        validateMemtableSettings(cf_def);
-
         CFMetaData newCFMD = new CFMetaData(cf_def.keyspace,
                                             cf_def.name,
                                             cfType,
@@ -889,36 +886,6 @@ public final class CFMetaData
         return newDef;
     }
 
-    public static void 
validateMinMaxCompactionThresholds(org.apache.cassandra.thrift.CfDef cf_def) 
throws ConfigurationException
-    {
-        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");
-            }
-        }
-        else if (cf_def.isSetMin_compaction_threshold())
-        {
-            if (cf_def.min_compaction_threshold > 
DEFAULT_MAX_COMPACTION_THRESHOLD)
-            {
-                throw new ConfigurationException("min_compaction_threshold 
cannot be greather than max_compaction_threshold (default " +
-                                                  
DEFAULT_MAX_COMPACTION_THRESHOLD + ")");
-            }
-        }
-        else if (cf_def.isSetMax_compaction_threshold())
-        {
-            if (cf_def.max_compaction_threshold < 
DEFAULT_MIN_COMPACTION_THRESHOLD && cf_def.max_compaction_threshold != 0) {
-                throw new ConfigurationException("max_compaction_threshold 
cannot be less than min_compaction_threshold");
-            }
-        }
-        else
-        {
-            //Defaults are valid.
-        }
-    }
-
     public static void 
validateMinMaxCompactionThresholds(org.apache.cassandra.db.migration.avro.CfDef 
cf_def) throws ConfigurationException
     {
         if (cf_def.min_compaction_threshold != null && 
cf_def.max_compaction_threshold != null)
@@ -949,16 +916,6 @@ public final class CFMetaData
         }
     }
 
-    public static void 
validateMemtableSettings(org.apache.cassandra.thrift.CfDef cf_def) throws 
ConfigurationException
-    {
-        if (cf_def.isSetMemtable_flush_after_mins())
-            
DatabaseDescriptor.validateMemtableFlushPeriod(cf_def.memtable_flush_after_mins);
-        if (cf_def.isSetMemtable_throughput_in_mb())
-            
DatabaseDescriptor.validateMemtableThroughput(cf_def.memtable_throughput_in_mb);
-        if (cf_def.isSetMemtable_operations_in_millions())
-            
DatabaseDescriptor.validateMemtableOperations(cf_def.memtable_operations_in_millions);
-    }
-
     public static void 
validateMemtableSettings(org.apache.cassandra.db.migration.avro.CfDef cf_def) 
throws ConfigurationException
     {
         if (cf_def.memtable_flush_after_mins != null)

Modified: 
cassandra/branches/cassandra-0.8.0/src/java/org/apache/cassandra/thrift/ThriftValidation.java
URL: 
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8.0/src/java/org/apache/cassandra/thrift/ThriftValidation.java?rev=1127037&r1=1127036&r2=1127037&view=diff
==============================================================================
--- 
cassandra/branches/cassandra-0.8.0/src/java/org/apache/cassandra/thrift/ThriftValidation.java
 (original)
+++ 
cassandra/branches/cassandra-0.8.0/src/java/org/apache/cassandra/thrift/ThriftValidation.java
 Tue May 24 13:34:46 2011
@@ -576,6 +576,8 @@ public class ThriftValidation
                 if (cfType == ColumnFamilyType.Super && c.index_type != null)
                     throw new InvalidRequestException("Secondary indexes are 
not supported on supercolumns");
             }
+            validateMinMaxCompactionThresholds(cf_def);
+            validateMemtableSettings(cf_def);
         }
         catch (ConfigurationException e)
         {
@@ -601,4 +603,45 @@ public class ThriftValidation
         Class<? extends AbstractReplicationStrategy> cls = 
AbstractReplicationStrategy.getClass(ks_def.strategy_class);
         AbstractReplicationStrategy.createReplicationStrategy(ks_def.name, 
cls, tmd, eps, options);
     }
+
+    public static void 
validateMinMaxCompactionThresholds(org.apache.cassandra.thrift.CfDef cf_def) 
throws ConfigurationException
+    {
+        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");
+            }
+        }
+        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));
+            }
+        }
+        else if (cf_def.isSetMax_compaction_threshold())
+        {
+            if (cf_def.max_compaction_threshold < 
CFMetaData.DEFAULT_MIN_COMPACTION_THRESHOLD && cf_def.max_compaction_threshold 
!= 0)
+            {
+                throw new ConfigurationException("max_compaction_threshold 
cannot be less than min_compaction_threshold");
+            }
+        }
+        else
+        {
+            //Defaults are valid.
+        }
+    }
+
+    public static void 
validateMemtableSettings(org.apache.cassandra.thrift.CfDef cf_def) throws 
ConfigurationException
+    {
+        if (cf_def.isSetMemtable_flush_after_mins())
+            
DatabaseDescriptor.validateMemtableFlushPeriod(cf_def.memtable_flush_after_mins);
+        if (cf_def.isSetMemtable_throughput_in_mb())
+            
DatabaseDescriptor.validateMemtableThroughput(cf_def.memtable_throughput_in_mb);
+        if (cf_def.isSetMemtable_operations_in_millions())
+            
DatabaseDescriptor.validateMemtableOperations(cf_def.memtable_operations_in_millions);
+    }
 }


Reply via email to