cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject git commit: Fix native protocol CAS batches
Date Mon, 09 Jun 2014 21:30:18 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.0 0c3424e21 -> aa9894df4


Fix native protocol CAS batches

patch by Sylvain Lebresne; reviewed by Aleksey Yeschenko for
CASSANDRA-7337


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

Branch: refs/heads/cassandra-2.0
Commit: aa9894df439eefd6af2732c9a49875c20a3d4902
Parents: 0c3424e
Author: Sylvain Lebresne <sylvain@datastax.com>
Authored: Tue Jun 10 00:27:42 2014 +0300
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Tue Jun 10 00:27:42 2014 +0300

----------------------------------------------------------------------
 CHANGES.txt                                                   | 1 +
 src/java/org/apache/cassandra/cql3/QueryProcessor.java        | 3 +--
 .../org/apache/cassandra/cql3/statements/BatchStatement.java  | 7 +------
 .../org/apache/cassandra/transport/messages/BatchMessage.java | 4 +++-
 4 files changed, 6 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/aa9894df/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index ac95e3f..97ac75e 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.0.9
+ * Fix native protocol CAS batches (CASSANDRA-7337)
  * Add per-CF range read request latency metrics (CASSANDRA-7338)
  * Fix NPE in StreamTransferTask.createMessageForRetry() (CASSANDRA-7323)
  * Add conditional CREATE/DROP USER support (CASSANDRA-7264)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/aa9894df/src/java/org/apache/cassandra/cql3/QueryProcessor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/QueryProcessor.java b/src/java/org/apache/cassandra/cql3/QueryProcessor.java
index 3d9c5a8..a59fe9b 100644
--- a/src/java/org/apache/cassandra/cql3/QueryProcessor.java
+++ b/src/java/org/apache/cassandra/cql3/QueryProcessor.java
@@ -316,8 +316,7 @@ public class QueryProcessor implements QueryHandler
         batch.checkAccess(clientState);
         batch.validate(clientState);
 
-        batch.executeWithPerStatementVariables(options.getConsistency(), queryState, options.getValues());
-        return new ResultMessage.Void();
+        return batch.executeWithPerStatementVariables(options.getConsistency(), queryState,
options.getValues());
     }
 
     public static ParsedStatement.Prepared getStatement(String queryStr, ClientState clientState)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/aa9894df/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java b/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java
index 875e41c..8fc1ecc 100644
--- a/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java
+++ b/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java
@@ -64,11 +64,6 @@ public class BatchStatement implements CQLStatement, MeasurableForPreparedCache
      * @param statements a list of UpdateStatements
      * @param attrs additional attributes for statement (CL, timestamp, timeToLive)
      */
-    public BatchStatement(int boundTerms, Type type, List<ModificationStatement> statements,
Attributes attrs)
-    {
-        this(boundTerms, type, statements, attrs, false);
-    }
-
     public BatchStatement(int boundTerms, Type type, List<ModificationStatement> statements,
Attributes attrs, boolean hasConditions)
     {
         this.boundTerms = boundTerms;
@@ -254,7 +249,7 @@ public class BatchStatement implements CQLStatement, MeasurableForPreparedCache
             return executeWithConditions(variables, cl, serialCl, now);
 
         executeWithoutConditions(getMutations(variables, local, cl, now), cl);
-        return null;
+        return new ResultMessage.Void();
     }
 
     private void executeWithoutConditions(Collection<? extends IMutation> mutations,
ConsistencyLevel cl) throws RequestExecutionException, RequestValidationException

http://git-wip-us.apache.org/repos/asf/cassandra/blob/aa9894df/src/java/org/apache/cassandra/transport/messages/BatchMessage.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/transport/messages/BatchMessage.java b/src/java/org/apache/cassandra/transport/messages/BatchMessage.java
index 221dcd9..34dd8fe 100644
--- a/src/java/org/apache/cassandra/transport/messages/BatchMessage.java
+++ b/src/java/org/apache/cassandra/transport/messages/BatchMessage.java
@@ -162,6 +162,7 @@ public class BatchMessage extends Message.Request
 
             QueryHandler handler = state.getClientState().getCQLQueryHandler();
             List<ModificationStatement> statements = new ArrayList<ModificationStatement>(queryOrIdList.size());
+            boolean hasConditions = false;
             for (int i = 0; i < queryOrIdList.size(); i++)
             {
                 Object query = queryOrIdList.get(i);
@@ -186,6 +187,7 @@ public class BatchMessage extends Message.Request
                     throw new InvalidRequestException("Invalid statement in batch: only UPDATE,
INSERT and DELETE statements are allowed.");
 
                 ModificationStatement mst = (ModificationStatement)statement;
+                hasConditions |= mst.hasConditions();
                 if (mst.isCounter())
                 {
                     if (type != BatchStatement.Type.COUNTER)
@@ -201,7 +203,7 @@ public class BatchMessage extends Message.Request
 
             // Note: It's ok at this point to pass a bogus value for the number of bound
terms in the BatchState ctor
             // (and no value would be really correct, so we prefer passing a clearly wrong
one).
-            BatchStatement batch = new BatchStatement(-1, type, statements, Attributes.none());
+            BatchStatement batch = new BatchStatement(-1, type, statements, Attributes.none(),
hasConditions);
             Message.Response response = handler.processBatch(batch, state, new BatchQueryOptions(consistency,
values, queryOrIdList));
 
             if (tracingId != null)


Mime
View raw message