From 297f530c246a8dcfa3372d33204f17c2edee7b45 Mon Sep 17 00:00:00 2001 From: Sylvain Lebresne Date: Mon, 1 Oct 2012 16:28:41 +0200 Subject: [PATCH] Move consistency level to the protocol level patch by slebresne; reviewed by jbellis for CASSANDRA-4734 --- CHANGES.txt | 1 + NEWS.txt | 2 + doc/native_protocol.spec | 32 +- interface/cassandra.thrift | 24 +- .../apache/cassandra/thrift/Cassandra.java | 3598 ++++++++++++++++- .../apache/cassandra/thrift/Constants.java | 2 +- .../cassandra/thrift/TimedOutException.java | 2 - .../apache/cassandra/config/CFMetaData.java | 39 +- .../org/apache/cassandra/cql3/Attributes.java | 1 - .../org/apache/cassandra/cql3/CFPropDefs.java | 24 - .../apache/cassandra/cql3/CQLStatement.java | 3 +- src/java/org/apache/cassandra/cql3/Cql.g | 14 +- .../apache/cassandra/cql3/QueryProcessor.java | 12 +- .../cql3/statements/BatchStatement.java | 40 +- .../cql3/statements/DeleteStatement.java | 16 +- .../statements/ModificationStatement.java | 57 +- .../PermissionAlteringStatement.java | 12 + .../statements/SchemaAlteringStatement.java | 13 +- .../cql3/statements/SelectStatement.java | 25 +- .../cql3/statements/TruncateStatement.java | 3 +- .../cql3/statements/UpdateStatement.java | 23 +- .../cql3/statements/UseStatement.java | 3 +- .../cassandra/thrift/CassandraServer.java | 140 +- .../apache/cassandra/transport/CBUtil.java | 25 + .../apache/cassandra/transport/Client.java | 7 +- .../cassandra/transport/SimpleClient.java | 9 +- .../transport/messages/ErrorMessage.java | 8 +- .../transport/messages/ExecuteMessage.java | 19 +- .../transport/messages/QueryMessage.java | 14 +- 29 files changed, 3904 insertions(+), 264 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index ddd21ab2a6..5a8dbd9c4d 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 diff --git a/NEWS.txt b/NEWS.txt index f1649adea6..920940ff80 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 diff --git a/doc/native_protocol.spec b/doc/native_protocol.spec index a7fa7cb126..b8152bcf95 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 where and 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: - .... + .... where: - is the prepared query ID. It's the [short bytes] returned as a response to a PREPARE message. - is a [short] indicating the number of following values. - ... are the [bytes] to use for bound variables in the prepared query. + - 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 where: - is a [string] representing the consistency level of the - query having triggered the exception. + is the [consistency] level of the query having triggered + the exception. is an [int] representing the number of node that should be alive to respect is an [int] representing the number of replica that @@ -526,8 +542,8 @@ Table of Contents of the ERROR message body will be where: - is a [string] representing the consistency level of the - query having triggered the exception. + is the [consistency] level of the query having triggered + the exception. is an [int] representing the number of nodes having acknowledged the request. is the number of replica whose acknowledgement is @@ -552,8 +568,8 @@ Table of Contents of the ERROR message body will be where: - is a [string] representing the consistency level of the - query having triggered the exception. + is the [consistency] level of the query having triggered + the exception. is an [int] representing the number of nodes having answered the request. is the number of replica whose response is diff --git a/interface/cassandra.thrift b/interface/cassandra.thrift index a2d0294158..237d2bfde6 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 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) } diff --git a/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java b/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java index c48a0ddaa0..e43d02dd63 100644 --- a/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java +++ b/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java @@ -341,6 +341,8 @@ public class Cassandra { */ public CqlResult execute_cql_query(ByteBuffer query, Compression compression) throws InvalidRequestException, UnavailableException, TimedOutException, SchemaDisagreementException, org.apache.thrift.TException; + public CqlResult execute_cql3_query(ByteBuffer query, Compression compression, ConsistencyLevel consistency) throws InvalidRequestException, UnavailableException, TimedOutException, SchemaDisagreementException, org.apache.thrift.TException; + /** * Prepare a CQL (Cassandra Query Language) statement by compiling and returning * - the type of CQL statement @@ -352,6 +354,8 @@ public class Cassandra { */ public CqlPreparedResult prepare_cql_query(ByteBuffer query, Compression compression) throws InvalidRequestException, org.apache.thrift.TException; + public CqlPreparedResult prepare_cql3_query(ByteBuffer query, Compression compression) throws InvalidRequestException, org.apache.thrift.TException; + /** * Executes a prepared CQL (Cassandra Query Language) statement by passing an id token and a list of variables * to bind and returns a CqlResult containing the results. @@ -361,6 +365,13 @@ public class Cassandra { */ public CqlResult execute_prepared_cql_query(int itemId, List values) throws InvalidRequestException, UnavailableException, TimedOutException, SchemaDisagreementException, org.apache.thrift.TException; + public CqlResult execute_prepared_cql3_query(int itemId, List values, ConsistencyLevel consistency) throws InvalidRequestException, UnavailableException, TimedOutException, SchemaDisagreementException, org.apache.thrift.TException; + + /** + * @Deprecated This is now a no-op. Please use the CQL3 specific methods instead. + * + * @param version + */ public void set_cql_version(String version) throws InvalidRequestException, org.apache.thrift.TException; } @@ -437,10 +448,16 @@ public class Cassandra { public void execute_cql_query(ByteBuffer query, Compression compression, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + public void execute_cql3_query(ByteBuffer query, Compression compression, ConsistencyLevel consistency, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + public void prepare_cql_query(ByteBuffer query, Compression compression, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + public void prepare_cql3_query(ByteBuffer query, Compression compression, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + public void execute_prepared_cql_query(int itemId, List values, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + public void execute_prepared_cql3_query(int itemId, List values, ConsistencyLevel consistency, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + public void set_cql_version(String version, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; } @@ -1491,6 +1508,43 @@ public class Cassandra { throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "execute_cql_query failed: unknown result"); } + public CqlResult execute_cql3_query(ByteBuffer query, Compression compression, ConsistencyLevel consistency) throws InvalidRequestException, UnavailableException, TimedOutException, SchemaDisagreementException, org.apache.thrift.TException + { + send_execute_cql3_query(query, compression, consistency); + return recv_execute_cql3_query(); + } + + public void send_execute_cql3_query(ByteBuffer query, Compression compression, ConsistencyLevel consistency) throws org.apache.thrift.TException + { + execute_cql3_query_args args = new execute_cql3_query_args(); + args.setQuery(query); + args.setCompression(compression); + args.setConsistency(consistency); + sendBase("execute_cql3_query", args); + } + + public CqlResult recv_execute_cql3_query() throws InvalidRequestException, UnavailableException, TimedOutException, SchemaDisagreementException, org.apache.thrift.TException + { + execute_cql3_query_result result = new execute_cql3_query_result(); + receiveBase(result, "execute_cql3_query"); + if (result.isSetSuccess()) { + return result.success; + } + if (result.ire != null) { + throw result.ire; + } + if (result.ue != null) { + throw result.ue; + } + if (result.te != null) { + throw result.te; + } + if (result.sde != null) { + throw result.sde; + } + throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "execute_cql3_query failed: unknown result"); + } + public CqlPreparedResult prepare_cql_query(ByteBuffer query, Compression compression) throws InvalidRequestException, org.apache.thrift.TException { send_prepare_cql_query(query, compression); @@ -1518,6 +1572,33 @@ public class Cassandra { throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "prepare_cql_query failed: unknown result"); } + public CqlPreparedResult prepare_cql3_query(ByteBuffer query, Compression compression) throws InvalidRequestException, org.apache.thrift.TException + { + send_prepare_cql3_query(query, compression); + return recv_prepare_cql3_query(); + } + + public void send_prepare_cql3_query(ByteBuffer query, Compression compression) throws org.apache.thrift.TException + { + prepare_cql3_query_args args = new prepare_cql3_query_args(); + args.setQuery(query); + args.setCompression(compression); + sendBase("prepare_cql3_query", args); + } + + public CqlPreparedResult recv_prepare_cql3_query() throws InvalidRequestException, org.apache.thrift.TException + { + prepare_cql3_query_result result = new prepare_cql3_query_result(); + receiveBase(result, "prepare_cql3_query"); + if (result.isSetSuccess()) { + return result.success; + } + if (result.ire != null) { + throw result.ire; + } + throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "prepare_cql3_query failed: unknown result"); + } + public CqlResult execute_prepared_cql_query(int itemId, List values) throws InvalidRequestException, UnavailableException, TimedOutException, SchemaDisagreementException, org.apache.thrift.TException { send_execute_prepared_cql_query(itemId, values); @@ -1554,6 +1635,43 @@ public class Cassandra { throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "execute_prepared_cql_query failed: unknown result"); } + public CqlResult execute_prepared_cql3_query(int itemId, List values, ConsistencyLevel consistency) throws InvalidRequestException, UnavailableException, TimedOutException, SchemaDisagreementException, org.apache.thrift.TException + { + send_execute_prepared_cql3_query(itemId, values, consistency); + return recv_execute_prepared_cql3_query(); + } + + public void send_execute_prepared_cql3_query(int itemId, List values, ConsistencyLevel consistency) throws org.apache.thrift.TException + { + execute_prepared_cql3_query_args args = new execute_prepared_cql3_query_args(); + args.setItemId(itemId); + args.setValues(values); + args.setConsistency(consistency); + sendBase("execute_prepared_cql3_query", args); + } + + public CqlResult recv_execute_prepared_cql3_query() throws InvalidRequestException, UnavailableException, TimedOutException, SchemaDisagreementException, org.apache.thrift.TException + { + execute_prepared_cql3_query_result result = new execute_prepared_cql3_query_result(); + receiveBase(result, "execute_prepared_cql3_query"); + if (result.isSetSuccess()) { + return result.success; + } + if (result.ire != null) { + throw result.ire; + } + if (result.ue != null) { + throw result.ue; + } + if (result.te != null) { + throw result.te; + } + if (result.sde != null) { + throw result.sde; + } + throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "execute_prepared_cql3_query failed: unknown result"); + } + public void set_cql_version(String version) throws InvalidRequestException, org.apache.thrift.TException { send_set_cql_version(version); @@ -2811,6 +2929,44 @@ public class Cassandra { } } + public void execute_cql3_query(ByteBuffer query, Compression compression, ConsistencyLevel consistency, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + execute_cql3_query_call method_call = new execute_cql3_query_call(query, compression, consistency, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class execute_cql3_query_call extends org.apache.thrift.async.TAsyncMethodCall { + private ByteBuffer query; + private Compression compression; + private ConsistencyLevel consistency; + public execute_cql3_query_call(ByteBuffer query, Compression compression, ConsistencyLevel consistency, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.query = query; + this.compression = compression; + this.consistency = consistency; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("execute_cql3_query", org.apache.thrift.protocol.TMessageType.CALL, 0)); + execute_cql3_query_args args = new execute_cql3_query_args(); + args.setQuery(query); + args.setCompression(compression); + args.setConsistency(consistency); + args.write(prot); + prot.writeMessageEnd(); + } + + public CqlResult getResult() throws InvalidRequestException, UnavailableException, TimedOutException, SchemaDisagreementException, org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + return (new Client(prot)).recv_execute_cql3_query(); + } + } + public void prepare_cql_query(ByteBuffer query, Compression compression, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { checkReady(); prepare_cql_query_call method_call = new prepare_cql_query_call(query, compression, resultHandler, this, ___protocolFactory, ___transport); @@ -2846,6 +3002,41 @@ public class Cassandra { } } + public void prepare_cql3_query(ByteBuffer query, Compression compression, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + prepare_cql3_query_call method_call = new prepare_cql3_query_call(query, compression, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class prepare_cql3_query_call extends org.apache.thrift.async.TAsyncMethodCall { + private ByteBuffer query; + private Compression compression; + public prepare_cql3_query_call(ByteBuffer query, Compression compression, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.query = query; + this.compression = compression; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("prepare_cql3_query", org.apache.thrift.protocol.TMessageType.CALL, 0)); + prepare_cql3_query_args args = new prepare_cql3_query_args(); + args.setQuery(query); + args.setCompression(compression); + args.write(prot); + prot.writeMessageEnd(); + } + + public CqlPreparedResult getResult() throws InvalidRequestException, org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + return (new Client(prot)).recv_prepare_cql3_query(); + } + } + public void execute_prepared_cql_query(int itemId, List values, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { checkReady(); execute_prepared_cql_query_call method_call = new execute_prepared_cql_query_call(itemId, values, resultHandler, this, ___protocolFactory, ___transport); @@ -2881,6 +3072,44 @@ public class Cassandra { } } + public void execute_prepared_cql3_query(int itemId, List values, ConsistencyLevel consistency, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + execute_prepared_cql3_query_call method_call = new execute_prepared_cql3_query_call(itemId, values, consistency, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class execute_prepared_cql3_query_call extends org.apache.thrift.async.TAsyncMethodCall { + private int itemId; + private List values; + private ConsistencyLevel consistency; + public execute_prepared_cql3_query_call(int itemId, List values, ConsistencyLevel consistency, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.itemId = itemId; + this.values = values; + this.consistency = consistency; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("execute_prepared_cql3_query", org.apache.thrift.protocol.TMessageType.CALL, 0)); + execute_prepared_cql3_query_args args = new execute_prepared_cql3_query_args(); + args.setItemId(itemId); + args.setValues(values); + args.setConsistency(consistency); + args.write(prot); + prot.writeMessageEnd(); + } + + public CqlResult getResult() throws InvalidRequestException, UnavailableException, TimedOutException, SchemaDisagreementException, org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + return (new Client(prot)).recv_execute_prepared_cql3_query(); + } + } + public void set_cql_version(String version, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { checkReady(); set_cql_version_call method_call = new set_cql_version_call(version, resultHandler, this, ___protocolFactory, ___transport); @@ -2961,8 +3190,11 @@ public class Cassandra { processMap.put("system_update_keyspace", new system_update_keyspace()); processMap.put("system_update_column_family", new system_update_column_family()); processMap.put("execute_cql_query", new execute_cql_query()); + processMap.put("execute_cql3_query", new execute_cql3_query()); processMap.put("prepare_cql_query", new prepare_cql_query()); + processMap.put("prepare_cql3_query", new prepare_cql3_query()); processMap.put("execute_prepared_cql_query", new execute_prepared_cql_query()); + processMap.put("execute_prepared_cql3_query", new execute_prepared_cql3_query()); processMap.put("set_cql_version", new set_cql_version()); return processMap; } @@ -3732,6 +3964,32 @@ public class Cassandra { } } + private static class execute_cql3_query extends org.apache.thrift.ProcessFunction { + public execute_cql3_query() { + super("execute_cql3_query"); + } + + protected execute_cql3_query_args getEmptyArgsInstance() { + return new execute_cql3_query_args(); + } + + protected execute_cql3_query_result getResult(I iface, execute_cql3_query_args args) throws org.apache.thrift.TException { + execute_cql3_query_result result = new execute_cql3_query_result(); + try { + result.success = iface.execute_cql3_query(args.query, args.compression, args.consistency); + } catch (InvalidRequestException ire) { + result.ire = ire; + } catch (UnavailableException ue) { + result.ue = ue; + } catch (TimedOutException te) { + result.te = te; + } catch (SchemaDisagreementException sde) { + result.sde = sde; + } + return result; + } + } + private static class prepare_cql_query extends org.apache.thrift.ProcessFunction { public prepare_cql_query() { super("prepare_cql_query"); @@ -3752,6 +4010,26 @@ public class Cassandra { } } + private static class prepare_cql3_query extends org.apache.thrift.ProcessFunction { + public prepare_cql3_query() { + super("prepare_cql3_query"); + } + + protected prepare_cql3_query_args getEmptyArgsInstance() { + return new prepare_cql3_query_args(); + } + + protected prepare_cql3_query_result getResult(I iface, prepare_cql3_query_args args) throws org.apache.thrift.TException { + prepare_cql3_query_result result = new prepare_cql3_query_result(); + try { + result.success = iface.prepare_cql3_query(args.query, args.compression); + } catch (InvalidRequestException ire) { + result.ire = ire; + } + return result; + } + } + private static class execute_prepared_cql_query extends org.apache.thrift.ProcessFunction { public execute_prepared_cql_query() { super("execute_prepared_cql_query"); @@ -3778,6 +4056,32 @@ public class Cassandra { } } + private static class execute_prepared_cql3_query extends org.apache.thrift.ProcessFunction { + public execute_prepared_cql3_query() { + super("execute_prepared_cql3_query"); + } + + protected execute_prepared_cql3_query_args getEmptyArgsInstance() { + return new execute_prepared_cql3_query_args(); + } + + protected execute_prepared_cql3_query_result getResult(I iface, execute_prepared_cql3_query_args args) throws org.apache.thrift.TException { + execute_prepared_cql3_query_result result = new execute_prepared_cql3_query_result(); + try { + result.success = iface.execute_prepared_cql3_query(args.itemId, args.values, args.consistency); + } catch (InvalidRequestException ire) { + result.ire = ire; + } catch (UnavailableException ue) { + result.ue = ue; + } catch (TimedOutException te) { + result.te = te; + } catch (SchemaDisagreementException sde) { + result.sde = sde; + } + return result; + } + } + private static class set_cql_version extends org.apache.thrift.ProcessFunction { public set_cql_version() { super("set_cql_version"); @@ -17996,8 +18300,6 @@ public class Cassandra { private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { try { - // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. - __isset_bit_vector = new BitSet(1); read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); @@ -35328,6 +35630,1230 @@ public class Cassandra { } + public static class execute_cql3_query_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("execute_cql3_query_args"); + + private static final org.apache.thrift.protocol.TField QUERY_FIELD_DESC = new org.apache.thrift.protocol.TField("query", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField COMPRESSION_FIELD_DESC = new org.apache.thrift.protocol.TField("compression", org.apache.thrift.protocol.TType.I32, (short)2); + private static final org.apache.thrift.protocol.TField CONSISTENCY_FIELD_DESC = new org.apache.thrift.protocol.TField("consistency", org.apache.thrift.protocol.TType.I32, (short)3); + + public ByteBuffer query; // required + /** + * + * @see Compression + */ + public Compression compression; // required + /** + * + * @see ConsistencyLevel + */ + public ConsistencyLevel consistency; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + QUERY((short)1, "query"), + /** + * + * @see Compression + */ + COMPRESSION((short)2, "compression"), + /** + * + * @see ConsistencyLevel + */ + CONSISTENCY((short)3, "consistency"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // QUERY + return QUERY; + case 2: // COMPRESSION + return COMPRESSION; + case 3: // CONSISTENCY + return CONSISTENCY; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.QUERY, new org.apache.thrift.meta_data.FieldMetaData("query", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true))); + tmpMap.put(_Fields.COMPRESSION, new org.apache.thrift.meta_data.FieldMetaData("compression", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, Compression.class))); + tmpMap.put(_Fields.CONSISTENCY, new org.apache.thrift.meta_data.FieldMetaData("consistency", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, ConsistencyLevel.class))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(execute_cql3_query_args.class, metaDataMap); + } + + public execute_cql3_query_args() { + } + + public execute_cql3_query_args( + ByteBuffer query, + Compression compression, + ConsistencyLevel consistency) + { + this(); + this.query = query; + this.compression = compression; + this.consistency = consistency; + } + + /** + * Performs a deep copy on other. + */ + public execute_cql3_query_args(execute_cql3_query_args other) { + if (other.isSetQuery()) { + this.query = org.apache.thrift.TBaseHelper.copyBinary(other.query); +; + } + if (other.isSetCompression()) { + this.compression = other.compression; + } + if (other.isSetConsistency()) { + this.consistency = other.consistency; + } + } + + public execute_cql3_query_args deepCopy() { + return new execute_cql3_query_args(this); + } + + @Override + public void clear() { + this.query = null; + this.compression = null; + this.consistency = null; + } + + public byte[] getQuery() { + setQuery(org.apache.thrift.TBaseHelper.rightSize(query)); + return query == null ? null : query.array(); + } + + public ByteBuffer bufferForQuery() { + return query; + } + + public execute_cql3_query_args setQuery(byte[] query) { + setQuery(query == null ? (ByteBuffer)null : ByteBuffer.wrap(query)); + return this; + } + + public execute_cql3_query_args setQuery(ByteBuffer query) { + this.query = query; + return this; + } + + public void unsetQuery() { + this.query = null; + } + + /** Returns true if field query is set (has been assigned a value) and false otherwise */ + public boolean isSetQuery() { + return this.query != null; + } + + public void setQueryIsSet(boolean value) { + if (!value) { + this.query = null; + } + } + + /** + * + * @see Compression + */ + public Compression getCompression() { + return this.compression; + } + + /** + * + * @see Compression + */ + public execute_cql3_query_args setCompression(Compression compression) { + this.compression = compression; + return this; + } + + public void unsetCompression() { + this.compression = null; + } + + /** Returns true if field compression is set (has been assigned a value) and false otherwise */ + public boolean isSetCompression() { + return this.compression != null; + } + + public void setCompressionIsSet(boolean value) { + if (!value) { + this.compression = null; + } + } + + /** + * + * @see ConsistencyLevel + */ + public ConsistencyLevel getConsistency() { + return this.consistency; + } + + /** + * + * @see ConsistencyLevel + */ + public execute_cql3_query_args setConsistency(ConsistencyLevel consistency) { + this.consistency = consistency; + return this; + } + + public void unsetConsistency() { + this.consistency = null; + } + + /** Returns true if field consistency is set (has been assigned a value) and false otherwise */ + public boolean isSetConsistency() { + return this.consistency != null; + } + + public void setConsistencyIsSet(boolean value) { + if (!value) { + this.consistency = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case QUERY: + if (value == null) { + unsetQuery(); + } else { + setQuery((ByteBuffer)value); + } + break; + + case COMPRESSION: + if (value == null) { + unsetCompression(); + } else { + setCompression((Compression)value); + } + break; + + case CONSISTENCY: + if (value == null) { + unsetConsistency(); + } else { + setConsistency((ConsistencyLevel)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case QUERY: + return getQuery(); + + case COMPRESSION: + return getCompression(); + + case CONSISTENCY: + return getConsistency(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case QUERY: + return isSetQuery(); + case COMPRESSION: + return isSetCompression(); + case CONSISTENCY: + return isSetConsistency(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof execute_cql3_query_args) + return this.equals((execute_cql3_query_args)that); + return false; + } + + public boolean equals(execute_cql3_query_args that) { + if (that == null) + return false; + + boolean this_present_query = true && this.isSetQuery(); + boolean that_present_query = true && that.isSetQuery(); + if (this_present_query || that_present_query) { + if (!(this_present_query && that_present_query)) + return false; + if (!this.query.equals(that.query)) + return false; + } + + boolean this_present_compression = true && this.isSetCompression(); + boolean that_present_compression = true && that.isSetCompression(); + if (this_present_compression || that_present_compression) { + if (!(this_present_compression && that_present_compression)) + return false; + if (!this.compression.equals(that.compression)) + return false; + } + + boolean this_present_consistency = true && this.isSetConsistency(); + boolean that_present_consistency = true && that.isSetConsistency(); + if (this_present_consistency || that_present_consistency) { + if (!(this_present_consistency && that_present_consistency)) + return false; + if (!this.consistency.equals(that.consistency)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + HashCodeBuilder builder = new HashCodeBuilder(); + + boolean present_query = true && (isSetQuery()); + builder.append(present_query); + if (present_query) + builder.append(query); + + boolean present_compression = true && (isSetCompression()); + builder.append(present_compression); + if (present_compression) + builder.append(compression.getValue()); + + boolean present_consistency = true && (isSetConsistency()); + builder.append(present_consistency); + if (present_consistency) + builder.append(consistency.getValue()); + + return builder.toHashCode(); + } + + public int compareTo(execute_cql3_query_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + execute_cql3_query_args typedOther = (execute_cql3_query_args)other; + + lastComparison = Boolean.valueOf(isSetQuery()).compareTo(typedOther.isSetQuery()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetQuery()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.query, typedOther.query); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetCompression()).compareTo(typedOther.isSetCompression()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetCompression()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.compression, typedOther.compression); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetConsistency()).compareTo(typedOther.isSetConsistency()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetConsistency()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.consistency, typedOther.consistency); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField field; + iprot.readStructBegin(); + while (true) + { + field = iprot.readFieldBegin(); + if (field.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (field.id) { + case 1: // QUERY + if (field.type == org.apache.thrift.protocol.TType.STRING) { + this.query = iprot.readBinary(); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 2: // COMPRESSION + if (field.type == org.apache.thrift.protocol.TType.I32) { + this.compression = Compression.findByValue(iprot.readI32()); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 3: // CONSISTENCY + if (field.type == org.apache.thrift.protocol.TType.I32) { + this.consistency = ConsistencyLevel.findByValue(iprot.readI32()); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (this.query != null) { + oprot.writeFieldBegin(QUERY_FIELD_DESC); + oprot.writeBinary(this.query); + oprot.writeFieldEnd(); + } + if (this.compression != null) { + oprot.writeFieldBegin(COMPRESSION_FIELD_DESC); + oprot.writeI32(this.compression.getValue()); + oprot.writeFieldEnd(); + } + if (this.consistency != null) { + oprot.writeFieldBegin(CONSISTENCY_FIELD_DESC); + oprot.writeI32(this.consistency.getValue()); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("execute_cql3_query_args("); + boolean first = true; + + sb.append("query:"); + if (this.query == null) { + sb.append("null"); + } else { + org.apache.thrift.TBaseHelper.toString(this.query, sb); + } + first = false; + if (!first) sb.append(", "); + sb.append("compression:"); + if (this.compression == null) { + sb.append("null"); + } else { + sb.append(this.compression); + } + first = false; + if (!first) sb.append(", "); + sb.append("consistency:"); + if (this.consistency == null) { + sb.append("null"); + } else { + sb.append(this.consistency); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (query == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'query' was not present! Struct: " + toString()); + } + if (compression == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'compression' was not present! Struct: " + toString()); + } + if (consistency == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'consistency' was not present! Struct: " + toString()); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + } + + public static class execute_cql3_query_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("execute_cql3_query_result"); + + private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0); + private static final org.apache.thrift.protocol.TField IRE_FIELD_DESC = new org.apache.thrift.protocol.TField("ire", org.apache.thrift.protocol.TType.STRUCT, (short)1); + private static final org.apache.thrift.protocol.TField UE_FIELD_DESC = new org.apache.thrift.protocol.TField("ue", org.apache.thrift.protocol.TType.STRUCT, (short)2); + private static final org.apache.thrift.protocol.TField TE_FIELD_DESC = new org.apache.thrift.protocol.TField("te", org.apache.thrift.protocol.TType.STRUCT, (short)3); + private static final org.apache.thrift.protocol.TField SDE_FIELD_DESC = new org.apache.thrift.protocol.TField("sde", org.apache.thrift.protocol.TType.STRUCT, (short)4); + + public CqlResult success; // required + public InvalidRequestException ire; // required + public UnavailableException ue; // required + public TimedOutException te; // required + public SchemaDisagreementException sde; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SUCCESS((short)0, "success"), + IRE((short)1, "ire"), + UE((short)2, "ue"), + TE((short)3, "te"), + SDE((short)4, "sde"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + case 1: // IRE + return IRE; + case 2: // UE + return UE; + case 3: // TE + return TE; + case 4: // SDE + return SDE; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, CqlResult.class))); + tmpMap.put(_Fields.IRE, new org.apache.thrift.meta_data.FieldMetaData("ire", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT))); + tmpMap.put(_Fields.UE, new org.apache.thrift.meta_data.FieldMetaData("ue", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT))); + tmpMap.put(_Fields.TE, new org.apache.thrift.meta_data.FieldMetaData("te", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT))); + tmpMap.put(_Fields.SDE, new org.apache.thrift.meta_data.FieldMetaData("sde", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(execute_cql3_query_result.class, metaDataMap); + } + + public execute_cql3_query_result() { + } + + public execute_cql3_query_result( + CqlResult success, + InvalidRequestException ire, + UnavailableException ue, + TimedOutException te, + SchemaDisagreementException sde) + { + this(); + this.success = success; + this.ire = ire; + this.ue = ue; + this.te = te; + this.sde = sde; + } + + /** + * Performs a deep copy on other. + */ + public execute_cql3_query_result(execute_cql3_query_result other) { + if (other.isSetSuccess()) { + this.success = new CqlResult(other.success); + } + if (other.isSetIre()) { + this.ire = new InvalidRequestException(other.ire); + } + if (other.isSetUe()) { + this.ue = new UnavailableException(other.ue); + } + if (other.isSetTe()) { + this.te = new TimedOutException(other.te); + } + if (other.isSetSde()) { + this.sde = new SchemaDisagreementException(other.sde); + } + } + + public execute_cql3_query_result deepCopy() { + return new execute_cql3_query_result(this); + } + + @Override + public void clear() { + this.success = null; + this.ire = null; + this.ue = null; + this.te = null; + this.sde = null; + } + + public CqlResult getSuccess() { + return this.success; + } + + public execute_cql3_query_result setSuccess(CqlResult success) { + this.success = success; + return this; + } + + public void unsetSuccess() { + this.success = null; + } + + /** Returns true if field success is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccess() { + return this.success != null; + } + + public void setSuccessIsSet(boolean value) { + if (!value) { + this.success = null; + } + } + + public InvalidRequestException getIre() { + return this.ire; + } + + public execute_cql3_query_result setIre(InvalidRequestException ire) { + this.ire = ire; + return this; + } + + public void unsetIre() { + this.ire = null; + } + + /** Returns true if field ire is set (has been assigned a value) and false otherwise */ + public boolean isSetIre() { + return this.ire != null; + } + + public void setIreIsSet(boolean value) { + if (!value) { + this.ire = null; + } + } + + public UnavailableException getUe() { + return this.ue; + } + + public execute_cql3_query_result setUe(UnavailableException ue) { + this.ue = ue; + return this; + } + + public void unsetUe() { + this.ue = null; + } + + /** Returns true if field ue is set (has been assigned a value) and false otherwise */ + public boolean isSetUe() { + return this.ue != null; + } + + public void setUeIsSet(boolean value) { + if (!value) { + this.ue = null; + } + } + + public TimedOutException getTe() { + return this.te; + } + + public execute_cql3_query_result setTe(TimedOutException te) { + this.te = te; + return this; + } + + public void unsetTe() { + this.te = null; + } + + /** Returns true if field te is set (has been assigned a value) and false otherwise */ + public boolean isSetTe() { + return this.te != null; + } + + public void setTeIsSet(boolean value) { + if (!value) { + this.te = null; + } + } + + public SchemaDisagreementException getSde() { + return this.sde; + } + + public execute_cql3_query_result setSde(SchemaDisagreementException sde) { + this.sde = sde; + return this; + } + + public void unsetSde() { + this.sde = null; + } + + /** Returns true if field sde is set (has been assigned a value) and false otherwise */ + public boolean isSetSde() { + return this.sde != null; + } + + public void setSdeIsSet(boolean value) { + if (!value) { + this.sde = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((CqlResult)value); + } + break; + + case IRE: + if (value == null) { + unsetIre(); + } else { + setIre((InvalidRequestException)value); + } + break; + + case UE: + if (value == null) { + unsetUe(); + } else { + setUe((UnavailableException)value); + } + break; + + case TE: + if (value == null) { + unsetTe(); + } else { + setTe((TimedOutException)value); + } + break; + + case SDE: + if (value == null) { + unsetSde(); + } else { + setSde((SchemaDisagreementException)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return getSuccess(); + + case IRE: + return getIre(); + + case UE: + return getUe(); + + case TE: + return getTe(); + + case SDE: + return getSde(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + case IRE: + return isSetIre(); + case UE: + return isSetUe(); + case TE: + return isSetTe(); + case SDE: + return isSetSde(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof execute_cql3_query_result) + return this.equals((execute_cql3_query_result)that); + return false; + } + + public boolean equals(execute_cql3_query_result that) { + if (that == null) + return false; + + boolean this_present_success = true && this.isSetSuccess(); + boolean that_present_success = true && that.isSetSuccess(); + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (!this.success.equals(that.success)) + return false; + } + + boolean this_present_ire = true && this.isSetIre(); + boolean that_present_ire = true && that.isSetIre(); + if (this_present_ire || that_present_ire) { + if (!(this_present_ire && that_present_ire)) + return false; + if (!this.ire.equals(that.ire)) + return false; + } + + boolean this_present_ue = true && this.isSetUe(); + boolean that_present_ue = true && that.isSetUe(); + if (this_present_ue || that_present_ue) { + if (!(this_present_ue && that_present_ue)) + return false; + if (!this.ue.equals(that.ue)) + return false; + } + + boolean this_present_te = true && this.isSetTe(); + boolean that_present_te = true && that.isSetTe(); + if (this_present_te || that_present_te) { + if (!(this_present_te && that_present_te)) + return false; + if (!this.te.equals(that.te)) + return false; + } + + boolean this_present_sde = true && this.isSetSde(); + boolean that_present_sde = true && that.isSetSde(); + if (this_present_sde || that_present_sde) { + if (!(this_present_sde && that_present_sde)) + return false; + if (!this.sde.equals(that.sde)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + HashCodeBuilder builder = new HashCodeBuilder(); + + boolean present_success = true && (isSetSuccess()); + builder.append(present_success); + if (present_success) + builder.append(success); + + boolean present_ire = true && (isSetIre()); + builder.append(present_ire); + if (present_ire) + builder.append(ire); + + boolean present_ue = true && (isSetUe()); + builder.append(present_ue); + if (present_ue) + builder.append(ue); + + boolean present_te = true && (isSetTe()); + builder.append(present_te); + if (present_te) + builder.append(te); + + boolean present_sde = true && (isSetSde()); + builder.append(present_sde); + if (present_sde) + builder.append(sde); + + return builder.toHashCode(); + } + + public int compareTo(execute_cql3_query_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + execute_cql3_query_result typedOther = (execute_cql3_query_result)other; + + lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(typedOther.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, typedOther.success); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetIre()).compareTo(typedOther.isSetIre()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetIre()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ire, typedOther.ire); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetUe()).compareTo(typedOther.isSetUe()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetUe()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ue, typedOther.ue); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetTe()).compareTo(typedOther.isSetTe()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetTe()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.te, typedOther.te); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetSde()).compareTo(typedOther.isSetSde()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSde()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sde, typedOther.sde); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField field; + iprot.readStructBegin(); + while (true) + { + field = iprot.readFieldBegin(); + if (field.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (field.id) { + case 0: // SUCCESS + if (field.type == org.apache.thrift.protocol.TType.STRUCT) { + this.success = new CqlResult(); + this.success.read(iprot); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 1: // IRE + if (field.type == org.apache.thrift.protocol.TType.STRUCT) { + this.ire = new InvalidRequestException(); + this.ire.read(iprot); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 2: // UE + if (field.type == org.apache.thrift.protocol.TType.STRUCT) { + this.ue = new UnavailableException(); + this.ue.read(iprot); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 3: // TE + if (field.type == org.apache.thrift.protocol.TType.STRUCT) { + this.te = new TimedOutException(); + this.te.read(iprot); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 4: // SDE + if (field.type == org.apache.thrift.protocol.TType.STRUCT) { + this.sde = new SchemaDisagreementException(); + this.sde.read(iprot); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + oprot.writeStructBegin(STRUCT_DESC); + + if (this.isSetSuccess()) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + this.success.write(oprot); + oprot.writeFieldEnd(); + } else if (this.isSetIre()) { + oprot.writeFieldBegin(IRE_FIELD_DESC); + this.ire.write(oprot); + oprot.writeFieldEnd(); + } else if (this.isSetUe()) { + oprot.writeFieldBegin(UE_FIELD_DESC); + this.ue.write(oprot); + oprot.writeFieldEnd(); + } else if (this.isSetTe()) { + oprot.writeFieldBegin(TE_FIELD_DESC); + this.te.write(oprot); + oprot.writeFieldEnd(); + } else if (this.isSetSde()) { + oprot.writeFieldBegin(SDE_FIELD_DESC); + this.sde.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("execute_cql3_query_result("); + boolean first = true; + + sb.append("success:"); + if (this.success == null) { + sb.append("null"); + } else { + sb.append(this.success); + } + first = false; + if (!first) sb.append(", "); + sb.append("ire:"); + if (this.ire == null) { + sb.append("null"); + } else { + sb.append(this.ire); + } + first = false; + if (!first) sb.append(", "); + sb.append("ue:"); + if (this.ue == null) { + sb.append("null"); + } else { + sb.append(this.ue); + } + first = false; + if (!first) sb.append(", "); + sb.append("te:"); + if (this.te == null) { + sb.append("null"); + } else { + sb.append(this.te); + } + first = false; + if (!first) sb.append(", "); + sb.append("sde:"); + if (this.sde == null) { + sb.append("null"); + } else { + sb.append(this.sde); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + } + public static class prepare_cql_query_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("prepare_cql_query_args"); @@ -36157,6 +37683,835 @@ public class Cassandra { } + public static class prepare_cql3_query_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("prepare_cql3_query_args"); + + private static final org.apache.thrift.protocol.TField QUERY_FIELD_DESC = new org.apache.thrift.protocol.TField("query", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField COMPRESSION_FIELD_DESC = new org.apache.thrift.protocol.TField("compression", org.apache.thrift.protocol.TType.I32, (short)2); + + public ByteBuffer query; // required + /** + * + * @see Compression + */ + public Compression compression; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + QUERY((short)1, "query"), + /** + * + * @see Compression + */ + COMPRESSION((short)2, "compression"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // QUERY + return QUERY; + case 2: // COMPRESSION + return COMPRESSION; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.QUERY, new org.apache.thrift.meta_data.FieldMetaData("query", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true))); + tmpMap.put(_Fields.COMPRESSION, new org.apache.thrift.meta_data.FieldMetaData("compression", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, Compression.class))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(prepare_cql3_query_args.class, metaDataMap); + } + + public prepare_cql3_query_args() { + } + + public prepare_cql3_query_args( + ByteBuffer query, + Compression compression) + { + this(); + this.query = query; + this.compression = compression; + } + + /** + * Performs a deep copy on other. + */ + public prepare_cql3_query_args(prepare_cql3_query_args other) { + if (other.isSetQuery()) { + this.query = org.apache.thrift.TBaseHelper.copyBinary(other.query); +; + } + if (other.isSetCompression()) { + this.compression = other.compression; + } + } + + public prepare_cql3_query_args deepCopy() { + return new prepare_cql3_query_args(this); + } + + @Override + public void clear() { + this.query = null; + this.compression = null; + } + + public byte[] getQuery() { + setQuery(org.apache.thrift.TBaseHelper.rightSize(query)); + return query == null ? null : query.array(); + } + + public ByteBuffer bufferForQuery() { + return query; + } + + public prepare_cql3_query_args setQuery(byte[] query) { + setQuery(query == null ? (ByteBuffer)null : ByteBuffer.wrap(query)); + return this; + } + + public prepare_cql3_query_args setQuery(ByteBuffer query) { + this.query = query; + return this; + } + + public void unsetQuery() { + this.query = null; + } + + /** Returns true if field query is set (has been assigned a value) and false otherwise */ + public boolean isSetQuery() { + return this.query != null; + } + + public void setQueryIsSet(boolean value) { + if (!value) { + this.query = null; + } + } + + /** + * + * @see Compression + */ + public Compression getCompression() { + return this.compression; + } + + /** + * + * @see Compression + */ + public prepare_cql3_query_args setCompression(Compression compression) { + this.compression = compression; + return this; + } + + public void unsetCompression() { + this.compression = null; + } + + /** Returns true if field compression is set (has been assigned a value) and false otherwise */ + public boolean isSetCompression() { + return this.compression != null; + } + + public void setCompressionIsSet(boolean value) { + if (!value) { + this.compression = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case QUERY: + if (value == null) { + unsetQuery(); + } else { + setQuery((ByteBuffer)value); + } + break; + + case COMPRESSION: + if (value == null) { + unsetCompression(); + } else { + setCompression((Compression)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case QUERY: + return getQuery(); + + case COMPRESSION: + return getCompression(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case QUERY: + return isSetQuery(); + case COMPRESSION: + return isSetCompression(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof prepare_cql3_query_args) + return this.equals((prepare_cql3_query_args)that); + return false; + } + + public boolean equals(prepare_cql3_query_args that) { + if (that == null) + return false; + + boolean this_present_query = true && this.isSetQuery(); + boolean that_present_query = true && that.isSetQuery(); + if (this_present_query || that_present_query) { + if (!(this_present_query && that_present_query)) + return false; + if (!this.query.equals(that.query)) + return false; + } + + boolean this_present_compression = true && this.isSetCompression(); + boolean that_present_compression = true && that.isSetCompression(); + if (this_present_compression || that_present_compression) { + if (!(this_present_compression && that_present_compression)) + return false; + if (!this.compression.equals(that.compression)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + HashCodeBuilder builder = new HashCodeBuilder(); + + boolean present_query = true && (isSetQuery()); + builder.append(present_query); + if (present_query) + builder.append(query); + + boolean present_compression = true && (isSetCompression()); + builder.append(present_compression); + if (present_compression) + builder.append(compression.getValue()); + + return builder.toHashCode(); + } + + public int compareTo(prepare_cql3_query_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + prepare_cql3_query_args typedOther = (prepare_cql3_query_args)other; + + lastComparison = Boolean.valueOf(isSetQuery()).compareTo(typedOther.isSetQuery()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetQuery()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.query, typedOther.query); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetCompression()).compareTo(typedOther.isSetCompression()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetCompression()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.compression, typedOther.compression); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField field; + iprot.readStructBegin(); + while (true) + { + field = iprot.readFieldBegin(); + if (field.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (field.id) { + case 1: // QUERY + if (field.type == org.apache.thrift.protocol.TType.STRING) { + this.query = iprot.readBinary(); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 2: // COMPRESSION + if (field.type == org.apache.thrift.protocol.TType.I32) { + this.compression = Compression.findByValue(iprot.readI32()); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (this.query != null) { + oprot.writeFieldBegin(QUERY_FIELD_DESC); + oprot.writeBinary(this.query); + oprot.writeFieldEnd(); + } + if (this.compression != null) { + oprot.writeFieldBegin(COMPRESSION_FIELD_DESC); + oprot.writeI32(this.compression.getValue()); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("prepare_cql3_query_args("); + boolean first = true; + + sb.append("query:"); + if (this.query == null) { + sb.append("null"); + } else { + org.apache.thrift.TBaseHelper.toString(this.query, sb); + } + first = false; + if (!first) sb.append(", "); + sb.append("compression:"); + if (this.compression == null) { + sb.append("null"); + } else { + sb.append(this.compression); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (query == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'query' was not present! Struct: " + toString()); + } + if (compression == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'compression' was not present! Struct: " + toString()); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + } + + public static class prepare_cql3_query_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("prepare_cql3_query_result"); + + private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0); + private static final org.apache.thrift.protocol.TField IRE_FIELD_DESC = new org.apache.thrift.protocol.TField("ire", org.apache.thrift.protocol.TType.STRUCT, (short)1); + + public CqlPreparedResult success; // required + public InvalidRequestException ire; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SUCCESS((short)0, "success"), + IRE((short)1, "ire"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + case 1: // IRE + return IRE; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, CqlPreparedResult.class))); + tmpMap.put(_Fields.IRE, new org.apache.thrift.meta_data.FieldMetaData("ire", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(prepare_cql3_query_result.class, metaDataMap); + } + + public prepare_cql3_query_result() { + } + + public prepare_cql3_query_result( + CqlPreparedResult success, + InvalidRequestException ire) + { + this(); + this.success = success; + this.ire = ire; + } + + /** + * Performs a deep copy on other. + */ + public prepare_cql3_query_result(prepare_cql3_query_result other) { + if (other.isSetSuccess()) { + this.success = new CqlPreparedResult(other.success); + } + if (other.isSetIre()) { + this.ire = new InvalidRequestException(other.ire); + } + } + + public prepare_cql3_query_result deepCopy() { + return new prepare_cql3_query_result(this); + } + + @Override + public void clear() { + this.success = null; + this.ire = null; + } + + public CqlPreparedResult getSuccess() { + return this.success; + } + + public prepare_cql3_query_result setSuccess(CqlPreparedResult success) { + this.success = success; + return this; + } + + public void unsetSuccess() { + this.success = null; + } + + /** Returns true if field success is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccess() { + return this.success != null; + } + + public void setSuccessIsSet(boolean value) { + if (!value) { + this.success = null; + } + } + + public InvalidRequestException getIre() { + return this.ire; + } + + public prepare_cql3_query_result setIre(InvalidRequestException ire) { + this.ire = ire; + return this; + } + + public void unsetIre() { + this.ire = null; + } + + /** Returns true if field ire is set (has been assigned a value) and false otherwise */ + public boolean isSetIre() { + return this.ire != null; + } + + public void setIreIsSet(boolean value) { + if (!value) { + this.ire = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((CqlPreparedResult)value); + } + break; + + case IRE: + if (value == null) { + unsetIre(); + } else { + setIre((InvalidRequestException)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return getSuccess(); + + case IRE: + return getIre(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + case IRE: + return isSetIre(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof prepare_cql3_query_result) + return this.equals((prepare_cql3_query_result)that); + return false; + } + + public boolean equals(prepare_cql3_query_result that) { + if (that == null) + return false; + + boolean this_present_success = true && this.isSetSuccess(); + boolean that_present_success = true && that.isSetSuccess(); + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (!this.success.equals(that.success)) + return false; + } + + boolean this_present_ire = true && this.isSetIre(); + boolean that_present_ire = true && that.isSetIre(); + if (this_present_ire || that_present_ire) { + if (!(this_present_ire && that_present_ire)) + return false; + if (!this.ire.equals(that.ire)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + HashCodeBuilder builder = new HashCodeBuilder(); + + boolean present_success = true && (isSetSuccess()); + builder.append(present_success); + if (present_success) + builder.append(success); + + boolean present_ire = true && (isSetIre()); + builder.append(present_ire); + if (present_ire) + builder.append(ire); + + return builder.toHashCode(); + } + + public int compareTo(prepare_cql3_query_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + prepare_cql3_query_result typedOther = (prepare_cql3_query_result)other; + + lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(typedOther.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, typedOther.success); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetIre()).compareTo(typedOther.isSetIre()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetIre()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ire, typedOther.ire); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField field; + iprot.readStructBegin(); + while (true) + { + field = iprot.readFieldBegin(); + if (field.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (field.id) { + case 0: // SUCCESS + if (field.type == org.apache.thrift.protocol.TType.STRUCT) { + this.success = new CqlPreparedResult(); + this.success.read(iprot); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 1: // IRE + if (field.type == org.apache.thrift.protocol.TType.STRUCT) { + this.ire = new InvalidRequestException(); + this.ire.read(iprot); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + oprot.writeStructBegin(STRUCT_DESC); + + if (this.isSetSuccess()) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + this.success.write(oprot); + oprot.writeFieldEnd(); + } else if (this.isSetIre()) { + oprot.writeFieldBegin(IRE_FIELD_DESC); + this.ire.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("prepare_cql3_query_result("); + boolean first = true; + + sb.append("success:"); + if (this.success == null) { + sb.append("null"); + } else { + sb.append(this.success); + } + first = false; + if (!first) sb.append(", "); + sb.append("ire:"); + if (this.ire == null) { + sb.append("null"); + } else { + sb.append(this.ire); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + } + public static class execute_prepared_cql_query_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("execute_prepared_cql_query_args"); @@ -36591,8 +38946,6 @@ public class Cassandra { private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { try { - // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. - __isset_bit_vector = new BitSet(1); read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); @@ -37281,6 +39634,1243 @@ public class Cassandra { } + public static class execute_prepared_cql3_query_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("execute_prepared_cql3_query_args"); + + private static final org.apache.thrift.protocol.TField ITEM_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("itemId", org.apache.thrift.protocol.TType.I32, (short)1); + private static final org.apache.thrift.protocol.TField VALUES_FIELD_DESC = new org.apache.thrift.protocol.TField("values", org.apache.thrift.protocol.TType.LIST, (short)2); + private static final org.apache.thrift.protocol.TField CONSISTENCY_FIELD_DESC = new org.apache.thrift.protocol.TField("consistency", org.apache.thrift.protocol.TType.I32, (short)3); + + public int itemId; // required + public List values; // required + /** + * + * @see ConsistencyLevel + */ + public ConsistencyLevel consistency; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + ITEM_ID((short)1, "itemId"), + VALUES((short)2, "values"), + /** + * + * @see ConsistencyLevel + */ + CONSISTENCY((short)3, "consistency"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // ITEM_ID + return ITEM_ID; + case 2: // VALUES + return VALUES; + case 3: // CONSISTENCY + return CONSISTENCY; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final int __ITEMID_ISSET_ID = 0; + private BitSet __isset_bit_vector = new BitSet(1); + + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.ITEM_ID, new org.apache.thrift.meta_data.FieldMetaData("itemId", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); + tmpMap.put(_Fields.VALUES, new org.apache.thrift.meta_data.FieldMetaData("values", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)))); + tmpMap.put(_Fields.CONSISTENCY, new org.apache.thrift.meta_data.FieldMetaData("consistency", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, ConsistencyLevel.class))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(execute_prepared_cql3_query_args.class, metaDataMap); + } + + public execute_prepared_cql3_query_args() { + } + + public execute_prepared_cql3_query_args( + int itemId, + List values, + ConsistencyLevel consistency) + { + this(); + this.itemId = itemId; + setItemIdIsSet(true); + this.values = values; + this.consistency = consistency; + } + + /** + * Performs a deep copy on other. + */ + public execute_prepared_cql3_query_args(execute_prepared_cql3_query_args other) { + __isset_bit_vector.clear(); + __isset_bit_vector.or(other.__isset_bit_vector); + this.itemId = other.itemId; + if (other.isSetValues()) { + List __this__values = new ArrayList(); + for (ByteBuffer other_element : other.values) { + ByteBuffer temp_binary_element = org.apache.thrift.TBaseHelper.copyBinary(other_element); +; + __this__values.add(temp_binary_element); + } + this.values = __this__values; + } + if (other.isSetConsistency()) { + this.consistency = other.consistency; + } + } + + public execute_prepared_cql3_query_args deepCopy() { + return new execute_prepared_cql3_query_args(this); + } + + @Override + public void clear() { + setItemIdIsSet(false); + this.itemId = 0; + this.values = null; + this.consistency = null; + } + + public int getItemId() { + return this.itemId; + } + + public execute_prepared_cql3_query_args setItemId(int itemId) { + this.itemId = itemId; + setItemIdIsSet(true); + return this; + } + + public void unsetItemId() { + __isset_bit_vector.clear(__ITEMID_ISSET_ID); + } + + /** Returns true if field itemId is set (has been assigned a value) and false otherwise */ + public boolean isSetItemId() { + return __isset_bit_vector.get(__ITEMID_ISSET_ID); + } + + public void setItemIdIsSet(boolean value) { + __isset_bit_vector.set(__ITEMID_ISSET_ID, value); + } + + public int getValuesSize() { + return (this.values == null) ? 0 : this.values.size(); + } + + public java.util.Iterator getValuesIterator() { + return (this.values == null) ? null : this.values.iterator(); + } + + public void addToValues(ByteBuffer elem) { + if (this.values == null) { + this.values = new ArrayList(); + } + this.values.add(elem); + } + + public List getValues() { + return this.values; + } + + public execute_prepared_cql3_query_args setValues(List values) { + this.values = values; + return this; + } + + public void unsetValues() { + this.values = null; + } + + /** Returns true if field values is set (has been assigned a value) and false otherwise */ + public boolean isSetValues() { + return this.values != null; + } + + public void setValuesIsSet(boolean value) { + if (!value) { + this.values = null; + } + } + + /** + * + * @see ConsistencyLevel + */ + public ConsistencyLevel getConsistency() { + return this.consistency; + } + + /** + * + * @see ConsistencyLevel + */ + public execute_prepared_cql3_query_args setConsistency(ConsistencyLevel consistency) { + this.consistency = consistency; + return this; + } + + public void unsetConsistency() { + this.consistency = null; + } + + /** Returns true if field consistency is set (has been assigned a value) and false otherwise */ + public boolean isSetConsistency() { + return this.consistency != null; + } + + public void setConsistencyIsSet(boolean value) { + if (!value) { + this.consistency = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case ITEM_ID: + if (value == null) { + unsetItemId(); + } else { + setItemId((Integer)value); + } + break; + + case VALUES: + if (value == null) { + unsetValues(); + } else { + setValues((List)value); + } + break; + + case CONSISTENCY: + if (value == null) { + unsetConsistency(); + } else { + setConsistency((ConsistencyLevel)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case ITEM_ID: + return Integer.valueOf(getItemId()); + + case VALUES: + return getValues(); + + case CONSISTENCY: + return getConsistency(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case ITEM_ID: + return isSetItemId(); + case VALUES: + return isSetValues(); + case CONSISTENCY: + return isSetConsistency(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof execute_prepared_cql3_query_args) + return this.equals((execute_prepared_cql3_query_args)that); + return false; + } + + public boolean equals(execute_prepared_cql3_query_args that) { + if (that == null) + return false; + + boolean this_present_itemId = true; + boolean that_present_itemId = true; + if (this_present_itemId || that_present_itemId) { + if (!(this_present_itemId && that_present_itemId)) + return false; + if (this.itemId != that.itemId) + return false; + } + + boolean this_present_values = true && this.isSetValues(); + boolean that_present_values = true && that.isSetValues(); + if (this_present_values || that_present_values) { + if (!(this_present_values && that_present_values)) + return false; + if (!this.values.equals(that.values)) + return false; + } + + boolean this_present_consistency = true && this.isSetConsistency(); + boolean that_present_consistency = true && that.isSetConsistency(); + if (this_present_consistency || that_present_consistency) { + if (!(this_present_consistency && that_present_consistency)) + return false; + if (!this.consistency.equals(that.consistency)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + HashCodeBuilder builder = new HashCodeBuilder(); + + boolean present_itemId = true; + builder.append(present_itemId); + if (present_itemId) + builder.append(itemId); + + boolean present_values = true && (isSetValues()); + builder.append(present_values); + if (present_values) + builder.append(values); + + boolean present_consistency = true && (isSetConsistency()); + builder.append(present_consistency); + if (present_consistency) + builder.append(consistency.getValue()); + + return builder.toHashCode(); + } + + public int compareTo(execute_prepared_cql3_query_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + execute_prepared_cql3_query_args typedOther = (execute_prepared_cql3_query_args)other; + + lastComparison = Boolean.valueOf(isSetItemId()).compareTo(typedOther.isSetItemId()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetItemId()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.itemId, typedOther.itemId); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetValues()).compareTo(typedOther.isSetValues()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetValues()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.values, typedOther.values); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetConsistency()).compareTo(typedOther.isSetConsistency()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetConsistency()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.consistency, typedOther.consistency); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField field; + iprot.readStructBegin(); + while (true) + { + field = iprot.readFieldBegin(); + if (field.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (field.id) { + case 1: // ITEM_ID + if (field.type == org.apache.thrift.protocol.TType.I32) { + this.itemId = iprot.readI32(); + setItemIdIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 2: // VALUES + if (field.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list191 = iprot.readListBegin(); + this.values = new ArrayList(_list191.size); + for (int _i192 = 0; _i192 < _list191.size; ++_i192) + { + ByteBuffer _elem193; // required + _elem193 = iprot.readBinary(); + this.values.add(_elem193); + } + iprot.readListEnd(); + } + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 3: // CONSISTENCY + if (field.type == org.apache.thrift.protocol.TType.I32) { + this.consistency = ConsistencyLevel.findByValue(iprot.readI32()); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + if (!isSetItemId()) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'itemId' was not found in serialized data! Struct: " + toString()); + } + validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + validate(); + + oprot.writeStructBegin(STRUCT_DESC); + oprot.writeFieldBegin(ITEM_ID_FIELD_DESC); + oprot.writeI32(this.itemId); + oprot.writeFieldEnd(); + if (this.values != null) { + oprot.writeFieldBegin(VALUES_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, this.values.size())); + for (ByteBuffer _iter194 : this.values) + { + oprot.writeBinary(_iter194); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + if (this.consistency != null) { + oprot.writeFieldBegin(CONSISTENCY_FIELD_DESC); + oprot.writeI32(this.consistency.getValue()); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("execute_prepared_cql3_query_args("); + boolean first = true; + + sb.append("itemId:"); + sb.append(this.itemId); + first = false; + if (!first) sb.append(", "); + sb.append("values:"); + if (this.values == null) { + sb.append("null"); + } else { + sb.append(this.values); + } + first = false; + if (!first) sb.append(", "); + sb.append("consistency:"); + if (this.consistency == null) { + sb.append("null"); + } else { + sb.append(this.consistency); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // alas, we cannot check 'itemId' because it's a primitive and you chose the non-beans generator. + if (values == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'values' was not present! Struct: " + toString()); + } + if (consistency == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'consistency' was not present! Struct: " + toString()); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. + __isset_bit_vector = new BitSet(1); + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + } + + public static class execute_prepared_cql3_query_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("execute_prepared_cql3_query_result"); + + private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0); + private static final org.apache.thrift.protocol.TField IRE_FIELD_DESC = new org.apache.thrift.protocol.TField("ire", org.apache.thrift.protocol.TType.STRUCT, (short)1); + private static final org.apache.thrift.protocol.TField UE_FIELD_DESC = new org.apache.thrift.protocol.TField("ue", org.apache.thrift.protocol.TType.STRUCT, (short)2); + private static final org.apache.thrift.protocol.TField TE_FIELD_DESC = new org.apache.thrift.protocol.TField("te", org.apache.thrift.protocol.TType.STRUCT, (short)3); + private static final org.apache.thrift.protocol.TField SDE_FIELD_DESC = new org.apache.thrift.protocol.TField("sde", org.apache.thrift.protocol.TType.STRUCT, (short)4); + + public CqlResult success; // required + public InvalidRequestException ire; // required + public UnavailableException ue; // required + public TimedOutException te; // required + public SchemaDisagreementException sde; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SUCCESS((short)0, "success"), + IRE((short)1, "ire"), + UE((short)2, "ue"), + TE((short)3, "te"), + SDE((short)4, "sde"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + case 1: // IRE + return IRE; + case 2: // UE + return UE; + case 3: // TE + return TE; + case 4: // SDE + return SDE; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, CqlResult.class))); + tmpMap.put(_Fields.IRE, new org.apache.thrift.meta_data.FieldMetaData("ire", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT))); + tmpMap.put(_Fields.UE, new org.apache.thrift.meta_data.FieldMetaData("ue", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT))); + tmpMap.put(_Fields.TE, new org.apache.thrift.meta_data.FieldMetaData("te", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT))); + tmpMap.put(_Fields.SDE, new org.apache.thrift.meta_data.FieldMetaData("sde", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(execute_prepared_cql3_query_result.class, metaDataMap); + } + + public execute_prepared_cql3_query_result() { + } + + public execute_prepared_cql3_query_result( + CqlResult success, + InvalidRequestException ire, + UnavailableException ue, + TimedOutException te, + SchemaDisagreementException sde) + { + this(); + this.success = success; + this.ire = ire; + this.ue = ue; + this.te = te; + this.sde = sde; + } + + /** + * Performs a deep copy on other. + */ + public execute_prepared_cql3_query_result(execute_prepared_cql3_query_result other) { + if (other.isSetSuccess()) { + this.success = new CqlResult(other.success); + } + if (other.isSetIre()) { + this.ire = new InvalidRequestException(other.ire); + } + if (other.isSetUe()) { + this.ue = new UnavailableException(other.ue); + } + if (other.isSetTe()) { + this.te = new TimedOutException(other.te); + } + if (other.isSetSde()) { + this.sde = new SchemaDisagreementException(other.sde); + } + } + + public execute_prepared_cql3_query_result deepCopy() { + return new execute_prepared_cql3_query_result(this); + } + + @Override + public void clear() { + this.success = null; + this.ire = null; + this.ue = null; + this.te = null; + this.sde = null; + } + + public CqlResult getSuccess() { + return this.success; + } + + public execute_prepared_cql3_query_result setSuccess(CqlResult success) { + this.success = success; + return this; + } + + public void unsetSuccess() { + this.success = null; + } + + /** Returns true if field success is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccess() { + return this.success != null; + } + + public void setSuccessIsSet(boolean value) { + if (!value) { + this.success = null; + } + } + + public InvalidRequestException getIre() { + return this.ire; + } + + public execute_prepared_cql3_query_result setIre(InvalidRequestException ire) { + this.ire = ire; + return this; + } + + public void unsetIre() { + this.ire = null; + } + + /** Returns true if field ire is set (has been assigned a value) and false otherwise */ + public boolean isSetIre() { + return this.ire != null; + } + + public void setIreIsSet(boolean value) { + if (!value) { + this.ire = null; + } + } + + public UnavailableException getUe() { + return this.ue; + } + + public execute_prepared_cql3_query_result setUe(UnavailableException ue) { + this.ue = ue; + return this; + } + + public void unsetUe() { + this.ue = null; + } + + /** Returns true if field ue is set (has been assigned a value) and false otherwise */ + public boolean isSetUe() { + return this.ue != null; + } + + public void setUeIsSet(boolean value) { + if (!value) { + this.ue = null; + } + } + + public TimedOutException getTe() { + return this.te; + } + + public execute_prepared_cql3_query_result setTe(TimedOutException te) { + this.te = te; + return this; + } + + public void unsetTe() { + this.te = null; + } + + /** Returns true if field te is set (has been assigned a value) and false otherwise */ + public boolean isSetTe() { + return this.te != null; + } + + public void setTeIsSet(boolean value) { + if (!value) { + this.te = null; + } + } + + public SchemaDisagreementException getSde() { + return this.sde; + } + + public execute_prepared_cql3_query_result setSde(SchemaDisagreementException sde) { + this.sde = sde; + return this; + } + + public void unsetSde() { + this.sde = null; + } + + /** Returns true if field sde is set (has been assigned a value) and false otherwise */ + public boolean isSetSde() { + return this.sde != null; + } + + public void setSdeIsSet(boolean value) { + if (!value) { + this.sde = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((CqlResult)value); + } + break; + + case IRE: + if (value == null) { + unsetIre(); + } else { + setIre((InvalidRequestException)value); + } + break; + + case UE: + if (value == null) { + unsetUe(); + } else { + setUe((UnavailableException)value); + } + break; + + case TE: + if (value == null) { + unsetTe(); + } else { + setTe((TimedOutException)value); + } + break; + + case SDE: + if (value == null) { + unsetSde(); + } else { + setSde((SchemaDisagreementException)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return getSuccess(); + + case IRE: + return getIre(); + + case UE: + return getUe(); + + case TE: + return getTe(); + + case SDE: + return getSde(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + case IRE: + return isSetIre(); + case UE: + return isSetUe(); + case TE: + return isSetTe(); + case SDE: + return isSetSde(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof execute_prepared_cql3_query_result) + return this.equals((execute_prepared_cql3_query_result)that); + return false; + } + + public boolean equals(execute_prepared_cql3_query_result that) { + if (that == null) + return false; + + boolean this_present_success = true && this.isSetSuccess(); + boolean that_present_success = true && that.isSetSuccess(); + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (!this.success.equals(that.success)) + return false; + } + + boolean this_present_ire = true && this.isSetIre(); + boolean that_present_ire = true && that.isSetIre(); + if (this_present_ire || that_present_ire) { + if (!(this_present_ire && that_present_ire)) + return false; + if (!this.ire.equals(that.ire)) + return false; + } + + boolean this_present_ue = true && this.isSetUe(); + boolean that_present_ue = true && that.isSetUe(); + if (this_present_ue || that_present_ue) { + if (!(this_present_ue && that_present_ue)) + return false; + if (!this.ue.equals(that.ue)) + return false; + } + + boolean this_present_te = true && this.isSetTe(); + boolean that_present_te = true && that.isSetTe(); + if (this_present_te || that_present_te) { + if (!(this_present_te && that_present_te)) + return false; + if (!this.te.equals(that.te)) + return false; + } + + boolean this_present_sde = true && this.isSetSde(); + boolean that_present_sde = true && that.isSetSde(); + if (this_present_sde || that_present_sde) { + if (!(this_present_sde && that_present_sde)) + return false; + if (!this.sde.equals(that.sde)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + HashCodeBuilder builder = new HashCodeBuilder(); + + boolean present_success = true && (isSetSuccess()); + builder.append(present_success); + if (present_success) + builder.append(success); + + boolean present_ire = true && (isSetIre()); + builder.append(present_ire); + if (present_ire) + builder.append(ire); + + boolean present_ue = true && (isSetUe()); + builder.append(present_ue); + if (present_ue) + builder.append(ue); + + boolean present_te = true && (isSetTe()); + builder.append(present_te); + if (present_te) + builder.append(te); + + boolean present_sde = true && (isSetSde()); + builder.append(present_sde); + if (present_sde) + builder.append(sde); + + return builder.toHashCode(); + } + + public int compareTo(execute_prepared_cql3_query_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + execute_prepared_cql3_query_result typedOther = (execute_prepared_cql3_query_result)other; + + lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(typedOther.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, typedOther.success); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetIre()).compareTo(typedOther.isSetIre()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetIre()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ire, typedOther.ire); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetUe()).compareTo(typedOther.isSetUe()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetUe()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ue, typedOther.ue); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetTe()).compareTo(typedOther.isSetTe()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetTe()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.te, typedOther.te); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetSde()).compareTo(typedOther.isSetSde()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSde()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sde, typedOther.sde); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField field; + iprot.readStructBegin(); + while (true) + { + field = iprot.readFieldBegin(); + if (field.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (field.id) { + case 0: // SUCCESS + if (field.type == org.apache.thrift.protocol.TType.STRUCT) { + this.success = new CqlResult(); + this.success.read(iprot); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 1: // IRE + if (field.type == org.apache.thrift.protocol.TType.STRUCT) { + this.ire = new InvalidRequestException(); + this.ire.read(iprot); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 2: // UE + if (field.type == org.apache.thrift.protocol.TType.STRUCT) { + this.ue = new UnavailableException(); + this.ue.read(iprot); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 3: // TE + if (field.type == org.apache.thrift.protocol.TType.STRUCT) { + this.te = new TimedOutException(); + this.te.read(iprot); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 4: // SDE + if (field.type == org.apache.thrift.protocol.TType.STRUCT) { + this.sde = new SchemaDisagreementException(); + this.sde.read(iprot); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + oprot.writeStructBegin(STRUCT_DESC); + + if (this.isSetSuccess()) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + this.success.write(oprot); + oprot.writeFieldEnd(); + } else if (this.isSetIre()) { + oprot.writeFieldBegin(IRE_FIELD_DESC); + this.ire.write(oprot); + oprot.writeFieldEnd(); + } else if (this.isSetUe()) { + oprot.writeFieldBegin(UE_FIELD_DESC); + this.ue.write(oprot); + oprot.writeFieldEnd(); + } else if (this.isSetTe()) { + oprot.writeFieldBegin(TE_FIELD_DESC); + this.te.write(oprot); + oprot.writeFieldEnd(); + } else if (this.isSetSde()) { + oprot.writeFieldBegin(SDE_FIELD_DESC); + this.sde.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("execute_prepared_cql3_query_result("); + boolean first = true; + + sb.append("success:"); + if (this.success == null) { + sb.append("null"); + } else { + sb.append(this.success); + } + first = false; + if (!first) sb.append(", "); + sb.append("ire:"); + if (this.ire == null) { + sb.append("null"); + } else { + sb.append(this.ire); + } + first = false; + if (!first) sb.append(", "); + sb.append("ue:"); + if (this.ue == null) { + sb.append("null"); + } else { + sb.append(this.ue); + } + first = false; + if (!first) sb.append(", "); + sb.append("te:"); + if (this.te == null) { + sb.append("null"); + } else { + sb.append(this.te); + } + first = false; + if (!first) sb.append(", "); + sb.append("sde:"); + if (this.sde == null) { + sb.append("null"); + } else { + sb.append(this.sde); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + } + public static class set_cql_version_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("set_cql_version_args"); diff --git a/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java b/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java index 1810548a53..8721462dc5 100644 --- a/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java +++ b/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java @@ -44,6 +44,6 @@ import org.slf4j.LoggerFactory; public class Constants { - public static final String VERSION = "19.34.0"; + public static final String VERSION = "19.35.0"; } diff --git a/interface/thrift/gen-java/org/apache/cassandra/thrift/TimedOutException.java b/interface/thrift/gen-java/org/apache/cassandra/thrift/TimedOutException.java index 0a53222924..8c793c2a99 100644 --- a/interface/thrift/gen-java/org/apache/cassandra/thrift/TimedOutException.java +++ b/interface/thrift/gen-java/org/apache/cassandra/thrift/TimedOutException.java @@ -461,8 +461,6 @@ public class TimedOutException extends Exception implements org.apache.thrift.TB private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { try { - // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. - __isset_bit_vector = new BitSet(1); read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); diff --git a/src/java/org/apache/cassandra/config/CFMetaData.java b/src/java/org/apache/cassandra/config/CFMetaData.java index fe44b5498e..fb5681b4cb 100644 --- a/src/java/org/apache/cassandra/config/CFMetaData.java +++ b/src/java/org/apache/cassandra/config/CFMetaData.java @@ -259,11 +259,6 @@ public final class CFMetaData public volatile CompressionParameters compressionParameters; - // Default consistency levels for CQL3. The default for those values is ONE, - // but we keep the internal default to null as it help handling thrift compatibility - private volatile ConsistencyLevel readConsistencyLevel; - private volatile ConsistencyLevel writeConsistencyLevel; - // Processed infos used by CQL. This can be fully reconstructed from the CFMedata, // so it's not saved on disk. It is however costlyish to recreate for each query // so we cache it here (and update on each relevant CFMetadata change) @@ -287,8 +282,6 @@ public final class CFMetaData public CFMetaData compressionParameters(CompressionParameters prop) {compressionParameters = prop; return this;} public CFMetaData bloomFilterFpChance(Double prop) {bloomFilterFpChance = prop; return this;} public CFMetaData caching(Caching prop) {caching = prop; return this;} - public CFMetaData defaultReadCL(ConsistencyLevel prop) {readConsistencyLevel = prop; return this;} - public CFMetaData defaultWriteCL(ConsistencyLevel prop) {writeConsistencyLevel = prop; return this;} public CFMetaData(String keyspace, String name, ColumnFamilyType type, AbstractType comp, AbstractType subcc) { @@ -454,9 +447,7 @@ public final class CFMetaData .compactionStrategyOptions(oldCFMD.compactionStrategyOptions) .compressionParameters(oldCFMD.compressionParameters) .bloomFilterFpChance(oldCFMD.bloomFilterFpChance) - .caching(oldCFMD.caching) - .defaultReadCL(oldCFMD.readConsistencyLevel) - .defaultWriteCL(oldCFMD.writeConsistencyLevel); + .caching(oldCFMD.caching); } /** @@ -542,16 +533,6 @@ public final class CFMetaData return valueAlias; } - public ConsistencyLevel getReadConsistencyLevel() - { - return readConsistencyLevel == null ? ConsistencyLevel.ONE : readConsistencyLevel; - } - - public ConsistencyLevel getWriteConsistencyLevel() - { - return writeConsistencyLevel == null ? ConsistencyLevel.ONE : writeConsistencyLevel; - } - public CompressionParameters compressionParameters() { return compressionParameters; @@ -614,8 +595,6 @@ public final class CFMetaData .append(compressionParameters, rhs.compressionParameters) .append(bloomFilterFpChance, rhs.bloomFilterFpChance) .append(caching, rhs.caching) - .append(readConsistencyLevel, rhs.readConsistencyLevel) - .append(writeConsistencyLevel, rhs.writeConsistencyLevel) .isEquals(); } @@ -646,8 +625,6 @@ public final class CFMetaData .append(compressionParameters) .append(bloomFilterFpChance) .append(caching) - .append(readConsistencyLevel) - .append(writeConsistencyLevel) .toHashCode(); } @@ -836,10 +813,6 @@ public final class CFMetaData } if (cfm.valueAlias != null) valueAlias = cfm.valueAlias; - if (cfm.readConsistencyLevel != null) - readConsistencyLevel = cfm.readConsistencyLevel; - if (cfm.writeConsistencyLevel != null) - writeConsistencyLevel = cfm.writeConsistencyLevel; bloomFilterFpChance = cfm.bloomFilterFpChance; caching = cfm.caching; @@ -1331,10 +1304,6 @@ public final class CFMetaData : Column.create(valueAlias, timestamp, cfName, "value_alias")); cf.addColumn(Column.create(json(aliasesAsStrings(columnAliases)), timestamp, cfName, "column_aliases")); cf.addColumn(Column.create(json(compactionStrategyOptions), timestamp, cfName, "compaction_strategy_options")); - cf.addColumn(readConsistencyLevel == null ? DeletedColumn.create(ldt, timestamp, cfName, "default_read_consistency") - : Column.create(readConsistencyLevel.toString(), timestamp, cfName, "default_read_consistency")); - cf.addColumn(writeConsistencyLevel == null ? DeletedColumn.create(ldt, timestamp, cfName, "default_write_consistency") - : Column.create(writeConsistencyLevel.toString(), timestamp, cfName, "default_write_consistency")); } // Package protected for use by tests @@ -1379,10 +1348,6 @@ public final class CFMetaData if (result.has("value_alias")) cfm.valueAlias(result.getBytes("value_alias")); cfm.compactionStrategyOptions(fromJsonMap(result.getString("compaction_strategy_options"))); - if (result.has("default_read_consistency")) - cfm.defaultReadCL(Enum.valueOf(ConsistencyLevel.class, result.getString("default_read_consistency"))); - if (result.has("default_write_consistency")) - cfm.defaultWriteCL(Enum.valueOf(ConsistencyLevel.class, result.getString("default_write_consistency"))); return cfm; } @@ -1546,8 +1511,6 @@ public final class CFMetaData .append("compressionOptions", compressionParameters.asThriftOptions()) .append("bloomFilterFpChance", bloomFilterFpChance) .append("caching", caching) - .append("readConsistencyLevel", readConsistencyLevel) - .append("writeConsistencyLevel", writeConsistencyLevel) .toString(); } } diff --git a/src/java/org/apache/cassandra/cql3/Attributes.java b/src/java/org/apache/cassandra/cql3/Attributes.java index 00fd30be69..6733d0df5b 100644 --- a/src/java/org/apache/cassandra/cql3/Attributes.java +++ b/src/java/org/apache/cassandra/cql3/Attributes.java @@ -25,7 +25,6 @@ import org.apache.cassandra.db.ConsistencyLevel; */ public class Attributes { - public ConsistencyLevel cLevel; public Long timestamp; public int timeToLive; } diff --git a/src/java/org/apache/cassandra/cql3/CFPropDefs.java b/src/java/org/apache/cassandra/cql3/CFPropDefs.java index cb78db0a46..53a5bc6643 100644 --- a/src/java/org/apache/cassandra/cql3/CFPropDefs.java +++ b/src/java/org/apache/cassandra/cql3/CFPropDefs.java @@ -48,8 +48,6 @@ public class CFPropDefs extends PropertyDefinitions public static final String KW_REPLICATEONWRITE = "replicate_on_write"; public static final String KW_CACHING = "caching"; public static final String KW_BF_FP_CHANCE = "bloom_filter_fp_chance"; - public static final String KW_DEFAULT_R_CONSISTENCY = "default_read_consistency"; - public static final String KW_DEFAULT_W_CONSISTENCY = "default_write_consistency"; public static final String KW_COMPACTION = "compaction"; public static final String KW_COMPRESSION = "compression"; @@ -70,8 +68,6 @@ public class CFPropDefs extends PropertyDefinitions keywords.add(KW_BF_FP_CHANCE); keywords.add(KW_COMPACTION); keywords.add(KW_COMPRESSION); - keywords.add(KW_DEFAULT_W_CONSISTENCY); - keywords.add(KW_DEFAULT_R_CONSISTENCY); obsoleteKeywords.add("compaction_strategy_class"); obsoleteKeywords.add("compaction_strategy_options"); @@ -143,26 +139,6 @@ public class CFPropDefs extends PropertyDefinitions if (!getCompressionOptions().isEmpty()) cfm.compressionParameters(CompressionParameters.create(getCompressionOptions())); - - try - { - ConsistencyLevel readCL = getConsistencyLevel(KW_DEFAULT_R_CONSISTENCY); - if (readCL != null) - { - readCL.validateForRead(cfm.ksName); - cfm.defaultReadCL(readCL); - } - ConsistencyLevel writeCL = getConsistencyLevel(KW_DEFAULT_W_CONSISTENCY); - if (writeCL != null) - { - writeCL.validateForWrite(cfm.ksName); - cfm.defaultWriteCL(writeCL); - } - } - catch (InvalidRequestException e) - { - throw new ConfigurationException(e.getMessage(), e.getCause()); - } } public ConsistencyLevel getConsistencyLevel(String key) throws ConfigurationException, SyntaxException diff --git a/src/java/org/apache/cassandra/cql3/CQLStatement.java b/src/java/org/apache/cassandra/cql3/CQLStatement.java index 00fb406e4b..90883e6c5f 100644 --- a/src/java/org/apache/cassandra/cql3/CQLStatement.java +++ b/src/java/org/apache/cassandra/cql3/CQLStatement.java @@ -20,6 +20,7 @@ package org.apache.cassandra.cql3; import java.nio.ByteBuffer; import java.util.List; +import org.apache.cassandra.db.ConsistencyLevel; import org.apache.cassandra.transport.messages.ResultMessage; import org.apache.cassandra.service.ClientState; import org.apache.cassandra.exceptions.*; @@ -53,7 +54,7 @@ public interface CQLStatement * @param variables the values for bounded variables. The implementation * can assume that each bound term have a corresponding value. */ - public ResultMessage execute(ClientState state, List variables) throws RequestValidationException, RequestExecutionException; + public ResultMessage execute(ConsistencyLevel cl, ClientState state, List variables) throws RequestValidationException, RequestExecutionException; /** * Variante of execute used for internal query against the system tables, and thus only query the local node. diff --git a/src/java/org/apache/cassandra/cql3/Cql.g b/src/java/org/apache/cassandra/cql3/Cql.g index 320e934d91..76f2509e45 100644 --- a/src/java/org/apache/cassandra/cql3/Cql.g +++ b/src/java/org/apache/cassandra/cql3/Cql.g @@ -42,7 +42,6 @@ options { import org.apache.cassandra.exceptions.InvalidRequestException; import org.apache.cassandra.exceptions.SyntaxException; import org.apache.cassandra.utils.Pair; - import org.apache.cassandra.db.ConsistencyLevel; } @members { @@ -189,19 +188,16 @@ useStatement returns [UseStatement stmt] selectStatement returns [SelectStatement.RawStatement expr] @init { boolean isCount = false; - ConsistencyLevel cLevel = null; int limit = 10000; Map orderings = new LinkedHashMap(); } : K_SELECT ( sclause=selectClause | (K_COUNT '(' sclause=selectCountClause ')' { isCount = true; }) ) K_FROM cf=columnFamilyName - ( K_USING K_CONSISTENCY K_LEVEL { cLevel = ConsistencyLevel.valueOf($K_LEVEL.text.toUpperCase()); } )? ( K_WHERE wclause=whereClause )? ( K_ORDER K_BY orderByClause[orderings] ( ',' orderByClause[orderings] )* )? ( K_LIMIT rows=INTEGER { limit = Integer.parseInt($rows.text); } )? { - SelectStatement.Parameters params = new SelectStatement.Parameters(cLevel, - limit, + SelectStatement.Parameters params = new SelectStatement.Parameters(limit, orderings, isCount); $expr = new SelectStatement.RawStatement(cf, params, sclause, wclause); @@ -240,9 +236,8 @@ orderByClause[Map orderings] /** * INSERT INTO (, , , ...) * VALUES (, , , ...) - * USING CONSISTENCY AND TIMESTAMP ; + * USING TIMESTAMP ; * - * Consistency level is set to ONE by default */ insertStatement returns [UpdateStatement expr] @init { @@ -269,8 +264,7 @@ usingClauseDelete[Attributes attrs] ; usingClauseDeleteObjective[Attributes attrs] - : K_CONSISTENCY K_LEVEL { attrs.cLevel = ConsistencyLevel.valueOf($K_LEVEL.text.toUpperCase()); } - | K_TIMESTAMP ts=INTEGER { attrs.timestamp = Long.valueOf($ts.text); } + : K_TIMESTAMP ts=INTEGER { attrs.timestamp = Long.valueOf($ts.text); } ; usingClauseObjective[Attributes attrs] @@ -727,7 +721,6 @@ collection_type returns [ParsedType pt] unreserved_keyword returns [String str] : k=( K_KEY - | K_CONSISTENCY | K_CLUSTERING | K_LEVEL | K_COUNT @@ -755,7 +748,6 @@ K_UPDATE: U P D A T E; K_WITH: W I T H; K_LIMIT: L I M I T; K_USING: U S I N G; -K_CONSISTENCY: C O N S I S T E N C Y; K_LEVEL: ( O N E | Q U O R U M | A L L diff --git a/src/java/org/apache/cassandra/cql3/QueryProcessor.java b/src/java/org/apache/cassandra/cql3/QueryProcessor.java index 58a8f44975..ce9dfec2fa 100644 --- a/src/java/org/apache/cassandra/cql3/QueryProcessor.java +++ b/src/java/org/apache/cassandra/cql3/QueryProcessor.java @@ -122,20 +122,20 @@ public class QueryProcessor } } - private static ResultMessage processStatement(CQLStatement statement, ClientState clientState, List variables) + private static ResultMessage processStatement(CQLStatement statement, ConsistencyLevel cl, ClientState clientState, List variables) throws RequestExecutionException, RequestValidationException { statement.checkAccess(clientState); statement.validate(clientState); - ResultMessage result = statement.execute(clientState, variables); + ResultMessage result = statement.execute(cl, clientState, variables); return result == null ? ResultMessage.Void.instance() : result; } - public static ResultMessage process(String queryString, ClientState clientState) + public static ResultMessage process(String queryString, ConsistencyLevel cl, ClientState clientState) throws RequestExecutionException, RequestValidationException { logger.trace("CQL QUERY: {}", queryString); - return processStatement(getStatement(queryString, clientState).statement, clientState, Collections.emptyList()); + return processStatement(getStatement(queryString, clientState).statement, cl, clientState, Collections.emptyList()); } public static UntypedResultSet processInternal(String query) @@ -210,7 +210,7 @@ public class QueryProcessor } } - public static ResultMessage processPrepared(CQLStatement statement, ClientState clientState, List variables) + public static ResultMessage processPrepared(CQLStatement statement, ConsistencyLevel cl, ClientState clientState, List variables) throws RequestExecutionException, RequestValidationException { // Check to see if there are any bound variables to verify @@ -228,7 +228,7 @@ public class QueryProcessor logger.trace("[{}] '{}'", i+1, variables.get(i)); } - return processStatement(statement, clientState, variables); + return processStatement(statement, cl, clientState, variables); } private static ParsedStatement.Prepared getStatement(String queryStr, ClientState clientState) diff --git a/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java b/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java index 92c708b335..41f4f7694d 100644 --- a/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java +++ b/src/java/org/apache/cassandra/cql3/statements/BatchStatement.java @@ -22,6 +22,7 @@ import java.util.*; import org.apache.cassandra.auth.Permission; import org.apache.cassandra.cql3.*; +import org.apache.cassandra.config.Schema; import org.apache.cassandra.db.ConsistencyLevel; import org.apache.cassandra.db.CounterMutation; import org.apache.cassandra.db.IMutation; @@ -78,49 +79,28 @@ public class BatchStatement extends ModificationStatement } } - @Override - public ConsistencyLevel getConsistencyLevel() - { - // We have validated that either the consistency is set, or all statements have the same default CL (see validate()) - return isSetConsistencyLevel() - ? super.getConsistencyLevel() - : (statements.isEmpty() ? ConsistencyLevel.ONE : statements.get(0).getConsistencyLevel()); - } - public void validate(ClientState state) throws InvalidRequestException { if (getTimeToLive() != 0) throw new InvalidRequestException("Global TTL on the BATCH statement is not supported."); - ConsistencyLevel cLevel = null; for (ModificationStatement statement : statements) { - if (statement.isSetConsistencyLevel()) - throw new InvalidRequestException("Consistency level must be set on the BATCH, not individual statements"); - if (isSetTimestamp() && statement.isSetTimestamp()) throw new InvalidRequestException("Timestamp must be set either on BATCH or individual statements"); if (statement.getTimeToLive() < 0) throw new InvalidRequestException("A TTL must be greater or equal to 0"); - - if (isSetConsistencyLevel()) - { - getConsistencyLevel().validateForWrite(statement.keyspace()); - } - else - { - // If no consistency is set for the batch, we need all the CF in the batch to have the same default consistency level, - // otherwise the batch is invalid (i.e. the user must explicitely set the CL) - ConsistencyLevel stmtCL = statement.getConsistencyLevel(); - if (cLevel != null && cLevel != stmtCL) - throw new InvalidRequestException("The tables involved in the BATCH have different default write consistency, you must explicitely set the BATCH consitency level with USING CONSISTENCY"); - cLevel = stmtCL; - } } } - public Collection getMutations(ClientState clientState, List variables, boolean local) + protected void validateConsistency(ConsistencyLevel cl) throws InvalidRequestException + { + for (ModificationStatement statement : statements) + statement.validateConsistency(cl); + } + + public Collection getMutations(ClientState clientState, List variables, boolean local, ConsistencyLevel cl) throws RequestExecutionException, RequestValidationException { Map, IMutation> mutations = new HashMap, IMutation>(); @@ -130,7 +110,7 @@ public class BatchStatement extends ModificationStatement statement.setTimestamp(getTimestamp(clientState)); // Group mutation together, otherwise they won't get applied atomically - for (IMutation m : statement.getMutations(clientState, variables, local)) + for (IMutation m : statement.getMutations(clientState, variables, local, cl)) { if (m instanceof CounterMutation && type != Type.COUNTER) throw new InvalidRequestException("Counter mutations are only allowed in COUNTER batches"); @@ -169,6 +149,6 @@ public class BatchStatement extends ModificationStatement public String toString() { - return String.format("BatchStatement(type=%s, statements=%s, consistency=%s)", type, statements, getConsistencyLevel()); + return String.format("BatchStatement(type=%s, statements=%s)", type, statements); } } diff --git a/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java b/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java index 86af858004..c7d32b1284 100644 --- a/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java +++ b/src/java/org/apache/cassandra/cql3/statements/DeleteStatement.java @@ -26,6 +26,7 @@ import org.apache.cassandra.cql3.operations.ListOperation; import org.apache.cassandra.cql3.operations.MapOperation; import org.apache.cassandra.cql3.operations.Operation; import org.apache.cassandra.cql3.operations.SetOperation; +import org.apache.cassandra.db.ConsistencyLevel; import org.apache.cassandra.db.ColumnFamily; import org.apache.cassandra.db.DeletionInfo; import org.apache.cassandra.db.RowMutation; @@ -60,7 +61,15 @@ public class DeleteStatement extends ModificationStatement this.toRemove = new ArrayList>(columns.size()); } - public Collection getMutations(ClientState clientState, List variables, boolean local) + protected void validateConsistency(ConsistencyLevel cl) throws InvalidRequestException + { + if (type == Type.COUNTER) + cl.validateCounterForWrite(cfDef.cfm); + else + cl.validateForWrite(cfDef.cfm.ksName); + } + + public Collection getMutations(ClientState clientState, List variables, boolean local, ConsistencyLevel cl) throws RequestExecutionException, RequestValidationException { // keys @@ -90,7 +99,7 @@ public class DeleteStatement extends ModificationStatement } } - Map rows = needsReading ? readRows(keys, builder, (CompositeType)cfDef.cfm.comparator, local) : null; + Map rows = needsReading ? readRows(keys, builder, (CompositeType)cfDef.cfm.comparator, local, cl) : null; Collection rowMutations = new ArrayList(keys.size()); UpdateParameters params = new UpdateParameters(variables, getTimestamp(clientState), -1); @@ -228,10 +237,9 @@ public class DeleteStatement extends ModificationStatement public String toString() { - return String.format("DeleteStatement(name=%s, columns=%s, consistency=%s keys=%s)", + return String.format("DeleteStatement(name=%s, columns=%s, keys=%s)", cfName, columns, - getConsistencyLevel(), whereClause); } } diff --git a/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java b/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java index 9f335a7cb4..6e92ec2340 100644 --- a/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java +++ b/src/java/org/apache/cassandra/cql3/statements/ModificationStatement.java @@ -51,19 +51,17 @@ public abstract class ModificationStatement extends CFStatement implements CQLSt protected Type type; - private final ConsistencyLevel cLevel; private Long timestamp; private final int timeToLive; public ModificationStatement(CFName name, Attributes attrs) { - this(name, attrs.cLevel, attrs.timestamp, attrs.timeToLive); + this(name, attrs.timestamp, attrs.timeToLive); } - public ModificationStatement(CFName name, ConsistencyLevel cLevel, Long timestamp, int timeToLive) + public ModificationStatement(CFName name, Long timestamp, int timeToLive) { super(name); - this.cLevel = cLevel; this.timestamp = timestamp; this.timeToLive = timeToLive; } @@ -80,14 +78,18 @@ public abstract class ModificationStatement extends CFStatement implements CQLSt if (timeToLive > ExpiringColumn.MAX_TTL) throw new InvalidRequestException(String.format("ttl is too large. requested (%d) maximum (%d)", timeToLive, ExpiringColumn.MAX_TTL)); - - getConsistencyLevel().validateForWrite(keyspace()); } - public ResultMessage execute(ClientState state, List variables) throws RequestExecutionException, RequestValidationException + protected abstract void validateConsistency(ConsistencyLevel cl) throws InvalidRequestException; + + public ResultMessage execute(ConsistencyLevel cl, ClientState state, List variables) throws RequestExecutionException, RequestValidationException { - Collection mutations = getMutations(state, variables, false); - ConsistencyLevel cl = getConsistencyLevel(); + if (cl == null) + throw new InvalidRequestException("Invalid empty consistency level"); + + validateConsistency(cl); + + Collection mutations = getMutations(state, variables, false, cl); // The type should have been set by now or we have a bug assert type != null; @@ -111,33 +113,13 @@ public abstract class ModificationStatement extends CFStatement implements CQLSt return null; } - public ResultMessage executeInternal(ClientState state) throws RequestValidationException, RequestExecutionException { - for (IMutation mutation : getMutations(state, Collections.emptyList(), true)) + for (IMutation mutation : getMutations(state, Collections.emptyList(), true, null)) mutation.apply(); return null; } - public ConsistencyLevel getConsistencyLevel() - { - if (cLevel != null) - return cLevel; - - CFMetaData cfm = Schema.instance.getCFMetaData(keyspace(), columnFamily()); - return cfm == null ? ConsistencyLevel.ONE : cfm.getWriteConsistencyLevel(); - } - - /** - * True if an explicit consistency level was parsed from the statement. - * - * @return true if a consistency was parsed, false otherwise. - */ - public boolean isSetConsistencyLevel() - { - return cLevel != null; - } - public long getTimestamp(ClientState clientState) { return timestamp == null ? clientState.getTimestamp() : timestamp; @@ -158,9 +140,18 @@ public abstract class ModificationStatement extends CFStatement implements CQLSt return timeToLive; } - protected Map readRows(List keys, ColumnNameBuilder builder, CompositeType composite, boolean local) + protected Map readRows(List keys, ColumnNameBuilder builder, CompositeType composite, boolean local, ConsistencyLevel cl) throws RequestExecutionException, RequestValidationException { + try + { + cl.validateForRead(keyspace()); + } + catch (InvalidRequestException e) + { + throw new InvalidRequestException(String.format("Write operation require a read but consistency %s is not supported on reads", cl)); + } + List commands = new ArrayList(keys.size()); for (ByteBuffer key : keys) { @@ -177,7 +168,7 @@ public abstract class ModificationStatement extends CFStatement implements CQLSt { List rows = local ? SelectStatement.readLocally(keyspace(), commands) - : StorageProxy.read(commands, getConsistencyLevel()); + : StorageProxy.read(commands, cl); Map map = new HashMap(); for (Row row : rows) @@ -212,7 +203,7 @@ public abstract class ModificationStatement extends CFStatement implements CQLSt * @return list of the mutations * @throws InvalidRequestException on invalid requests */ - protected abstract Collection getMutations(ClientState clientState, List variables, boolean local) + protected abstract Collection getMutations(ClientState clientState, List variables, boolean local, ConsistencyLevel cl) throws RequestExecutionException, RequestValidationException; public abstract ParsedStatement.Prepared prepare(CFDefinition.Name[] boundNames) throws InvalidRequestException; diff --git a/src/java/org/apache/cassandra/cql3/statements/PermissionAlteringStatement.java b/src/java/org/apache/cassandra/cql3/statements/PermissionAlteringStatement.java index d3d1c9f7ff..48c2d03c6b 100644 --- a/src/java/org/apache/cassandra/cql3/statements/PermissionAlteringStatement.java +++ b/src/java/org/apache/cassandra/cql3/statements/PermissionAlteringStatement.java @@ -17,7 +17,12 @@ */ package org.apache.cassandra.cql3.statements; +import java.nio.ByteBuffer; +import java.util.List; + import org.apache.cassandra.cql3.CQLStatement; +import org.apache.cassandra.db.ConsistencyLevel; +import org.apache.cassandra.exceptions.*; import org.apache.cassandra.service.ClientState; import org.apache.cassandra.transport.messages.ResultMessage; @@ -40,6 +45,13 @@ public abstract class PermissionAlteringStatement extends ParsedStatement implem public void validate(ClientState state) {} + public ResultMessage execute(ConsistencyLevel cl, ClientState state, List variables) throws UnauthorizedException, InvalidRequestException + { + return execute(state, variables); + } + + public abstract ResultMessage execute(ClientState state, List variables) throws UnauthorizedException, InvalidRequestException; + public ResultMessage executeInternal(ClientState state) { // executeInternal is for local query only, thus altering permission doesn't make sense and is not supported diff --git a/src/java/org/apache/cassandra/cql3/statements/SchemaAlteringStatement.java b/src/java/org/apache/cassandra/cql3/statements/SchemaAlteringStatement.java index e9d4450476..ef0f0a1117 100644 --- a/src/java/org/apache/cassandra/cql3/statements/SchemaAlteringStatement.java +++ b/src/java/org/apache/cassandra/cql3/statements/SchemaAlteringStatement.java @@ -21,18 +21,15 @@ import java.nio.ByteBuffer; import java.util.List; import java.util.Map; -import org.apache.cassandra.cql3.CQLStatement; -import org.apache.cassandra.exceptions.InvalidRequestException; -import org.apache.cassandra.transport.messages.ResultMessage; import org.apache.cassandra.auth.Permission; import org.apache.cassandra.config.Schema; import org.apache.cassandra.cql3.CFName; -import org.apache.cassandra.exceptions.ConfigurationException; -import org.apache.cassandra.exceptions.InvalidRequestException; -import org.apache.cassandra.exceptions.RequestValidationException; -import org.apache.cassandra.exceptions.UnauthorizedException; +import org.apache.cassandra.cql3.CQLStatement; +import org.apache.cassandra.db.ConsistencyLevel; +import org.apache.cassandra.exceptions.*; import org.apache.cassandra.service.ClientState; import org.apache.cassandra.service.StorageProxy; +import org.apache.cassandra.transport.messages.ResultMessage; import com.google.common.base.Predicates; import com.google.common.collect.Maps; @@ -77,7 +74,7 @@ public abstract class SchemaAlteringStatement extends CFStatement implements CQL public void validate(ClientState state) throws RequestValidationException {} - public ResultMessage execute(ClientState state, List variables) throws RequestValidationException + public ResultMessage execute(ConsistencyLevel cl, ClientState state, List variables) throws RequestValidationException { announceMigration(); String tableName = cfName == null || columnFamily() == null ? "" : columnFamily(); diff --git a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java index ec50ef9df7..226d00438a 100644 --- a/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java +++ b/src/java/org/apache/cassandra/cql3/statements/SelectStatement.java @@ -118,13 +118,18 @@ public class SelectStatement implements CQLStatement // Nothing to do, all validation has been done by RawStatement.prepare() } - public ResultMessage.Rows execute(ClientState state, List variables) throws RequestExecutionException, RequestValidationException + public ResultMessage.Rows execute(ConsistencyLevel cl, ClientState state, List variables) throws RequestExecutionException, RequestValidationException { + if (cl == null) + throw new InvalidRequestException("Invalid empty consistency level"); + + cl.validateForRead(keyspace()); + try { List rows = isKeyRange - ? StorageProxy.getRangeSlice(getRangeCommand(variables), getConsistencyLevel()) - : StorageProxy.read(getSliceCommands(variables), getConsistencyLevel()); + ? StorageProxy.getRangeSlice(getRangeCommand(variables), cl) + : StorageProxy.read(getSliceCommands(variables), cl); return processResults(rows, variables); } @@ -322,11 +327,6 @@ public class SelectStatement implements CQLStatement return sliceRestriction != null && !sliceRestriction.isInclusive(Bound.START) ? parameters.limit + 1 : parameters.limit; } - private ConsistencyLevel getConsistencyLevel() - { - return parameters.consistencyLevel == null ? cfDef.cfm.getReadConsistencyLevel() : parameters.consistencyLevel; - } - private Collection getKeys(final List variables) throws InvalidRequestException { List keys = new ArrayList(); @@ -971,8 +971,6 @@ public class SelectStatement implements CQLStatement public ParsedStatement.Prepared prepare() throws InvalidRequestException { CFMetaData cfm = ThriftValidation.validateColumnFamily(keyspace(), columnFamily()); - if (parameters.consistencyLevel != null) - parameters.consistencyLevel.validateForRead(keyspace()); if (parameters.limit <= 0) throw new InvalidRequestException("LIMIT must be strictly positive"); @@ -1280,12 +1278,11 @@ public class SelectStatement implements CQLStatement @Override public String toString() { - return String.format("SelectRawStatement[name=%s, selectClause=%s, whereClause=%s, isCount=%s, cLevel=%s, limit=%s]", + return String.format("SelectRawStatement[name=%s, selectClause=%s, whereClause=%s, isCount=%s, limit=%s]", cfName, selectClause, whereClause, parameters.isCount, - parameters.consistencyLevel, parameters.limit); } } @@ -1428,13 +1425,11 @@ public class SelectStatement implements CQLStatement public static class Parameters { private final int limit; - private final ConsistencyLevel consistencyLevel; private final Map orderings; private final boolean isCount; - public Parameters(ConsistencyLevel consistency, int limit, Map orderings, boolean isCount) + public Parameters(int limit, Map orderings, boolean isCount) { - this.consistencyLevel = consistency; this.limit = limit; this.orderings = orderings; this.isCount = isCount; diff --git a/src/java/org/apache/cassandra/cql3/statements/TruncateStatement.java b/src/java/org/apache/cassandra/cql3/statements/TruncateStatement.java index e709a067d6..af4b4e0bcd 100644 --- a/src/java/org/apache/cassandra/cql3/statements/TruncateStatement.java +++ b/src/java/org/apache/cassandra/cql3/statements/TruncateStatement.java @@ -24,6 +24,7 @@ import java.util.concurrent.TimeoutException; import org.apache.cassandra.auth.Permission; import org.apache.cassandra.cql3.*; +import org.apache.cassandra.db.ConsistencyLevel; import org.apache.cassandra.exceptions.*; import org.apache.cassandra.transport.messages.ResultMessage; import org.apache.cassandra.service.ClientState; @@ -52,7 +53,7 @@ public class TruncateStatement extends CFStatement implements CQLStatement ThriftValidation.validateColumnFamily(keyspace(), columnFamily()); } - public ResultMessage execute(ClientState state, List variables) throws InvalidRequestException, TruncateException + public ResultMessage execute(ConsistencyLevel cl, ClientState state, List variables) throws InvalidRequestException, TruncateException { try { diff --git a/src/java/org/apache/cassandra/cql3/statements/UpdateStatement.java b/src/java/org/apache/cassandra/cql3/statements/UpdateStatement.java index c3401b209c..2065f3243f 100644 --- a/src/java/org/apache/cassandra/cql3/statements/UpdateStatement.java +++ b/src/java/org/apache/cassandra/cql3/statements/UpdateStatement.java @@ -96,9 +96,16 @@ public class UpdateStatement extends ModificationStatement this.columns = null; } + protected void validateConsistency(ConsistencyLevel cl) throws InvalidRequestException + { + if (type == Type.COUNTER) + cl.validateCounterForWrite(cfDef.cfm); + else + cl.validateForWrite(cfDef.cfm.ksName); + } /** {@inheritDoc} */ - public Collection getMutations(ClientState clientState, List variables, boolean local) + public Collection getMutations(ClientState clientState, List variables, boolean local, ConsistencyLevel cl) throws RequestExecutionException, RequestValidationException { List keys = buildKeyNames(cfDef, processedKeys, variables); @@ -125,13 +132,13 @@ public class UpdateStatement extends ModificationStatement } } - Map rows = needsReading ? readRows(keys, builder, (CompositeType)cfDef.cfm.comparator, local) : null; + Map rows = needsReading ? readRows(keys, builder, (CompositeType)cfDef.cfm.comparator, local, cl) : null; Collection mutations = new LinkedList(); UpdateParameters params = new UpdateParameters(variables, getTimestamp(clientState), getTimeToLive()); for (ByteBuffer key: keys) - mutations.add(mutationForKey(cfDef, key, builder, params, rows == null ? null : rows.get(key))); + mutations.add(mutationForKey(cfDef, key, builder, params, rows == null ? null : rows.get(key), cl)); return mutations; } @@ -196,7 +203,7 @@ public class UpdateStatement extends ModificationStatement * * @throws InvalidRequestException on the wrong request */ - private IMutation mutationForKey(CFDefinition cfDef, ByteBuffer key, ColumnNameBuilder builder, UpdateParameters params, ColumnGroupMap group) + private IMutation mutationForKey(CFDefinition cfDef, ByteBuffer key, ColumnNameBuilder builder, UpdateParameters params, ColumnGroupMap group, ConsistencyLevel cl) throws InvalidRequestException { validateKey(key); @@ -252,7 +259,7 @@ public class UpdateStatement extends ModificationStatement } } - return (hasCounterColumn) ? new CounterMutation(rm, getConsistencyLevel()) : rm; + return (hasCounterColumn) ? new CounterMutation(rm, cl) : rm; } private boolean addToMutation(ColumnFamily cf, @@ -319,9 +326,6 @@ public class UpdateStatement extends ModificationStatement // Deal here with the keyspace overwrite thingy to avoid mistake CFMetaData metadata = validateColumnFamily(keyspace(), columnFamily(), type == Type.COUNTER); - if (type == Type.COUNTER) - getConsistencyLevel().validateCounterForWrite(metadata); - cfDef = metadata.getCfDef(); if (columns == null) @@ -440,11 +444,10 @@ public class UpdateStatement extends ModificationStatement public String toString() { - return String.format("UpdateStatement(name=%s, keys=%s, columns=%s, consistency=%s, timestamp=%s, timeToLive=%s)", + return String.format("UpdateStatement(name=%s, keys=%s, columns=%s, timestamp=%s, timeToLive=%s)", cfName, whereClause, columns, - getConsistencyLevel(), isSetTimestamp() ? getTimestamp(null) : "", getTimeToLive()); } diff --git a/src/java/org/apache/cassandra/cql3/statements/UseStatement.java b/src/java/org/apache/cassandra/cql3/statements/UseStatement.java index 70e95f6bd5..c381978b0a 100644 --- a/src/java/org/apache/cassandra/cql3/statements/UseStatement.java +++ b/src/java/org/apache/cassandra/cql3/statements/UseStatement.java @@ -21,6 +21,7 @@ import java.nio.ByteBuffer; import java.util.List; import org.apache.cassandra.cql3.CQLStatement; +import org.apache.cassandra.db.ConsistencyLevel; import org.apache.cassandra.exceptions.InvalidRequestException; import org.apache.cassandra.transport.messages.ResultMessage; import org.apache.cassandra.service.ClientState; @@ -48,7 +49,7 @@ public class UseStatement extends ParsedStatement implements CQLStatement { } - public ResultMessage execute(ClientState state, List variables) throws InvalidRequestException + public ResultMessage execute(ConsistencyLevel cl, ClientState state, List variables) throws InvalidRequestException { state.setKeyspace(keyspace); return new ResultMessage.SetKeyspace(keyspace); diff --git a/src/java/org/apache/cassandra/thrift/CassandraServer.java b/src/java/org/apache/cassandra/thrift/CassandraServer.java index 6a5ef45d4e..16b953f565 100644 --- a/src/java/org/apache/cassandra/thrift/CassandraServer.java +++ b/src/java/org/apache/cassandra/thrift/CassandraServer.java @@ -1651,11 +1651,41 @@ public class CassandraServer implements Cassandra.Iface logger.debug("execute_cql_query"); } - ClientState cState = state(); - if (cState.getCQLVersion().major == 2) - return QueryProcessor.process(queryString, state()); + return QueryProcessor.process(queryString, state()); + } + catch (RequestExecutionException e) + { + ThriftConversion.rethrow(e); + return null; + } + catch (RequestValidationException e) + { + throw ThriftConversion.toThrift(e); + } + finally + { + Tracing.instance().stopSession(); + } + } + + public CqlResult execute_cql3_query(ByteBuffer query, Compression compression, ConsistencyLevel cLevel) + throws InvalidRequestException, UnavailableException, TimedOutException, SchemaDisagreementException, TException + { + try + { + String queryString = uncompress(query, compression); + if (startSessionIfRequested()) + { + Tracing.instance().begin("execute_cql3_query", + ImmutableMap.of("query", queryString)); + } else - return org.apache.cassandra.cql3.QueryProcessor.process(queryString, cState).toThriftResult(); + { + logger.debug("execute_cql3_query"); + } + + ClientState cState = state(); + return org.apache.cassandra.cql3.QueryProcessor.process(queryString, ThriftConversion.fromThrift(cLevel), cState).toThriftResult(); } catch (RequestExecutionException e) { @@ -1680,13 +1710,27 @@ public class CassandraServer implements Cassandra.Iface try { - String queryString = uncompress(query,compression); - ClientState cState = state(); - if (cState.getCQLVersion().major == 2) - return QueryProcessor.prepare(queryString, cState); - else - return org.apache.cassandra.cql3.QueryProcessor.prepare(queryString, cState, true).toThriftPreparedResult(); + String queryString = uncompress(query,compression); + return QueryProcessor.prepare(queryString, cState); + } + catch (RequestValidationException e) + { + throw ThriftConversion.toThrift(e); + } + } + + public CqlPreparedResult prepare_cql3_query(ByteBuffer query, Compression compression) + throws InvalidRequestException, TException + { + if (logger.isDebugEnabled()) + logger.debug("prepare_cql3_query"); + + try + { + ClientState cState = state(); + String queryString = uncompress(query,compression); + return org.apache.cassandra.cql3.QueryProcessor.prepare(queryString, cState, true).toThriftPreparedResult(); } catch (RequestValidationException e) { @@ -1710,30 +1754,55 @@ public class CassandraServer implements Cassandra.Iface try { ClientState cState = state(); - if (cState.getCQLVersion().major == 2) - { - CQLStatement statement = cState.getPrepared().get(itemId); + CQLStatement statement = cState.getPrepared().get(itemId); - if (statement == null) - throw new InvalidRequestException(String.format("Prepared query with ID %d not found", itemId)); - logger.trace("Retrieved prepared statement #{} with {} bind markers", itemId, statement.boundTerms); + if (statement == null) + throw new InvalidRequestException(String.format("Prepared query with ID %d not found", itemId)); + logger.trace("Retrieved prepared statement #{} with {} bind markers", itemId, statement.boundTerms); - return QueryProcessor.processPrepared(statement, cState, bindVariables); - } - else - { - org.apache.cassandra.cql3.CQLStatement statement = org.apache.cassandra.cql3.QueryProcessor.getPrepared(itemId); + return QueryProcessor.processPrepared(statement, cState, bindVariables); + } + catch (RequestExecutionException e) + { + ThriftConversion.rethrow(e); + return null; + } + catch (RequestValidationException e) + { + throw ThriftConversion.toThrift(e); + } + finally + { + Tracing.instance().stopSession(); + } + } - if (statement == null) - throw new InvalidRequestException(String.format("Prepared query with ID %d not found" + - " (either the query was not prepared on this host (maybe the host has been restarted?)" + - " or you have prepared more than %d queries and queries %d has been evicted from the internal cache)", - itemId, org.apache.cassandra.cql3.QueryProcessor.MAX_CACHE_PREPARED, itemId)); - logger.trace("Retrieved prepared statement #{} with {} bind markers", itemId, - statement.getBoundsTerms()); + public CqlResult execute_prepared_cql3_query(int itemId, List bindVariables, ConsistencyLevel cLevel) + throws InvalidRequestException, UnavailableException, TimedOutException, SchemaDisagreementException, TException + { + if (startSessionIfRequested()) + { + // TODO we don't have [typed] access to CQL bind variables here. CASSANDRA-4560 is open to add support. + Tracing.instance().begin("execute_prepared_cql3_query", Collections.emptyMap()); + } + else + { + logger.debug("execute_prepared_cql3_query"); + } - return org.apache.cassandra.cql3.QueryProcessor.processPrepared(statement, cState, bindVariables).toThriftResult(); - } + try + { + ClientState cState = state(); + org.apache.cassandra.cql3.CQLStatement statement = org.apache.cassandra.cql3.QueryProcessor.getPrepared(itemId); + + if (statement == null) + throw new InvalidRequestException(String.format("Prepared query with ID %d not found" + + " (either the query was not prepared on this host (maybe the host has been restarted?)" + + " or you have prepared more than %d queries and queries %d has been evicted from the internal cache)", + itemId, org.apache.cassandra.cql3.QueryProcessor.MAX_CACHE_PREPARED, itemId)); + logger.trace("Retrieved prepared statement #{} with {} bind markers", itemId, statement.getBoundsTerms()); + + return org.apache.cassandra.cql3.QueryProcessor.processPrepared(statement, ThriftConversion.fromThrift(cLevel), cState, bindVariables).toThriftResult(); } catch (RequestExecutionException e) { @@ -1752,16 +1821,7 @@ public class CassandraServer implements Cassandra.Iface public void set_cql_version(String version) throws InvalidRequestException { - logger.debug("set_cql_version: " + version); - - try - { - state().setCQLVersion(version); - } - catch (RequestValidationException e) - { - throw ThriftConversion.toThrift(e); - } + // Deprecated, no-op } public ByteBuffer trace_next_query() throws TException diff --git a/src/java/org/apache/cassandra/transport/CBUtil.java b/src/java/org/apache/cassandra/transport/CBUtil.java index fe8863ab8e..45affc6785 100644 --- a/src/java/org/apache/cassandra/transport/CBUtil.java +++ b/src/java/org/apache/cassandra/transport/CBUtil.java @@ -31,6 +31,8 @@ import org.jboss.netty.buffer.ChannelBuffer; import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.util.CharsetUtil; +import org.apache.cassandra.db.ConsistencyLevel; + /** * ChannelBuffer utility methods. * Note that contrarily to ByteBufferUtil, these method do "read" the @@ -131,6 +133,29 @@ public abstract class CBUtil } } + public static ChannelBuffer consistencyLevelToCB(ConsistencyLevel consistency) + { + if (consistency == null) + return shortToCB(0); + else + return stringToCB(consistency.toString()); + } + + public static ConsistencyLevel readConsistencyLevel(ChannelBuffer cb) + { + String cl = CBUtil.readString(cb); + try + { + if (cl.isEmpty()) + return null; + return Enum.valueOf(ConsistencyLevel.class, cl.toUpperCase()); + } + catch (IllegalArgumentException e) + { + throw new ProtocolException("Unknown consistency level: " + cl); + } + } + public static ChannelBuffer longStringToCB(String str) { ChannelBuffer bytes = bytes(str); diff --git a/src/java/org/apache/cassandra/transport/Client.java b/src/java/org/apache/cassandra/transport/Client.java index 3b4ace9aa8..46a329739c 100644 --- a/src/java/org/apache/cassandra/transport/Client.java +++ b/src/java/org/apache/cassandra/transport/Client.java @@ -25,8 +25,9 @@ import java.util.*; import com.google.common.base.Splitter; -import org.apache.cassandra.transport.messages.*; import org.apache.cassandra.db.marshal.*; +import org.apache.cassandra.db.ConsistencyLevel; +import org.apache.cassandra.transport.messages.*; import org.apache.cassandra.utils.Hex; public class Client extends SimpleClient @@ -99,7 +100,7 @@ public class Client extends SimpleClient else if (msgType.equals("QUERY")) { String query = line.substring(6); - return new QueryMessage(query); + return new QueryMessage(query, ConsistencyLevel.ONE); } else if (msgType.equals("PREPARE")) { @@ -127,7 +128,7 @@ public class Client extends SimpleClient } values.add(bb); } - return new ExecuteMessage(id, values); + return new ExecuteMessage(id, values, ConsistencyLevel.ONE); } catch (Exception e) { diff --git a/src/java/org/apache/cassandra/transport/SimpleClient.java b/src/java/org/apache/cassandra/transport/SimpleClient.java index 8132e6546e..1d6731763c 100644 --- a/src/java/org/apache/cassandra/transport/SimpleClient.java +++ b/src/java/org/apache/cassandra/transport/SimpleClient.java @@ -36,6 +36,7 @@ import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory; import org.jboss.netty.logging.InternalLoggerFactory; import org.jboss.netty.logging.Slf4JLoggerFactory; +import org.apache.cassandra.db.ConsistencyLevel; import org.apache.cassandra.transport.messages.*; import org.apache.cassandra.service.ClientState; @@ -112,9 +113,9 @@ public class SimpleClient execute(msg); } - public ResultMessage execute(String query) + public ResultMessage execute(String query, ConsistencyLevel consistency) { - Message.Response msg = execute(new QueryMessage(query)); + Message.Response msg = execute(new QueryMessage(query, consistency)); assert msg instanceof ResultMessage; return (ResultMessage)msg; } @@ -126,9 +127,9 @@ public class SimpleClient return (ResultMessage.Prepared)msg; } - public ResultMessage executePrepared(byte[] statementId, List values) + public ResultMessage executePrepared(byte[] statementId, List values, ConsistencyLevel consistency) { - Message.Response msg = execute(new ExecuteMessage(statementId, values)); + Message.Response msg = execute(new ExecuteMessage(statementId, values, consistency)); assert msg instanceof ResultMessage; return (ResultMessage)msg; } diff --git a/src/java/org/apache/cassandra/transport/messages/ErrorMessage.java b/src/java/org/apache/cassandra/transport/messages/ErrorMessage.java index 73a965f16c..b42ba62aec 100644 --- a/src/java/org/apache/cassandra/transport/messages/ErrorMessage.java +++ b/src/java/org/apache/cassandra/transport/messages/ErrorMessage.java @@ -61,7 +61,7 @@ public class ErrorMessage extends Message.Response break; case UNAVAILABLE: { - ConsistencyLevel cl = Enum.valueOf(ConsistencyLevel.class, CBUtil.readString(body)); + ConsistencyLevel cl = CBUtil.readConsistencyLevel(body); int required = body.readInt(); int alive = body.readInt(); te = new UnavailableException(cl, required, alive); @@ -132,10 +132,8 @@ public class ErrorMessage extends Message.Response { case UNAVAILABLE: UnavailableException ue = (UnavailableException)msg.error; - ByteBuffer ueCl = ByteBufferUtil.bytes(ue.consistency.toString()); - - acb = ChannelBuffers.buffer(2 + ueCl.remaining() + 8); - acb.writeShort((short)ueCl.remaining()); + ChannelBuffer ueCl = CBUtil.consistencyLevelToCB(ue.consistency); + acb = ChannelBuffers.buffer(ueCl.readableBytes() + 8); acb.writeBytes(ueCl); acb.writeInt(ue.required); acb.writeInt(ue.alive); diff --git a/src/java/org/apache/cassandra/transport/messages/ExecuteMessage.java b/src/java/org/apache/cassandra/transport/messages/ExecuteMessage.java index 4400d127f3..842fb22380 100644 --- a/src/java/org/apache/cassandra/transport/messages/ExecuteMessage.java +++ b/src/java/org/apache/cassandra/transport/messages/ExecuteMessage.java @@ -25,6 +25,7 @@ import org.jboss.netty.buffer.ChannelBuffer; import org.apache.cassandra.cql3.CQLStatement; import org.apache.cassandra.cql3.QueryProcessor; +import org.apache.cassandra.db.ConsistencyLevel; import org.apache.cassandra.exceptions.PreparedQueryNotFoundException; import org.apache.cassandra.transport.*; import org.apache.cassandra.utils.MD5Digest; @@ -42,7 +43,8 @@ public class ExecuteMessage extends Message.Request for (int i = 0; i < count; i++) values.add(CBUtil.readValue(body)); - return new ExecuteMessage(id, values); + ConsistencyLevel consistency = CBUtil.readConsistencyLevel(body); + return new ExecuteMessage(id, values, consistency); } public ChannelBuffer encode(ExecuteMessage msg) @@ -53,7 +55,7 @@ public class ExecuteMessage extends Message.Request // - The values // - options int vs = msg.values.size(); - CBUtil.BufferBuilder builder = new CBUtil.BufferBuilder(2, 0, vs); + CBUtil.BufferBuilder builder = new CBUtil.BufferBuilder(3, 0, vs); builder.add(CBUtil.bytesToCB(msg.statementId.bytes)); builder.add(CBUtil.shortToCB(vs)); @@ -61,23 +63,26 @@ public class ExecuteMessage extends Message.Request for (ByteBuffer value : msg.values) builder.addValue(value); + builder.add(CBUtil.consistencyLevelToCB(msg.consistency)); return builder.build(); } }; public final MD5Digest statementId; public final List values; + public final ConsistencyLevel consistency; - public ExecuteMessage(byte[] statementId, List values) + public ExecuteMessage(byte[] statementId, List values, ConsistencyLevel consistency) { - this(MD5Digest.wrap(statementId), values); + this(MD5Digest.wrap(statementId), values, consistency); } - public ExecuteMessage(MD5Digest statementId, List values) + public ExecuteMessage(MD5Digest statementId, List values, ConsistencyLevel consistency) { super(Message.Type.EXECUTE); this.statementId = statementId; this.values = values; + this.consistency = consistency; } public ChannelBuffer encode() @@ -95,7 +100,7 @@ public class ExecuteMessage extends Message.Request if (statement == null) throw new PreparedQueryNotFoundException(statementId); - return QueryProcessor.processPrepared(statement, c.clientState(), values); + return QueryProcessor.processPrepared(statement, consistency, c.clientState(), values); } catch (Exception e) { @@ -106,6 +111,6 @@ public class ExecuteMessage extends Message.Request @Override public String toString() { - return "EXECUTE " + statementId + " with " + values.size() + " values"; + return "EXECUTE " + statementId + " with " + values.size() + " values at consistency " + consistency; } } diff --git a/src/java/org/apache/cassandra/transport/messages/QueryMessage.java b/src/java/org/apache/cassandra/transport/messages/QueryMessage.java index 0880ee0724..52235288b5 100644 --- a/src/java/org/apache/cassandra/transport/messages/QueryMessage.java +++ b/src/java/org/apache/cassandra/transport/messages/QueryMessage.java @@ -18,8 +18,10 @@ package org.apache.cassandra.transport.messages; import org.jboss.netty.buffer.ChannelBuffer; +import org.jboss.netty.buffer.ChannelBuffers; import org.apache.cassandra.cql3.QueryProcessor; +import org.apache.cassandra.db.ConsistencyLevel; import org.apache.cassandra.exceptions.*; import org.apache.cassandra.transport.*; @@ -33,21 +35,25 @@ public class QueryMessage extends Message.Request public QueryMessage decode(ChannelBuffer body) { String query = CBUtil.readLongString(body); - return new QueryMessage(query); + ConsistencyLevel consistency = CBUtil.readConsistencyLevel(body); + return new QueryMessage(query, consistency); } public ChannelBuffer encode(QueryMessage msg) { - return CBUtil.longStringToCB(msg.query); + + return ChannelBuffers.wrappedBuffer(CBUtil.longStringToCB(msg.query), CBUtil.consistencyLevelToCB(msg.consistency)); } }; public final String query; + public final ConsistencyLevel consistency; - public QueryMessage(String query) + public QueryMessage(String query, ConsistencyLevel consistency) { super(Message.Type.QUERY); this.query = query; + this.consistency = consistency; } public ChannelBuffer encode() @@ -59,7 +65,7 @@ public class QueryMessage extends Message.Request { try { - return QueryProcessor.process(query, ((ServerConnection)connection).clientState()); + return QueryProcessor.process(query, consistency, ((ServerConnection)connection).clientState()); } catch (Exception e) {