cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject svn commit: r1101021 - in /cassandra/branches/cassandra-0.7: CHANGES.txt src/java/org/apache/cassandra/thrift/CassandraServer.java src/java/org/apache/cassandra/thrift/ThriftValidation.java
Date Mon, 09 May 2011 13:29:24 GMT
Author: slebresne
Date: Mon May  9 13:29:24 2011
New Revision: 1101021

URL: http://svn.apache.org/viewvc?rev=1101021&view=rev
Log:
Don't allow {LOCAL|EACH}_QUORUM unless strategy is NTS
patch by slebresne; reviewed by jbellis for CASSANDRA-2627

Modified:
    cassandra/branches/cassandra-0.7/CHANGES.txt
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/thrift/CassandraServer.java
    cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/thrift/ThriftValidation.java

Modified: cassandra/branches/cassandra-0.7/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/CHANGES.txt?rev=1101021&r1=1101020&r2=1101021&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.7/CHANGES.txt Mon May  9 13:29:24 2011
@@ -14,6 +14,7 @@
  * improve ignoring of obsolete mutations in index maintenance (CASSANDRA-2401)
  * recognize attempt to drop just the index while leaving the column
    definition alone (CASSANDRA-2619)
+ * Don't allow {LOCAL|EACH}_QUORUM unless strategy is NTS (CASSANDRA-2627)
 
 
 0.7.5

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/thrift/CassandraServer.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/thrift/CassandraServer.java?rev=1101021&r1=1101020&r2=1101021&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/thrift/CassandraServer.java
(original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/thrift/CassandraServer.java
Mon May  9 13:29:24 2011
@@ -250,6 +250,7 @@ public class CassandraServer implements 
     {
         ThriftValidation.validateColumnParent(keyspace, column_parent);
         ThriftValidation.validatePredicate(keyspace, column_parent, predicate);
+        ThriftValidation.validateConsistencyLevel(keyspace, consistency_level);
 
         List<ReadCommand> commands = new ArrayList<ReadCommand>();
         if (predicate.column_names != null)
@@ -282,6 +283,7 @@ public class CassandraServer implements 
         String keyspace = state().getKeyspace();
 
         ThriftValidation.validateColumnPath(keyspace, column_path);
+        ThriftValidation.validateConsistencyLevel(keyspace, consistency_level);
 
         QueryPath path = new QueryPath(column_path.column_family, column_path.column == null
? null : column_path.super_column);
         List<ByteBuffer> nameAsList = Arrays.asList(column_path.column == null ? column_path.super_column
: column_path.column);
@@ -410,8 +412,9 @@ public class CassandraServer implements 
         doInsert(consistency_level, Arrays.asList(rm));
     }
 
-    private void doInsert(ConsistencyLevel consistency_level, List<RowMutation> mutations)
throws UnavailableException, TimedOutException
+    private void doInsert(ConsistencyLevel consistency_level, List<RowMutation> mutations)
throws UnavailableException, TimedOutException, InvalidRequestException
     {
+        ThriftValidation.validateConsistencyLevel(state().getKeyspace(), consistency_level);
         try
         {
             schedule();
@@ -459,6 +462,7 @@ public class CassandraServer implements 
         ThriftValidation.validateColumnParent(keyspace, column_parent);
         ThriftValidation.validatePredicate(keyspace, column_parent, predicate);
         ThriftValidation.validateKeyRange(range);
+        ThriftValidation.validateConsistencyLevel(keyspace, consistency_level);
 
         List<Row> rows;
         try
@@ -522,6 +526,7 @@ public class CassandraServer implements 
         ThriftValidation.validateColumnParent(keyspace, column_parent);
         ThriftValidation.validatePredicate(keyspace, column_parent, column_predicate);
         ThriftValidation.validateIndexClauses(keyspace, column_parent.column_family, index_clause);
+        ThriftValidation.validateConsistencyLevel(keyspace, consistency_level);
 
         List<Row> rows;
         try

Modified: cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/thrift/ThriftValidation.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/thrift/ThriftValidation.java?rev=1101021&r1=1101020&r2=1101021&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/thrift/ThriftValidation.java
(original)
+++ cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/thrift/ThriftValidation.java
Mon May  9 13:29:24 2011
@@ -36,6 +36,8 @@ import org.apache.cassandra.db.marshal.M
 import org.apache.cassandra.dht.IPartitioner;
 import org.apache.cassandra.dht.RandomPartitioner;
 import org.apache.cassandra.dht.Token;
+import org.apache.cassandra.locator.AbstractReplicationStrategy;
+import org.apache.cassandra.locator.NetworkTopologyStrategy;
 import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.FBUtilities;
@@ -74,6 +76,19 @@ public class ThriftValidation
         }
     }
 
+    // Don't check that the table exists, validateTable or validateColumnFamily must be called
beforehand.
+    public static void validateConsistencyLevel(String table, ConsistencyLevel cl) throws
InvalidRequestException
+    {
+        switch (cl)
+        {
+            case LOCAL_QUORUM:
+            case EACH_QUORUM:
+                AbstractReplicationStrategy strategy = Table.open(table).getReplicationStrategy();
+                if (!(strategy instanceof NetworkTopologyStrategy))
+                    throw new InvalidRequestException("consistency level " + cl + " not compatible
with replication strategy (" + strategy.getClass().getName() + ")");
+        }
+    }
+
     public static ColumnFamilyType validateColumnFamily(String tablename, String cfName)
throws InvalidRequestException
     {
         if (cfName.isEmpty())



Mime
View raw message