Fix native protocol CAS batches

patch by Sylvain Lebresne; reviewed by Aleksey Yeschenko for
CASSANDRA-7337
This commit is contained in:
Sylvain Lebresne 2014-06-10 00:27:42 +03:00 committed by Aleksey Yeschenko
parent 0c3424e21f
commit aa9894df43
4 changed files with 6 additions and 9 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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)