cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From slebre...@apache.org
Subject svn commit: r1155548 - in /cassandra/branches/cassandra-0.8: CHANGES.txt src/java/org/apache/cassandra/cql/UpdateStatement.java src/java/org/apache/cassandra/thrift/ThriftValidation.java test/system/test_cql.py test/system/test_thrift_server.py
Date Tue, 09 Aug 2011 20:24:17 GMT
Author: slebresne
Date: Tue Aug  9 20:24:17 2011
New Revision: 1155548

URL: http://svn.apache.org/viewvc?rev=1155548&view=rev
Log:
Refuse counter write at CL.ANY
patch by slebresne; reviewed by jbellis for CASSANDRA-2990

Modified:
    cassandra/branches/cassandra-0.8/CHANGES.txt
    cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/cql/UpdateStatement.java
    cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/thrift/ThriftValidation.java
    cassandra/branches/cassandra-0.8/test/system/test_cql.py
    cassandra/branches/cassandra-0.8/test/system/test_thrift_server.py

Modified: cassandra/branches/cassandra-0.8/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/CHANGES.txt?rev=1155548&r1=1155547&r2=1155548&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.8/CHANGES.txt Tue Aug  9 20:24:17 2011
@@ -2,6 +2,7 @@
  * include files-to-be-streamed in StreamInSession.getSources (CASSANDRA-2972)
  * use JAVA env var in cassandra-env.sh (CASSANDRA-2785, 2992)
  * avoid doing read for no-op replicate-on-write at CL=1 (CASSANDRA-2892)
+ * refuse counter write for CL.ANY (CASSANDRA-2990)
 
 
 0.8.3

Modified: cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/cql/UpdateStatement.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/cql/UpdateStatement.java?rev=1155548&r1=1155547&r2=1155548&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/cql/UpdateStatement.java
(original)
+++ cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/cql/UpdateStatement.java
Tue Aug  9 20:24:17 2011
@@ -39,6 +39,7 @@ import static org.apache.cassandra.cql.Q
 
 import static org.apache.cassandra.cql.Operation.OperationType;
 import static org.apache.cassandra.thrift.ThriftValidation.validateColumnFamily;
+import static org.apache.cassandra.thrift.ThriftValidation.validateCommutativeForWrite;
 
 /**
  * An <code>UPDATE</code> statement parsed from a CQL query statement.
@@ -142,6 +143,8 @@ public class UpdateStatement extends Abs
         }
 
         CFMetaData metadata = validateColumnFamily(keyspace, columnFamily, hasCommutativeOperation);
+        if (hasCommutativeOperation)
+            validateCommutativeForWrite(metadata, cLevel);
 
         QueryProcessor.validateKeyAlias(metadata, keyName);
 

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=1155548&r1=1155547&r2=1155548&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
Tue Aug  9 20:24:17 2011
@@ -627,7 +627,11 @@ public class ThriftValidation
 
     public static void validateCommutativeForWrite(CFMetaData metadata, ConsistencyLevel
consistency) throws InvalidRequestException
     {
-        if (!metadata.getReplicateOnWrite() && consistency != ConsistencyLevel.ONE)
+        if (consistency == ConsistencyLevel.ANY)
+        {
+            throw new InvalidRequestException("Consistency level ANY is not yet supported
for counter columnfamily " + metadata.cfName);
+        }
+        else if (!metadata.getReplicateOnWrite() && consistency != ConsistencyLevel.ONE)
         {
             throw new InvalidRequestException("cannot achieve CL > CL.ONE without replicate_on_write
on columnfamily " + metadata.cfName);
         }

Modified: cassandra/branches/cassandra-0.8/test/system/test_cql.py
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/test/system/test_cql.py?rev=1155548&r1=1155547&r2=1155548&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/test/system/test_cql.py (original)
+++ cassandra/branches/cassandra-0.8/test/system/test_cql.py Tue Aug  9 20:24:17 2011
@@ -1260,6 +1260,11 @@ class TestCql(ThriftTester):
                       cursor.execute,
                       "UPDATE CounterCF SET count_me = count_not_me + 2 WHERE key = 'counter1'")
 
+        # counters can't do ANY
+        assert_raises(cql.ProgrammingError,
+                      cursor.execute,
+                      "UPDATE CounterCF USING CONSISTENCY ANY SET count_me = count_me + 2
WHERE key = 'counter1'")
+
     def test_key_alias_support(self):
         "should be possible to use alias instead of KEY keyword"
         cursor = init()

Modified: cassandra/branches/cassandra-0.8/test/system/test_thrift_server.py
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/test/system/test_thrift_server.py?rev=1155548&r1=1155547&r2=1155548&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/test/system/test_thrift_server.py (original)
+++ cassandra/branches/cassandra-0.8/test/system/test_thrift_server.py Tue Aug  9 20:24:17
2011
@@ -728,6 +728,8 @@ class TestMutations(ThriftTester):
         mutation = Mutation(deletion=deletion)
         mutations = {'key' : {'Super5' : [mutation]}}
         _expect_exception(lambda: client.batch_mutate(mutations, ConsistencyLevel.QUORUM),
InvalidRequestException)
+        # counters don't support ANY
+        _expect_exception(lambda: client.add('key1', ColumnParent('Counter1', 'x'), CounterColumn('y',
1), ConsistencyLevel.ANY), InvalidRequestException)
 
     def test_batch_insert_super(self):
          _set_keyspace('Keyspace1')



Mime
View raw message