Updated Branches: refs/heads/trunk 771005e99 -> 297f530c2
Move consistency level to the protocol level patch by slebresne; reviewed by jbellis for CASSANDRA-4734 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/297f530c Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/297f530c Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/297f530c Branch: refs/heads/trunk Commit: 297f530c246a8dcfa3372d33204f17c2edee7b45 Parents: 771005e Author: Sylvain Lebresne <[email protected]> Authored: Mon Oct 1 16:28:41 2012 +0200 Committer: Sylvain Lebresne <[email protected]> Committed: Tue Oct 16 18:00:36 2012 +0200 ---------------------------------------------------------------------- CHANGES.txt | 1 + NEWS.txt | 2 + doc/native_protocol.spec | 32 +- interface/cassandra.thrift | 24 +- .../org/apache/cassandra/thrift/Cassandra.java | 3772 ++++++++++++++- .../org/apache/cassandra/thrift/Constants.java | 2 +- .../apache/cassandra/thrift/TimedOutException.java | 2 - .../org/apache/cassandra/config/CFMetaData.java | 39 +- src/java/org/apache/cassandra/cql3/Attributes.java | 1 - src/java/org/apache/cassandra/cql3/CFPropDefs.java | 24 - .../org/apache/cassandra/cql3/CQLStatement.java | 3 +- src/java/org/apache/cassandra/cql3/Cql.g | 14 +- .../org/apache/cassandra/cql3/QueryProcessor.java | 12 +- .../cassandra/cql3/statements/BatchStatement.java | 40 +- .../cassandra/cql3/statements/DeleteStatement.java | 16 +- .../cql3/statements/ModificationStatement.java | 57 +- .../statements/PermissionAlteringStatement.java | 12 + .../cql3/statements/SchemaAlteringStatement.java | 13 +- .../cassandra/cql3/statements/SelectStatement.java | 25 +- .../cql3/statements/TruncateStatement.java | 3 +- .../cassandra/cql3/statements/UpdateStatement.java | 23 +- .../cassandra/cql3/statements/UseStatement.java | 3 +- .../apache/cassandra/thrift/CassandraServer.java | 126 +- .../org/apache/cassandra/transport/CBUtil.java | 25 + .../org/apache/cassandra/transport/Client.java | 7 +- .../apache/cassandra/transport/SimpleClient.java | 9 +- .../cassandra/transport/messages/ErrorMessage.java | 8 +- .../transport/messages/ExecuteMessage.java | 19 +- .../cassandra/transport/messages/QueryMessage.java | 14 +- 29 files changed, 3984 insertions(+), 344 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/297f530c/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index ddd21ab..5a8dbd9 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -30,6 +30,7 @@ * Run leveled compaction in parallel (CASSANDRA-4310) * Fix potential NPE during CFS reload (CASSANDRA-4786) * Composite indexes may miss results (CASSANDRA-4796) + * Move consistency level to the protocol level (CASSANDRA-4734) 1.2-beta1 http://git-wip-us.apache.org/repos/asf/cassandra/blob/297f530c/NEWS.txt ---------------------------------------------------------------------- diff --git a/NEWS.txt b/NEWS.txt index f1649ad..920940f 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -63,6 +63,8 @@ Upgrading syntax to create a keyspace is now: CREATE KEYSPACE ks WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 2 }; + Also, the consistency level cannot be set in the language anymore, but is + at the protocol level. Please refer to the CQL3 documentation for details. Features http://git-wip-us.apache.org/repos/asf/cassandra/blob/297f530c/doc/native_protocol.spec ---------------------------------------------------------------------- diff --git a/doc/native_protocol.spec b/doc/native_protocol.spec index a7fa7cb..b8152bc 100644 --- a/doc/native_protocol.spec +++ b/doc/native_protocol.spec @@ -174,6 +174,15 @@ Table of Contents [byte] repesenting the IP address (in practice n can only be either 4 (IPv4) or 16 (IPv6)), following by one [int] representing the port. + [consistency] A consistency level specification. This is a [string] having + one of the following value: "", "ANY", "ONE", "TWO", "THREE", + "QUORUM", "ALL", "LOCAL_QUORUM", "EACH_QUORUM". It is + possible to provide an empty string, in which case a default + consistency will be used server side. Providing an empty + consistency level can also be useful to save bytes for cases + where a [consistency] is required by the protocol but not + strictly by the operation. The server never sends an empty + [consistency] however. [string map] A [short] n, followed by n pair <k><v> where <k> and <v> are [string]. @@ -232,7 +241,10 @@ Table of Contents 4.1.4. QUERY Performs a CQL query. The body of the message consists of a CQL query as a [long - string]. + string] followed by the [consistency] for the operation. + + Note that the consistency is ignored by some queries (USE, CREATE, ALTER, + TRUNCATE, ...). The server will respond to a QUERY message with a RESULT message, the content of which depends on the query. @@ -250,13 +262,17 @@ Table of Contents 4.1.6. EXECUTE Executes a prepared query. The body of the message must be: - <id><n><value_1>....<value_n> + <id><n><value_1>....<value_n><consistency> where: - <id> is the prepared query ID. It's the [short bytes] returned as a response to a PREPARE message. - <n> is a [short] indicating the number of following values. - <value_1>...<value_n> are the [bytes] to use for bound variables in the prepared query. + - <consistency> is the [consistency] level for the operation. + + Note that the consistency is ignored by some (prepared) queries (USE, CREATE, + ALTER, TRUNCATE, ...). The response from the server will be a RESULT message. @@ -509,8 +525,8 @@ Table of Contents 0x1000 Unavailable exception. The rest of the ERROR message body will be <cl><required><alive> where: - <cl> is a [string] representing the consistency level of the - query having triggered the exception. + <cl> is the [consistency] level of the query having triggered + the exception. <required> is an [int] representing the number of node that should be alive to respect <cl> <alive> is an [int] representing the number of replica that @@ -526,8 +542,8 @@ Table of Contents of the ERROR message body will be <cl><received><blockfor><writeType> where: - <cl> is a [string] representing the consistency level of the - query having triggered the exception. + <cl> is the [consistency] level of the query having triggered + the exception. <received> is an [int] representing the number of nodes having acknowledged the request. <blockfor> is the number of replica whose acknowledgement is @@ -552,8 +568,8 @@ Table of Contents of the ERROR message body will be <cl><received><blockfor><data_present> where: - <cl> is a [string] representing the consistency level of the - query having triggered the exception. + <cl> is the [consistency] level of the query having triggered + the exception. <received> is an [int] representing the number of nodes having answered the request. <blockfor> is the number of replica whose response is http://git-wip-us.apache.org/repos/asf/cassandra/blob/297f530c/interface/cassandra.thrift ---------------------------------------------------------------------- diff --git a/interface/cassandra.thrift b/interface/cassandra.thrift index a2d0294..237d2bf 100644 --- a/interface/cassandra.thrift +++ b/interface/cassandra.thrift @@ -55,7 +55,7 @@ namespace rb CassandraThrift # An effort should be made not to break forward-client-compatibility either # (e.g. one should avoid removing obsolete fields from the IDL), but no # guarantees in this respect are made by the Cassandra project. -const string VERSION = "19.34.0" +const string VERSION = "19.35.0" # @@ -772,8 +772,14 @@ service Cassandra { 2:UnavailableException ue, 3:TimedOutException te, 4:SchemaDisagreementException sde) - - + + CqlResult execute_cql3_query(1:required binary query, 2:required Compression compression, 3:required ConsistencyLevel consistency) + throws (1:InvalidRequestException ire, + 2:UnavailableException ue, + 3:TimedOutException te, + 4:SchemaDisagreementException sde) + + /** * Prepare a CQL (Cassandra Query Language) statement by compiling and returning * - the type of CQL statement @@ -783,6 +789,9 @@ service Cassandra { CqlPreparedResult prepare_cql_query(1:required binary query, 2:required Compression compression) throws (1:InvalidRequestException ire) + CqlPreparedResult prepare_cql3_query(1:required binary query, 2:required Compression compression) + throws (1:InvalidRequestException ire) + /** * Executes a prepared CQL (Cassandra Query Language) statement by passing an id token and a list of variables @@ -794,5 +803,14 @@ service Cassandra { 3:TimedOutException te, 4:SchemaDisagreementException sde) + CqlResult execute_prepared_cql3_query(1:required i32 itemId, 2:required list<binary> values, 3:required ConsistencyLevel consistency) + throws (1:InvalidRequestException ire, + 2:UnavailableException ue, + 3:TimedOutException te, + 4:SchemaDisagreementException sde) + + /** + * @Deprecated This is now a no-op. Please use the CQL3 specific methods instead. + */ void set_cql_version(1: required string version) throws (1:InvalidRequestException ire) }
