Repository: cassandra Updated Branches: refs/heads/trunk 3d7c5fdd3 -> 262170712
http://git-wip-us.apache.org/repos/asf/cassandra/blob/26217071/src/java/org/apache/cassandra/cql/hooks/PreExecutionHook.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/cql/hooks/PreExecutionHook.java b/src/java/org/apache/cassandra/cql/hooks/PreExecutionHook.java deleted file mode 100644 index 29ed38e..0000000 --- a/src/java/org/apache/cassandra/cql/hooks/PreExecutionHook.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.cassandra.cql.hooks; - -import org.apache.cassandra.cql.CQLStatement; -import org.apache.cassandra.exceptions.RequestExecutionException; -import org.apache.cassandra.exceptions.RequestValidationException; - -/** - * Run before the CQL Statement is executed in - * {@link org.apache.cassandra.cql.QueryProcessor}. The CQLStatement - * returned from the processStatement method is what is actually executed - * by the QueryProcessor. - */ -public interface PreExecutionHook -{ - /** - * Perform pre-processing on a CQL statement prior to it being - * executed by the QueryProcessor. If required, implementations - * may modify the statement as the returned instance is what - * is actually executed. - * - * @param statement the statement to perform pre-processing on - * @param context execution context containing additional info - * about the operation and statement - * @return the actual statement that will be executed, possibly - * a modification of the initial statement - * @throws RequestExecutionException, RequestValidationException - */ - CQLStatement processStatement(CQLStatement statement, ExecutionContext context) throws RequestExecutionException, RequestValidationException; -} http://git-wip-us.apache.org/repos/asf/cassandra/blob/26217071/src/java/org/apache/cassandra/cql/hooks/PreparationContext.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/cql/hooks/PreparationContext.java b/src/java/org/apache/cassandra/cql/hooks/PreparationContext.java deleted file mode 100644 index 00cce78..0000000 --- a/src/java/org/apache/cassandra/cql/hooks/PreparationContext.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.cassandra.cql.hooks; - -import org.apache.cassandra.cql.CQLStatement; -import org.apache.cassandra.thrift.ThriftClientState; - -/** - * Contextual information about the preparation of a CQLStatement. - * Used by {@link org.apache.cassandra.cql.hooks.PostPreparationHook} - */ -public class PreparationContext -{ - public final ThriftClientState clientState; - public final String queryString; - public final CQLStatement statement; - - public PreparationContext(ThriftClientState clientState, String queryString, CQLStatement statement) - { - this.clientState = clientState; - this.queryString = queryString; - this.statement = statement; - } -} http://git-wip-us.apache.org/repos/asf/cassandra/blob/26217071/src/java/org/apache/cassandra/cql3/QueryProcessor.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/cql3/QueryProcessor.java b/src/java/org/apache/cassandra/cql3/QueryProcessor.java index 5acb367..bd88852 100644 --- a/src/java/org/apache/cassandra/cql3/QueryProcessor.java +++ b/src/java/org/apache/cassandra/cql3/QueryProcessor.java @@ -50,7 +50,6 @@ public class QueryProcessor private static final Logger logger = LoggerFactory.getLogger(QueryProcessor.class); private static final MemoryMeter meter = new MemoryMeter().withGuessing(MemoryMeter.Guess.FALLBACK_BEST); private static final long MAX_CACHE_PREPARED_MEMORY = Runtime.getRuntime().maxMemory() / 256; - private static final int MAX_CACHE_PREPARED_COUNT = 10000; private static EntryWeigher<MD5Digest, CQLStatement> cqlMemoryUsageWeigher = new EntryWeigher<MD5Digest, CQLStatement>() { http://git-wip-us.apache.org/repos/asf/cassandra/blob/26217071/src/java/org/apache/cassandra/db/composites/CType.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/db/composites/CType.java b/src/java/org/apache/cassandra/db/composites/CType.java index c2516f5..0e26b1f 100644 --- a/src/java/org/apache/cassandra/db/composites/CType.java +++ b/src/java/org/apache/cassandra/db/composites/CType.java @@ -97,19 +97,19 @@ public interface CType extends Comparator<Composite> /** * Deserialize a Composite from a ByteBuffer. * - * This is meant for thrift/cql2 to convert the fully serialized buffer we + * This is meant for thrift to convert the fully serialized buffer we * get from the clients to composites. */ public Composite fromByteBuffer(ByteBuffer bb); /** - * Returns a AbstractType corresponding to this CType for thrift/cql2 sake. + * Returns a AbstractType corresponding to this CType for thrift sake. * * If the CType is a "simple" one, this just return the wrapped type, otherwise * it returns the corresponding org.apache.cassandra.db.marshal.CompositeType. * * This is only meant to be use for backward compatibility (particularly for - * thrift/cql2) but it's not meant to be used internally. + * thrift) but it's not meant to be used internally. */ public AbstractType<?> asAbstractType(); http://git-wip-us.apache.org/repos/asf/cassandra/blob/26217071/src/java/org/apache/cassandra/db/composites/CellNameType.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/db/composites/CellNameType.java b/src/java/org/apache/cassandra/db/composites/CellNameType.java index 7128c91..e4fa0e2 100644 --- a/src/java/org/apache/cassandra/db/composites/CellNameType.java +++ b/src/java/org/apache/cassandra/db/composites/CellNameType.java @@ -144,7 +144,7 @@ public interface CellNameType extends CType * Deserialize a Composite from a ByteBuffer. * * This is equilvalent to CType#fromByteBuffer but assumes the buffer is a full cell - * name. This is meant for thrift/cql2 to convert the fully serialized buffer we + * name. This is meant for thrift to convert the fully serialized buffer we * get from the clients. */ public CellName cellFromByteBuffer(ByteBuffer bb); http://git-wip-us.apache.org/repos/asf/cassandra/blob/26217071/src/java/org/apache/cassandra/db/marshal/AbstractType.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/db/marshal/AbstractType.java b/src/java/org/apache/cassandra/db/marshal/AbstractType.java index ce233de..c148366 100644 --- a/src/java/org/apache/cassandra/db/marshal/AbstractType.java +++ b/src/java/org/apache/cassandra/db/marshal/AbstractType.java @@ -84,12 +84,6 @@ public abstract class AbstractType<T> implements Comparator<ByteBuffer> /** get a byte representation of the given string. */ public abstract ByteBuffer fromString(String source) throws MarshalException; - /** for compatibility with TimeUUID in CQL2. See TimeUUIDType (that overrides it). */ - public ByteBuffer fromStringCQL2(String source) throws MarshalException - { - return fromString(source); - } - /* validate that the byte array is a valid sequence for the type we are supposed to be comparing */ public void validate(ByteBuffer bytes) throws MarshalException { http://git-wip-us.apache.org/repos/asf/cassandra/blob/26217071/src/java/org/apache/cassandra/db/marshal/TimeUUIDType.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/db/marshal/TimeUUIDType.java b/src/java/org/apache/cassandra/db/marshal/TimeUUIDType.java index 51cf47a..b16b3dd 100644 --- a/src/java/org/apache/cassandra/db/marshal/TimeUUIDType.java +++ b/src/java/org/apache/cassandra/db/marshal/TimeUUIDType.java @@ -83,41 +83,6 @@ public class TimeUUIDType extends AbstractType<UUID> return (o1.get(o1Pos + 3) & 0xFF) - (o2.get(o2Pos + 3) & 0xFF); } - // This accepts dates are valid TimeUUID represensation, which is bogus - // (see #4936) but kept for CQL2 for compatibility sake. - @Override - public ByteBuffer fromStringCQL2(String source) throws MarshalException - { - // Return an empty ByteBuffer for an empty string. - if (source.isEmpty()) - return ByteBufferUtil.EMPTY_BYTE_BUFFER; - - ByteBuffer idBytes = null; - - // ffffffff-ffff-ffff-ffff-ffffffffff - if (regexPattern.matcher(source).matches()) - { - UUID uuid = null; - try - { - uuid = UUID.fromString(source); - idBytes = decompose(uuid); - } - catch (IllegalArgumentException e) - { - throw new MarshalException(String.format("unable to make UUID from '%s'", source), e); - } - - if (uuid.version() != 1) - throw new MarshalException("TimeUUID supports only version 1 UUIDs"); - } else - { - idBytes = ByteBuffer.wrap(UUIDGen.getTimeUUIDBytes(DateType.dateStringToTimestamp(source))); - } - - return idBytes; - } - public ByteBuffer fromString(String source) throws MarshalException { // Return an empty ByteBuffer for an empty string. http://git-wip-us.apache.org/repos/asf/cassandra/blob/26217071/src/java/org/apache/cassandra/db/marshal/UUIDType.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/db/marshal/UUIDType.java b/src/java/org/apache/cassandra/db/marshal/UUIDType.java index 4b0751e..cb2dd33 100644 --- a/src/java/org/apache/cassandra/db/marshal/UUIDType.java +++ b/src/java/org/apache/cassandra/db/marshal/UUIDType.java @@ -17,9 +17,7 @@ */ package org.apache.cassandra.db.marshal; - import java.nio.ByteBuffer; -import java.text.ParseException; import java.util.UUID; import org.apache.cassandra.cql3.CQL3Type; @@ -28,9 +26,6 @@ import org.apache.cassandra.serializers.MarshalException; import org.apache.cassandra.serializers.UUIDSerializer; import org.apache.cassandra.utils.ByteBufferUtil; import org.apache.cassandra.utils.UUIDGen; -import org.apache.commons.lang3.time.DateUtils; - -import static org.apache.cassandra.serializers.TimestampSerializer.iso8601Patterns; /** * Compares UUIDs using the following criteria:<br> @@ -165,52 +160,20 @@ public class UUIDType extends AbstractType<UUID> if (source.isEmpty()) return ByteBufferUtil.EMPTY_BYTE_BUFFER; - ByteBuffer idBytes = null; - // ffffffff-ffff-ffff-ffff-ffffffffff if (TimeUUIDType.regexPattern.matcher(source).matches()) { - UUID uuid; try { - uuid = UUID.fromString(source); - idBytes = ByteBuffer.wrap(UUIDGen.decompose(uuid)); + return ByteBuffer.wrap(UUIDGen.decompose(UUID.fromString(source))); } catch (IllegalArgumentException e) { throw new MarshalException(String.format("unable to make UUID from '%s'", source), e); } - } else if (source.toLowerCase().equals("now")) - { - idBytes = ByteBuffer.wrap(UUIDGen.getTimeUUIDBytes()); - } - // Milliseconds since epoch? - else if (source.matches("^\\d+$")) - { - try - { - idBytes = ByteBuffer.wrap(UUIDGen.getTimeUUIDBytes(Long.parseLong(source))); - } - catch (NumberFormatException e) - { - throw new MarshalException(String.format("unable to make version 1 UUID from '%s'", source), e); - } - } - // Last chance, attempt to parse as date-time string - else - { - try - { - long timestamp = DateUtils.parseDate(source, iso8601Patterns).getTime(); - idBytes = ByteBuffer.wrap(UUIDGen.getTimeUUIDBytes(timestamp)); - } - catch (ParseException e1) - { - throw new MarshalException(String.format("unable to coerce '%s' to version 1 UUID", source), e1); - } } - return idBytes; + throw new MarshalException(String.format("unable to coerce '%s' to version 1 UUID", source)); } public CQL3Type asCQL3Type() http://git-wip-us.apache.org/repos/asf/cassandra/blob/26217071/src/java/org/apache/cassandra/service/ClientState.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/service/ClientState.java b/src/java/org/apache/cassandra/service/ClientState.java index 7f312a9..7c3ba22 100644 --- a/src/java/org/apache/cassandra/service/ClientState.java +++ b/src/java/org/apache/cassandra/service/ClientState.java @@ -31,6 +31,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.cassandra.auth.*; import org.apache.cassandra.config.DatabaseDescriptor; import org.apache.cassandra.config.Schema; +import org.apache.cassandra.cql3.QueryProcessor; import org.apache.cassandra.db.Keyspace; import org.apache.cassandra.db.SystemKeyspace; import org.apache.cassandra.exceptions.AuthenticationException; @@ -73,8 +74,6 @@ public class ClientState private volatile AuthenticatedUser user; private volatile String keyspace; - private SemanticVersion cqlVersion; - // isInternal is used to mark ClientState as used by some internal component // that should have an ability to modify system keyspace. private final boolean isInternal; @@ -241,54 +240,14 @@ public class ClientState throw new InvalidRequestException("You have not set a keyspace for this session"); } - public void setCQLVersion(String str) throws InvalidRequestException - { - SemanticVersion version; - try - { - version = new SemanticVersion(str); - } - catch (IllegalArgumentException e) - { - throw new InvalidRequestException(e.getMessage()); - } - - SemanticVersion cql = org.apache.cassandra.cql.QueryProcessor.CQL_VERSION; - SemanticVersion cql3 = org.apache.cassandra.cql3.QueryProcessor.CQL_VERSION; - - // We've made some backward incompatible changes between CQL3 beta1 and the final. - // It's ok because it was a beta, but it still mean we don't support 3.0.0-beta1 so reject it. - SemanticVersion cql3Beta = new SemanticVersion("3.0.0-beta1"); - if (version.equals(cql3Beta)) - throw new InvalidRequestException(String.format("There has been a few syntax breaking changes between 3.0.0-beta1 and 3.0.0 " - + "(mainly the syntax for options of CREATE KEYSPACE and CREATE TABLE). 3.0.0-beta1 " - + " is not supported; please upgrade to 3.0.0")); - if (version.isSupportedBy(cql)) - cqlVersion = cql; - else if (version.isSupportedBy(cql3)) - cqlVersion = cql3; - else - throw new InvalidRequestException(String.format("Provided version %s is not supported by this server (supported: %s)", - version, - StringUtils.join(getCQLSupportedVersion(), ", "))); - } - public AuthenticatedUser getUser() { return user; } - public SemanticVersion getCQLVersion() - { - return cqlVersion; - } - public static SemanticVersion[] getCQLSupportedVersion() { - SemanticVersion cql = org.apache.cassandra.cql.QueryProcessor.CQL_VERSION; - SemanticVersion cql3 = org.apache.cassandra.cql3.QueryProcessor.CQL_VERSION; - - return new SemanticVersion[]{ cql, cql3 }; + return new SemanticVersion[]{ QueryProcessor.CQL_VERSION }; } private static LoadingCache<Pair<AuthenticatedUser, IResource>, Set<Permission>> initPermissionsCache() http://git-wip-us.apache.org/repos/asf/cassandra/blob/26217071/src/java/org/apache/cassandra/thrift/CassandraServer.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/thrift/CassandraServer.java b/src/java/org/apache/cassandra/thrift/CassandraServer.java index 650c74e..a5af55d 100644 --- a/src/java/org/apache/cassandra/thrift/CassandraServer.java +++ b/src/java/org/apache/cassandra/thrift/CassandraServer.java @@ -44,8 +44,6 @@ import org.apache.cassandra.config.CFMetaData; import org.apache.cassandra.config.DatabaseDescriptor; import org.apache.cassandra.config.KSMetaData; import org.apache.cassandra.config.Schema; -import org.apache.cassandra.cql.CQLStatement; -import org.apache.cassandra.cql.QueryProcessor; import org.apache.cassandra.cql3.QueryOptions; import org.apache.cassandra.db.*; import org.apache.cassandra.db.composites.*; @@ -71,7 +69,6 @@ import org.apache.cassandra.service.pager.QueryPagers; import org.apache.cassandra.tracing.Tracing; import org.apache.cassandra.utils.ByteBufferUtil; import org.apache.cassandra.utils.Pair; -import org.apache.cassandra.utils.SemanticVersion; import org.apache.cassandra.utils.UUIDGen; import org.apache.thrift.TException; @@ -83,8 +80,6 @@ public class CassandraServer implements Cassandra.Iface private final static List<ColumnOrSuperColumn> EMPTY_COLUMNS = Collections.emptyList(); - private volatile boolean loggedCQL2Warning = false; - /* * RequestScheduler to perform the scheduling of incoming requests */ @@ -1895,67 +1890,13 @@ public class CassandraServer implements Cassandra.Iface return queryString; } - private void validateCQLVersion(int major) throws InvalidRequestException - { - /* - * The rules are: - * - If no version are set, we don't validate anything. The reason is - * that 1) old CQL2 client might not have called set_cql_version - * and 2) some client may have removed the set_cql_version for CQL3 - * when updating to 1.2.0. A CQL3 client upgrading from pre-1.2 - * shouldn't be in that case however since set_cql_version uses to - * be mandatory (for CQL3). - * - Otherwise, checks the major matches whatever was set. - */ - SemanticVersion versionSet = state().getCQLVersion(); - if (versionSet == null) - return; - - if (versionSet.major != major) - throw new InvalidRequestException( - "Cannot execute/prepare CQL" + major + " statement since the CQL has been set to CQL" + versionSet.major - + "(This might mean your client hasn't been upgraded correctly to use the new CQL3 methods introduced in Cassandra 1.2+)."); - } - - public CqlResult execute_cql_query(ByteBuffer query, Compression compression) - throws InvalidRequestException, UnavailableException, TimedOutException, SchemaDisagreementException, TException + public CqlResult execute_cql_query(ByteBuffer query, Compression compression) throws TException { - validateCQLVersion(2); - maybeLogCQL2Warning(); - - try - { - String queryString = uncompress(query, compression); - if (startSessionIfRequested()) - { - Tracing.instance.begin("execute_cql_query", - ImmutableMap.of("query", queryString)); - } - else - { - logger.debug("execute_cql_query"); - } - - return QueryProcessor.process(queryString, state()); - } - catch (RequestExecutionException e) - { - throw ThriftConversion.rethrow(e); - } - catch (RequestValidationException e) - { - throw ThriftConversion.toThrift(e); - } - finally - { - Tracing.instance.stopSession(); - } + throw new InvalidRequestException("CQL2 has been removed in Cassandra 3.0. Please use CQL3 instead"); } - public CqlResult execute_cql3_query(ByteBuffer query, Compression compression, ConsistencyLevel cLevel) - throws InvalidRequestException, UnavailableException, TimedOutException, SchemaDisagreementException, TException + public CqlResult execute_cql3_query(ByteBuffer query, Compression compression, ConsistencyLevel cLevel) throws TException { - validateCQLVersion(3); try { String queryString = uncompress(query, compression); @@ -1986,36 +1927,14 @@ public class CassandraServer implements Cassandra.Iface } } - public CqlPreparedResult prepare_cql_query(ByteBuffer query, Compression compression) - throws InvalidRequestException, TException + public CqlPreparedResult prepare_cql_query(ByteBuffer query, Compression compression) throws TException { - if (logger.isDebugEnabled()) - logger.debug("prepare_cql_query"); - - validateCQLVersion(2); - maybeLogCQL2Warning(); - - String queryString = uncompress(query, compression); - ThriftClientState cState = state(); - - try - { - cState.validateLogin(); - return QueryProcessor.prepare(queryString, cState); - } - catch (RequestValidationException e) - { - throw ThriftConversion.toThrift(e); - } + throw new InvalidRequestException("CQL2 has been removed in Cassandra 3.0. Please use CQL3 instead"); } - public CqlPreparedResult prepare_cql3_query(ByteBuffer query, Compression compression) - throws InvalidRequestException, TException + public CqlPreparedResult prepare_cql3_query(ByteBuffer query, Compression compression) throws TException { - if (logger.isDebugEnabled()) - logger.debug("prepare_cql3_query"); - - validateCQLVersion(3); + logger.debug("prepare_cql3_query"); String queryString = uncompress(query, compression); ThriftClientState cState = state(); @@ -2031,52 +1950,13 @@ public class CassandraServer implements Cassandra.Iface } } - public CqlResult execute_prepared_cql_query(int itemId, List<ByteBuffer> bindVariables) - throws InvalidRequestException, UnavailableException, TimedOutException, SchemaDisagreementException, TException + public CqlResult execute_prepared_cql_query(int itemId, List<ByteBuffer> bindVariables) throws TException { - validateCQLVersion(2); - maybeLogCQL2Warning(); - - 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_cql_query", Collections.<String, String>emptyMap()); - } - else - { - logger.debug("execute_prepared_cql_query"); - } - - try - { - ThriftClientState cState = state(); - 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); - - return QueryProcessor.processPrepared(statement, cState, bindVariables); - } - catch (RequestExecutionException e) - { - throw ThriftConversion.rethrow(e); - } - catch (RequestValidationException e) - { - throw ThriftConversion.toThrift(e); - } - finally - { - Tracing.instance.stopSession(); - } + throw new InvalidRequestException("CQL2 has been removed in Cassandra 3.0. Please use CQL3 instead"); } - public CqlResult execute_prepared_cql3_query(int itemId, List<ByteBuffer> bindVariables, ConsistencyLevel cLevel) - throws InvalidRequestException, UnavailableException, TimedOutException, SchemaDisagreementException, TException + public CqlResult execute_prepared_cql3_query(int itemId, List<ByteBuffer> bindVariables, ConsistencyLevel cLevel) throws TException { - validateCQLVersion(3); - if (startSessionIfRequested()) { // TODO we don't have [typed] access to CQL bind variables here. CASSANDRA-4560 is open to add support. @@ -2118,31 +1998,10 @@ public class CassandraServer implements Cassandra.Iface } /* - * Deprecated, but if a client sets CQL2, it is a no-op for compatibility sake. - * If it sets CQL3 however, we throw an IRE because this mean the client - * hasn't been updated for Cassandra 1.2 and should start using the new - * execute_cql3_query, etc... and there is no point no warning it early. + * No-op since 3.0. */ - public void set_cql_version(String version) throws InvalidRequestException + public void set_cql_version(String version) { - try - { - state().setCQLVersion(version); - } - catch (org.apache.cassandra.exceptions.InvalidRequestException e) - { - throw new InvalidRequestException(e.getMessage()); - } - } - - private void maybeLogCQL2Warning() - { - if (!loggedCQL2Warning) - { - logger.warn("CQL2 has been deprecated since Cassandra 2.0, and will be removed entirely in version 2.2." - + " Please switch to CQL3 before then."); - loggedCQL2Warning = true; - } } public ByteBuffer trace_next_query() throws TException http://git-wip-us.apache.org/repos/asf/cassandra/blob/26217071/src/java/org/apache/cassandra/thrift/ThriftClientState.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/thrift/ThriftClientState.java b/src/java/org/apache/cassandra/thrift/ThriftClientState.java index 56dcf6f..319169f 100644 --- a/src/java/org/apache/cassandra/thrift/ThriftClientState.java +++ b/src/java/org/apache/cassandra/thrift/ThriftClientState.java @@ -18,10 +18,8 @@ package org.apache.cassandra.thrift; import java.net.SocketAddress; -import java.util.*; import org.apache.cassandra.config.DatabaseDescriptor; -import org.apache.cassandra.cql.CQLStatement; import org.apache.cassandra.service.ClientState; import org.apache.cassandra.service.QueryState; @@ -34,19 +32,8 @@ import org.apache.cassandra.service.QueryState; */ public class ThriftClientState extends ClientState { - private static final int MAX_CACHE_PREPARED = 10000; // Enough to keep buggy clients from OOM'ing us - private final QueryState queryState; - // An LRU map of prepared statements - private final Map<Integer, CQLStatement> prepared = new LinkedHashMap<Integer, CQLStatement>(16, 0.75f, true) - { - protected boolean removeEldestEntry(Map.Entry<Integer, CQLStatement> eldest) - { - return size() > MAX_CACHE_PREPARED; - } - }; - public ThriftClientState(SocketAddress remoteAddress) { super(remoteAddress); @@ -58,11 +45,6 @@ public class ThriftClientState extends ClientState return queryState; } - public Map<Integer, CQLStatement> getPrepared() - { - return prepared; - } - public String getSchedulingValue() { switch(DatabaseDescriptor.getRequestSchedulerId()) http://git-wip-us.apache.org/repos/asf/cassandra/blob/26217071/src/java/org/apache/cassandra/transport/messages/StartupMessage.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/transport/messages/StartupMessage.java b/src/java/org/apache/cassandra/transport/messages/StartupMessage.java index d2b4350..5ae7a75 100644 --- a/src/java/org/apache/cassandra/transport/messages/StartupMessage.java +++ b/src/java/org/apache/cassandra/transport/messages/StartupMessage.java @@ -23,8 +23,6 @@ import java.util.Map; import org.jboss.netty.buffer.ChannelBuffer; import org.apache.cassandra.config.DatabaseDescriptor; -import org.apache.cassandra.exceptions.InvalidRequestException; -import org.apache.cassandra.service.ClientState; import org.apache.cassandra.service.QueryState; import org.apache.cassandra.transport.*; import org.apache.cassandra.utils.SemanticVersion; @@ -66,23 +64,20 @@ public class StartupMessage extends Message.Request public Message.Response execute(QueryState state) { - ClientState cState = state.getClientState(); String cqlVersion = options.get(CQL_VERSION); if (cqlVersion == null) throw new ProtocolException("Missing value CQL_VERSION in STARTUP message"); try { - cState.setCQLVersion(cqlVersion); + if (new SemanticVersion(cqlVersion).compareTo(new SemanticVersion("2.99.0")) < 0) + throw new ProtocolException(String.format("CQL version %s is not supported by the binary protocol (supported version are >= 3.0.0)", cqlVersion)); } - catch (InvalidRequestException e) + catch (IllegalArgumentException e) { throw new ProtocolException(e.getMessage()); } - if (cState.getCQLVersion().compareTo(new SemanticVersion("2.99.0")) < 0) - throw new ProtocolException(String.format("CQL version %s is not supported by the binary protocol (supported version are >= 3.0.0)", cqlVersion)); - if (options.containsKey(COMPRESSION)) { String compression = options.get(COMPRESSION).toLowerCase(); http://git-wip-us.apache.org/repos/asf/cassandra/blob/26217071/src/java/org/apache/cassandra/triggers/TriggerExecutor.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/triggers/TriggerExecutor.java b/src/java/org/apache/cassandra/triggers/TriggerExecutor.java index 91d0ea0..8d7f42b 100644 --- a/src/java/org/apache/cassandra/triggers/TriggerExecutor.java +++ b/src/java/org/apache/cassandra/triggers/TriggerExecutor.java @@ -28,9 +28,8 @@ import com.google.common.collect.Lists; import com.google.common.collect.Maps; import org.apache.cassandra.config.TriggerDefinition; -import org.apache.cassandra.cql.QueryProcessor; +import org.apache.cassandra.cql3.QueryProcessor; import org.apache.cassandra.db.*; -import org.apache.cassandra.db.composites.CellName; import org.apache.cassandra.exceptions.InvalidRequestException; import org.apache.cassandra.utils.FBUtilities; @@ -92,8 +91,8 @@ public class TriggerExecutor { QueryProcessor.validateKey(mutation.key()); for (ColumnFamily tcf : mutation.getColumnFamilies()) - for (CellName tName : tcf.getColumnNames()) - QueryProcessor.validateColumn(tcf.metadata(), tName, tcf.getColumn(tName).value()); + for (Cell cell : tcf) + cell.validateFields(tcf.metadata()); } } http://git-wip-us.apache.org/repos/asf/cassandra/blob/26217071/src/java/org/apache/cassandra/utils/UUIDGen.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/utils/UUIDGen.java b/src/java/org/apache/cassandra/utils/UUIDGen.java index f385744..e5ab7fe 100644 --- a/src/java/org/apache/cassandra/utils/UUIDGen.java +++ b/src/java/org/apache/cassandra/utils/UUIDGen.java @@ -165,27 +165,6 @@ public class UUIDGen } /** - * Converts a milliseconds-since-epoch timestamp into the 16 byte representation - * of a type 1 UUID (a time-based UUID). - * - * <p><i><b>Deprecated:</b> This method goes again the principle of a time - * UUID and should not be used. For queries based on timestamp, minTimeUUID() and - * maxTimeUUID() can be used but this method has questionable usefulness. This is - * only kept because CQL2 uses it (see TimeUUID.fromStringCQL2) and we - * don't want to break compatibility.</i></p> - * - * <p><i><b>Warning:</b> This method is not guaranteed to return unique UUIDs; Multiple - * invocations using identical timestamps will result in identical UUIDs.</i></p> - * - * @param timeMillis - * @return a type 1 UUID represented as a byte[] - */ - public static byte[] getTimeUUIDBytes(long timeMillis) - { - return createTimeUUIDBytes(instance.createTimeUnsafe(timeMillis)); - } - - /** * Converts a 100-nanoseconds precision timestamp into the 16 byte representation * of a type 1 UUID (a time-based UUID). * http://git-wip-us.apache.org/repos/asf/cassandra/blob/26217071/tools/stress/src/org/apache/cassandra/stress/Operation.java ---------------------------------------------------------------------- diff --git a/tools/stress/src/org/apache/cassandra/stress/Operation.java b/tools/stress/src/org/apache/cassandra/stress/Operation.java index 4519b19..198f7fe 100644 --- a/tools/stress/src/org/apache/cassandra/stress/Operation.java +++ b/tools/stress/src/org/apache/cassandra/stress/Operation.java @@ -131,10 +131,6 @@ public abstract class Operation { return settings.mode.cqlVersion == CqlVersion.CQL3; } - public boolean isCql2() - { - return settings.mode.cqlVersion == CqlVersion.CQL2; - } public Object getCqlCache() { return cqlCache; http://git-wip-us.apache.org/repos/asf/cassandra/blob/26217071/tools/stress/src/org/apache/cassandra/stress/operations/CqlCounterAdder.java ---------------------------------------------------------------------- diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/CqlCounterAdder.java b/tools/stress/src/org/apache/cassandra/stress/operations/CqlCounterAdder.java index aae99b5..910b6ed 100644 --- a/tools/stress/src/org/apache/cassandra/stress/operations/CqlCounterAdder.java +++ b/tools/stress/src/org/apache/cassandra/stress/operations/CqlCounterAdder.java @@ -35,12 +35,9 @@ public class CqlCounterAdder extends CqlOperation<Integer> @Override protected String buildQuery() { - String counterCF = state.isCql2() ? "Counter1" : "Counter3"; + String counterCF = "Counter3"; - StringBuilder query = new StringBuilder("UPDATE ").append(wrapInQuotesIfRequired(counterCF)); - - if (state.isCql2()) - query.append(" USING CONSISTENCY ").append(state.settings.command.consistencyLevel); + StringBuilder query = new StringBuilder("UPDATE ").append(wrapInQuotes(counterCF)); query.append(" SET "); http://git-wip-us.apache.org/repos/asf/cassandra/blob/26217071/tools/stress/src/org/apache/cassandra/stress/operations/CqlCounterGetter.java ---------------------------------------------------------------------- diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/CqlCounterGetter.java b/tools/stress/src/org/apache/cassandra/stress/operations/CqlCounterGetter.java index 31fd20d..6186667 100644 --- a/tools/stress/src/org/apache/cassandra/stress/operations/CqlCounterGetter.java +++ b/tools/stress/src/org/apache/cassandra/stress/operations/CqlCounterGetter.java @@ -42,21 +42,7 @@ public class CqlCounterGetter extends CqlOperation<Integer> @Override protected String buildQuery() { - StringBuilder query = new StringBuilder("SELECT "); - - if (state.isCql2()) - query.append("FIRST ").append(state.settings.columns.maxColumnsPerKey).append(" ''..''"); - else - query.append("*"); - - String counterCF = state.isCql2() ? "Counter1" : "Counter3"; - - query.append(" FROM ").append(wrapInQuotesIfRequired(counterCF)); - - if (state.isCql2()) - query.append(" USING CONSISTENCY ").append(state.settings.command.consistencyLevel); - - return query.append(" WHERE KEY=?").toString(); + return "SELECT * FROM \"Counter3\" USING CONSISTENCY " + state.settings.command.consistencyLevel + " WHERE KEY=?"; } @Override http://git-wip-us.apache.org/repos/asf/cassandra/blob/26217071/tools/stress/src/org/apache/cassandra/stress/operations/CqlIndexedRangeSlicer.java ---------------------------------------------------------------------- diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/CqlIndexedRangeSlicer.java b/tools/stress/src/org/apache/cassandra/stress/operations/CqlIndexedRangeSlicer.java index ff43322..25af04a 100644 --- a/tools/stress/src/org/apache/cassandra/stress/operations/CqlIndexedRangeSlicer.java +++ b/tools/stress/src/org/apache/cassandra/stress/operations/CqlIndexedRangeSlicer.java @@ -48,21 +48,10 @@ public class CqlIndexedRangeSlicer extends CqlOperation<byte[][]> @Override protected String buildQuery() { - StringBuilder query = new StringBuilder("SELECT "); - - if (state.isCql2()) - query.append(state.settings.columns.maxColumnsPerKey).append(" ''..''"); - else - query.append("*"); - - query.append(" FROM Standard1"); - - if (state.isCql2()) - query.append(" USING CONSISTENCY ").append(state.settings.command.consistencyLevel); - + StringBuilder query = new StringBuilder("SELECT * FROM \"Standard1\""); final String columnName = getColumnName(1); query.append(" WHERE ").append(columnName).append("=?") - .append(" AND KEY > ? LIMIT ").append(((SettingsCommandMulti)state.settings.command).keysAtOnce); + .append(" AND KEY > ? LIMIT ").append(((SettingsCommandMulti)state.settings.command).keysAtOnce); return query.toString(); } http://git-wip-us.apache.org/repos/asf/cassandra/blob/26217071/tools/stress/src/org/apache/cassandra/stress/operations/CqlInserter.java ---------------------------------------------------------------------- diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/CqlInserter.java b/tools/stress/src/org/apache/cassandra/stress/operations/CqlInserter.java index 8d964f5..1f8987d 100644 --- a/tools/stress/src/org/apache/cassandra/stress/operations/CqlInserter.java +++ b/tools/stress/src/org/apache/cassandra/stress/operations/CqlInserter.java @@ -38,10 +38,7 @@ public class CqlInserter extends CqlOperation<Integer> @Override protected String buildQuery() { - StringBuilder query = new StringBuilder("UPDATE ").append(wrapInQuotesIfRequired(state.settings.schema.columnFamily)); - - if (state.isCql2()) - query.append(" USING CONSISTENCY ").append(state.settings.command.consistencyLevel); + StringBuilder query = new StringBuilder("UPDATE ").append(wrapInQuotes(state.settings.schema.columnFamily)); query.append(" SET "); @@ -55,12 +52,12 @@ public class CqlInserter extends CqlOperation<Integer> if (state.isCql3()) throw new UnsupportedOperationException("Cannot use UUIDs in column names with CQL3"); - query.append(wrapInQuotesIfRequired(UUIDGen.getTimeUUID().toString())) + query.append(wrapInQuotes(UUIDGen.getTimeUUID().toString())) .append(" = ?"); } else { - query.append(wrapInQuotesIfRequired("C" + i)).append(" = ?"); + query.append(wrapInQuotes("C" + i)).append(" = ?"); } } http://git-wip-us.apache.org/repos/asf/cassandra/blob/26217071/tools/stress/src/org/apache/cassandra/stress/operations/CqlOperation.java ---------------------------------------------------------------------- diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/CqlOperation.java b/tools/stress/src/org/apache/cassandra/stress/operations/CqlOperation.java index b17f520..8674cc0 100644 --- a/tools/stress/src/org/apache/cassandra/stress/operations/CqlOperation.java +++ b/tools/stress/src/org/apache/cassandra/stress/operations/CqlOperation.java @@ -268,10 +268,7 @@ public abstract class CqlOperation<V> extends Operation public ClientWrapper wrap(ThriftClient client) { - return state.isCql3() - ? new Cql3CassandraClientWrapper(client) - : new Cql2CassandraClientWrapper(client); - + return new Cql3CassandraClientWrapper(client); } public ClientWrapper wrap(JavaDriverClient client) @@ -302,7 +299,7 @@ public abstract class CqlOperation<V> extends Operation @Override public <V> V execute(String query, ByteBuffer key, List<ByteBuffer> queryParams, ResultHandler<V> handler) { - String formattedQuery = formatCqlQuery(query, queryParams, state.isCql3()); + String formattedQuery = formatCqlQuery(query, queryParams); return handler.javaDriverHandler().apply(client.execute(formattedQuery, ThriftConversion.fromThrift(state.settings.command.consistencyLevel))); } @@ -334,7 +331,7 @@ public abstract class CqlOperation<V> extends Operation @Override public <V> V execute(String query, ByteBuffer key, List<ByteBuffer> queryParams, ResultHandler<V> handler) { - String formattedQuery = formatCqlQuery(query, queryParams, state.isCql3()); + String formattedQuery = formatCqlQuery(query, queryParams); return handler.thriftHandler().apply(client.execute(formattedQuery, ThriftConversion.fromThrift(state.settings.command.consistencyLevel))); } @@ -367,7 +364,7 @@ public abstract class CqlOperation<V> extends Operation @Override public <V> V execute(String query, ByteBuffer key, List<ByteBuffer> queryParams, ResultHandler<V> handler) throws TException { - String formattedQuery = formatCqlQuery(query, queryParams, true); + String formattedQuery = formatCqlQuery(query, queryParams); return handler.simpleNativeHandler().apply( client.execute_cql3_query(formattedQuery, key, Compression.NONE, state.settings.command.consistencyLevel) ); @@ -389,40 +386,6 @@ public abstract class CqlOperation<V> extends Operation } } - // client wrapper for Cql2 - private final class Cql2CassandraClientWrapper implements ClientWrapper - { - final ThriftClient client; - private Cql2CassandraClientWrapper(ThriftClient client) - { - this.client = client; - } - - @Override - public <V> V execute(String query, ByteBuffer key, List<ByteBuffer> queryParams, ResultHandler<V> handler) throws TException - { - String formattedQuery = formatCqlQuery(query, queryParams, false); - return handler.simpleNativeHandler().apply( - client.execute_cql_query(formattedQuery, key, Compression.NONE) - ); - } - - @Override - public <V> V execute(Object preparedStatementId, ByteBuffer key, List<ByteBuffer> queryParams, ResultHandler<V> handler) throws TException - { - Integer id = (Integer) preparedStatementId; - return handler.simpleNativeHandler().apply( - client.execute_prepared_cql_query(id, key, queryParams) - ); - } - - @Override - public Object createPreparedStatement(String cqlQuery) throws TException - { - return client.prepare_cql_query(cqlQuery, Compression.NONE); - } - } - // interface for building functions to standardise results from each client protected static interface ResultHandler<V> { @@ -632,11 +595,9 @@ public abstract class CqlOperation<V> extends Operation } - private static String getUnQuotedCqlBlob(ByteBuffer term, boolean isCQL3) + private static String getUnQuotedCqlBlob(ByteBuffer term) { - return isCQL3 - ? "0x" + ByteBufferUtil.bytesToHex(term) - : ByteBufferUtil.bytesToHex(term); + return "0x" + ByteBufferUtil.bytesToHex(term); } /** @@ -647,7 +608,7 @@ public abstract class CqlOperation<V> extends Operation * @param parms sequence of string query parameters * @return formatted CQL query string */ - private static String formatCqlQuery(String query, List<ByteBuffer> parms, boolean isCql3) + private static String formatCqlQuery(String query, List<ByteBuffer> parms) { int marker, position = 0; StringBuilder result = new StringBuilder(); @@ -658,7 +619,7 @@ public abstract class CqlOperation<V> extends Operation for (ByteBuffer parm : parms) { result.append(query.substring(position, marker)); - result.append(getUnQuotedCqlBlob(parm, isCql3)); + result.append(getUnQuotedCqlBlob(parm)); position = marker + 1; if (-1 == (marker = query.indexOf('?', position + 1))) @@ -671,11 +632,9 @@ public abstract class CqlOperation<V> extends Operation return result.toString(); } - protected String wrapInQuotesIfRequired(String string) + protected String wrapInQuotes(String string) { - return state.settings.mode.cqlVersion == CqlVersion.CQL3 - ? "\"" + string + "\"" - : string; + return "\"" + string + "\""; } } http://git-wip-us.apache.org/repos/asf/cassandra/blob/26217071/tools/stress/src/org/apache/cassandra/stress/operations/CqlRangeSlicer.java ---------------------------------------------------------------------- diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/CqlRangeSlicer.java b/tools/stress/src/org/apache/cassandra/stress/operations/CqlRangeSlicer.java index 76ba966..cce47fc 100644 --- a/tools/stress/src/org/apache/cassandra/stress/operations/CqlRangeSlicer.java +++ b/tools/stress/src/org/apache/cassandra/stress/operations/CqlRangeSlicer.java @@ -41,13 +41,7 @@ public class CqlRangeSlicer extends CqlOperation<Integer> @Override protected String buildQuery() { - StringBuilder query = new StringBuilder("SELECT FIRST ").append(state.settings.columns.maxColumnsPerKey) - .append(" ''..'' FROM ").append(state.settings.schema.columnFamily); - - if (state.isCql2()) - query.append(" USING CONSISTENCY ").append(state.settings.command.consistencyLevel); - - return query.append(" WHERE KEY > ?").toString(); + return "SELECT FIRST " + state.settings.columns.maxColumnsPerKey + " ''..'' FROM " + state.settings.schema.columnFamily + " WHERE KEY > ?"; } @Override http://git-wip-us.apache.org/repos/asf/cassandra/blob/26217071/tools/stress/src/org/apache/cassandra/stress/operations/CqlReader.java ---------------------------------------------------------------------- diff --git a/tools/stress/src/org/apache/cassandra/stress/operations/CqlReader.java b/tools/stress/src/org/apache/cassandra/stress/operations/CqlReader.java index 44da43f..aa949d4 100644 --- a/tools/stress/src/org/apache/cassandra/stress/operations/CqlReader.java +++ b/tools/stress/src/org/apache/cassandra/stress/operations/CqlReader.java @@ -42,10 +42,7 @@ public class CqlReader extends CqlOperation<ByteBuffer[][]> if (state.settings.columns.names == null) { - if (state.isCql2()) - query.append("FIRST ").append(state.settings.columns.maxColumnsPerKey).append(" ''..''"); - else - query.append("*"); + query.append("*"); } else { @@ -57,10 +54,8 @@ public class CqlReader extends CqlOperation<ByteBuffer[][]> } } - query.append(" FROM ").append(wrapInQuotesIfRequired(state.settings.schema.columnFamily)); + query.append(" FROM ").append(wrapInQuotes(state.settings.schema.columnFamily)); - if (state.isCql2()) - query.append(" USING CONSISTENCY ").append(state.settings.command.consistencyLevel); query.append(" WHERE KEY=?"); return query.toString(); } http://git-wip-us.apache.org/repos/asf/cassandra/blob/26217071/tools/stress/src/org/apache/cassandra/stress/settings/CqlVersion.java ---------------------------------------------------------------------- diff --git a/tools/stress/src/org/apache/cassandra/stress/settings/CqlVersion.java b/tools/stress/src/org/apache/cassandra/stress/settings/CqlVersion.java index d7d09f6..1e963c7 100644 --- a/tools/stress/src/org/apache/cassandra/stress/settings/CqlVersion.java +++ b/tools/stress/src/org/apache/cassandra/stress/settings/CqlVersion.java @@ -25,7 +25,6 @@ public enum CqlVersion { NOCQL(null), - CQL2("2.0.0"), CQL3("3.0.0"); public final String connectVersion; @@ -41,8 +40,6 @@ public enum CqlVersion return NOCQL; switch(version.charAt(0)) { - case '2': - return CQL2; case '3': return CQL3; default: @@ -55,11 +52,6 @@ public enum CqlVersion return this != NOCQL; } - public boolean isCql2() - { - return this == CQL2; - } - public boolean isCql3() { return this == CQL3; http://git-wip-us.apache.org/repos/asf/cassandra/blob/26217071/tools/stress/src/org/apache/cassandra/stress/settings/Legacy.java ---------------------------------------------------------------------- diff --git a/tools/stress/src/org/apache/cassandra/stress/settings/Legacy.java b/tools/stress/src/org/apache/cassandra/stress/settings/Legacy.java index 5c793e6..5ddb346 100644 --- a/tools/stress/src/org/apache/cassandra/stress/settings/Legacy.java +++ b/tools/stress/src/org/apache/cassandra/stress/settings/Legacy.java @@ -60,7 +60,6 @@ public class Legacy implements Serializable availableOptions.addOption("i", "progress-interval", true, "Progress Report Interval (seconds), default:10"); availableOptions.addOption("g", "keys-per-call", true, "Number of keys to get_range_slices or multiget per call, default:1000"); availableOptions.addOption("l", "replication-factor", true, "Replication Factor to use when creating needed column families, default:1"); - availableOptions.addOption("L", "enable-cql", false, "Perform queries using CQL2 (Cassandra Query Language v 2.0.0)"); availableOptions.addOption("L3", "enable-cql3", false, "Perform queries using CQL3 (Cassandra Query Language v 3.0.0)"); availableOptions.addOption("b", "enable-native-protocol", false, "Use the binary native protocol (only work along with -L3)"); availableOptions.addOption("P", "use-prepared-statements", false, "Perform queries using prepared statements (only applicable to CQL)."); @@ -233,9 +232,7 @@ public class Legacy implements Serializable r.add("-schema", "replication(" + rep + ")"); } - if (cmd.hasOption("L")) - r.add("-mode", cmd.hasOption("P") ? "prepared cql2" : "cql2"); - else if (cmd.hasOption("L3")) + if (cmd.hasOption("L3")) r.add("-mode", (cmd.hasOption("P") ? "prepared" : "") + (cmd.hasOption("b") ? "native" : "") + "cql3"); else r.add("-mode", "thrift"); http://git-wip-us.apache.org/repos/asf/cassandra/blob/26217071/tools/stress/src/org/apache/cassandra/stress/settings/SettingsMode.java ---------------------------------------------------------------------- diff --git a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsMode.java b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsMode.java index eef8c39..93cfe05 100644 --- a/tools/stress/src/org/apache/cassandra/stress/settings/SettingsMode.java +++ b/tools/stress/src/org/apache/cassandra/stress/settings/SettingsMode.java @@ -54,14 +54,6 @@ public class SettingsMode implements Serializable style = opts.usePrepared.setByUser() ? ConnectionStyle.CQL_PREPARED : ConnectionStyle.CQL; compression = ProtocolOptions.Compression.NONE.name(); } - else if (options instanceof Cql2Options) - { - cqlVersion = CqlVersion.CQL2; - api = ConnectionAPI.THRIFT; - Cql2Options opts = (Cql2Options) options; - style = opts.usePrepared.setByUser() ? ConnectionStyle.CQL_PREPARED : ConnectionStyle.CQL; - compression = ProtocolOptions.Compression.NONE.name(); - } else if (options instanceof ThriftOptions) { ThriftOptions opts = (ThriftOptions) options; @@ -110,18 +102,6 @@ public class SettingsMode implements Serializable } } - private static final class Cql2Options extends GroupedOptions - { - final OptionSimple api = new OptionSimple("cql2", "", null, "", true); - final OptionSimple usePrepared = new OptionSimple("prepared", "", null, "", false); - - @Override - public List<? extends Option> options() - { - return Arrays.asList(usePrepared, api); - } - } - private static final class ThriftOptions extends GroupedOptions { final OptionSimple api = new OptionSimple("thrift", "", null, "", true); @@ -146,7 +126,7 @@ public class SettingsMode implements Serializable return new SettingsMode(opts); } - GroupedOptions options = GroupedOptions.select(params, new ThriftOptions(), new Cql2Options(), new Cql3Options(), new Cql3SimpleNativeOptions()); + GroupedOptions options = GroupedOptions.select(params, new ThriftOptions(), new Cql3Options(), new Cql3SimpleNativeOptions()); if (options == null) { printHelp(); @@ -158,7 +138,7 @@ public class SettingsMode implements Serializable public static void printHelp() { - GroupedOptions.printOptions(System.out, "-mode", new ThriftOptions(), new Cql2Options(), new Cql3Options(), new Cql3SimpleNativeOptions()); + GroupedOptions.printOptions(System.out, "-mode", new ThriftOptions(), new Cql3Options(), new Cql3SimpleNativeOptions()); } public static Runnable helpPrinter()
