http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/transport/messages/CredentialsMessage.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/transport/messages/CredentialsMessage.java b/src/java/org/apache/cassandra/transport/messages/CredentialsMessage.java index 4ecaffd..764d992 100644 --- a/src/java/org/apache/cassandra/transport/messages/CredentialsMessage.java +++ b/src/java/org/apache/cassandra/transport/messages/CredentialsMessage.java @@ -29,6 +29,7 @@ import org.apache.cassandra.service.QueryState; import org.apache.cassandra.transport.CBUtil; import org.apache.cassandra.transport.Message; import org.apache.cassandra.transport.ProtocolException; +import org.apache.cassandra.transport.ProtocolVersion; /** * Message to indicate that the server is ready to receive requests. @@ -37,9 +38,9 @@ public class CredentialsMessage extends Message.Request { public static final Message.Codec<CredentialsMessage> codec = new Message.Codec<CredentialsMessage>() { - public CredentialsMessage decode(ByteBuf body, int version) + public CredentialsMessage decode(ByteBuf body, ProtocolVersion version) { - if (version > 1) + if (version.isGreaterThan(ProtocolVersion.V1)) throw new ProtocolException("Legacy credentials authentication is not supported in " + "protocol versions > 1. Please use SASL authentication via a SaslResponse message"); @@ -47,12 +48,12 @@ public class CredentialsMessage extends Message.Request return new CredentialsMessage(credentials); } - public void encode(CredentialsMessage msg, ByteBuf dest, int version) + public void encode(CredentialsMessage msg, ByteBuf dest, ProtocolVersion version) { CBUtil.writeStringMap(msg.credentials, dest); } - public int encodedSize(CredentialsMessage msg, int version) + public int encodedSize(CredentialsMessage msg, ProtocolVersion version) { return CBUtil.sizeOfStringMap(msg.credentials); }
http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/transport/messages/ErrorMessage.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/transport/messages/ErrorMessage.java b/src/java/org/apache/cassandra/transport/messages/ErrorMessage.java index 5ce248f..ac4b3dc 100644 --- a/src/java/org/apache/cassandra/transport/messages/ErrorMessage.java +++ b/src/java/org/apache/cassandra/transport/messages/ErrorMessage.java @@ -45,7 +45,7 @@ public class ErrorMessage extends Message.Response public static final Message.Codec<ErrorMessage> codec = new Message.Codec<ErrorMessage>() { - public ErrorMessage decode(ByteBuf body, int version) + public ErrorMessage decode(ByteBuf body, ProtocolVersion version) { ExceptionCode code = ExceptionCode.fromValue(body.readInt()); String msg = CBUtil.readString(body); @@ -89,7 +89,7 @@ public class ErrorMessage extends Message.Response int failure = body.readInt(); Map<InetAddress, RequestFailureReason> failureReasonByEndpoint = new ConcurrentHashMap<>(); - if (version >= Server.VERSION_5) + if (version.isGreaterOrEqualTo(ProtocolVersion.V5)) { for (int i = 0; i < failure; i++) { @@ -163,7 +163,7 @@ public class ErrorMessage extends Message.Response return new ErrorMessage(te); } - public void encode(ErrorMessage msg, ByteBuf dest, int version) + public void encode(ErrorMessage msg, ByteBuf dest, ProtocolVersion version) { final TransportException err = getBackwardsCompatibleException(msg, version); dest.writeInt(err.code().value); @@ -190,7 +190,7 @@ public class ErrorMessage extends Message.Response // The number of failures is also present in protocol v5, but used instead to specify the size of the failure map dest.writeInt(rfe.failureReasonByEndpoint.size()); - if (version >= Server.VERSION_5) + if (version.isGreaterOrEqualTo(ProtocolVersion.V5)) { for (Map.Entry<InetAddress, RequestFailureReason> entry : rfe.failureReasonByEndpoint.entrySet()) { @@ -236,7 +236,7 @@ public class ErrorMessage extends Message.Response } } - public int encodedSize(ErrorMessage msg, int version) + public int encodedSize(ErrorMessage msg, ProtocolVersion version) { final TransportException err = getBackwardsCompatibleException(msg, version); String errorString = err.getMessage() == null ? "" : err.getMessage(); @@ -255,7 +255,7 @@ public class ErrorMessage extends Message.Response size += CBUtil.sizeOfConsistencyLevel(rfe.consistency) + 4 + 4 + 4; size += isWrite ? CBUtil.sizeOfString(((WriteFailureException)rfe).writeType.toString()) : 1; - if (version >= Server.VERSION_5) + if (version.isGreaterOrEqualTo(ProtocolVersion.V5)) { for (Map.Entry<InetAddress, RequestFailureReason> entry : rfe.failureReasonByEndpoint.entrySet()) { @@ -292,9 +292,9 @@ public class ErrorMessage extends Message.Response } }; - private static TransportException getBackwardsCompatibleException(ErrorMessage msg, int version) + private static TransportException getBackwardsCompatibleException(ErrorMessage msg, ProtocolVersion version) { - if (version < Server.VERSION_4) + if (version.isSmallerThan(ProtocolVersion.V4)) { switch (msg.error.code()) { @@ -370,11 +370,11 @@ public class ErrorMessage extends Message.Response ErrorMessage message = new ErrorMessage((TransportException) e, streamId); if (e instanceof ProtocolException) { - // if the driver attempted to connect with a protocol version lower than the minimum supported - // version, respond with a protocol error message with the correct frame header for that version - Integer attemptedLowProtocolVersion = ((ProtocolException) e).getAttemptedLowProtocolVersion(); - if (attemptedLowProtocolVersion != null) - message.forcedProtocolVersion = attemptedLowProtocolVersion; + // if the driver attempted to connect with a protocol version not supported then + // reply with the appropiate version, see ProtocolVersion.decode() + ProtocolVersion forcedProtocolVersion = ((ProtocolException) e).getForcedProtocolVersion(); + if (forcedProtocolVersion != null) + message.forcedProtocolVersion = forcedProtocolVersion; } return message; } http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/transport/messages/EventMessage.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/transport/messages/EventMessage.java b/src/java/org/apache/cassandra/transport/messages/EventMessage.java index f3ab526..0af9e14 100644 --- a/src/java/org/apache/cassandra/transport/messages/EventMessage.java +++ b/src/java/org/apache/cassandra/transport/messages/EventMessage.java @@ -21,22 +21,23 @@ import io.netty.buffer.ByteBuf; import org.apache.cassandra.transport.Event; import org.apache.cassandra.transport.Message; +import org.apache.cassandra.transport.ProtocolVersion; public class EventMessage extends Message.Response { public static final Message.Codec<EventMessage> codec = new Message.Codec<EventMessage>() { - public EventMessage decode(ByteBuf body, int version) + public EventMessage decode(ByteBuf body, ProtocolVersion version) { return new EventMessage(Event.deserialize(body, version)); } - public void encode(EventMessage msg, ByteBuf dest, int version) + public void encode(EventMessage msg, ByteBuf dest, ProtocolVersion version) { msg.event.serialize(dest, version); } - public int encodedSize(EventMessage msg, int version) + public int encodedSize(EventMessage msg, ProtocolVersion version) { return msg.event.serializedSize(version); } http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/transport/messages/ExecuteMessage.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/transport/messages/ExecuteMessage.java b/src/java/org/apache/cassandra/transport/messages/ExecuteMessage.java index 088f278..d881e63 100644 --- a/src/java/org/apache/cassandra/transport/messages/ExecuteMessage.java +++ b/src/java/org/apache/cassandra/transport/messages/ExecuteMessage.java @@ -40,16 +40,16 @@ public class ExecuteMessage extends Message.Request { public static final Message.Codec<ExecuteMessage> codec = new Message.Codec<ExecuteMessage>() { - public ExecuteMessage decode(ByteBuf body, int version) + public ExecuteMessage decode(ByteBuf body, ProtocolVersion version) { byte[] id = CBUtil.readBytes(body); return new ExecuteMessage(MD5Digest.wrap(id), QueryOptions.codec.decode(body, version)); } - public void encode(ExecuteMessage msg, ByteBuf dest, int version) + public void encode(ExecuteMessage msg, ByteBuf dest, ProtocolVersion version) { CBUtil.writeBytes(msg.statementId.bytes, dest); - if (version == 1) + if (version == ProtocolVersion.V1) { CBUtil.writeValueList(msg.options.getValues(), dest); CBUtil.writeConsistencyLevel(msg.options.getConsistency(), dest); @@ -60,11 +60,11 @@ public class ExecuteMessage extends Message.Request } } - public int encodedSize(ExecuteMessage msg, int version) + public int encodedSize(ExecuteMessage msg, ProtocolVersion version) { int size = 0; size += CBUtil.sizeOfBytes(msg.statementId.bytes); - if (version == 1) + if (version == ProtocolVersion.V1) { size += CBUtil.sizeOfValueList(msg.options.getValues()); size += CBUtil.sizeOfConsistencyLevel(msg.options.getConsistency()); http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/transport/messages/OptionsMessage.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/transport/messages/OptionsMessage.java b/src/java/org/apache/cassandra/transport/messages/OptionsMessage.java index 4e95342..914ccb1 100644 --- a/src/java/org/apache/cassandra/transport/messages/OptionsMessage.java +++ b/src/java/org/apache/cassandra/transport/messages/OptionsMessage.java @@ -28,6 +28,7 @@ import org.apache.cassandra.cql3.QueryProcessor; import org.apache.cassandra.service.QueryState; import org.apache.cassandra.transport.FrameCompressor; import org.apache.cassandra.transport.Message; +import org.apache.cassandra.transport.ProtocolVersion; /** * Message to indicate that the server is ready to receive requests. @@ -36,16 +37,16 @@ public class OptionsMessage extends Message.Request { public static final Message.Codec<OptionsMessage> codec = new Message.Codec<OptionsMessage>() { - public OptionsMessage decode(ByteBuf body, int version) + public OptionsMessage decode(ByteBuf body, ProtocolVersion version) { return new OptionsMessage(); } - public void encode(OptionsMessage msg, ByteBuf dest, int version) + public void encode(OptionsMessage msg, ByteBuf dest, ProtocolVersion version) { } - public int encodedSize(OptionsMessage msg, int version) + public int encodedSize(OptionsMessage msg, ProtocolVersion version) { return 0; } @@ -70,6 +71,7 @@ public class OptionsMessage extends Message.Request Map<String, List<String>> supported = new HashMap<String, List<String>>(); supported.put(StartupMessage.CQL_VERSION, cqlVersions); supported.put(StartupMessage.COMPRESSION, compressions); + supported.put(StartupMessage.PROTOCOL_VERSIONS, ProtocolVersion.supportedVersions()); return new SupportedMessage(supported); } http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/transport/messages/PrepareMessage.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/transport/messages/PrepareMessage.java b/src/java/org/apache/cassandra/transport/messages/PrepareMessage.java index f5192de..b0c9dbe 100644 --- a/src/java/org/apache/cassandra/transport/messages/PrepareMessage.java +++ b/src/java/org/apache/cassandra/transport/messages/PrepareMessage.java @@ -33,18 +33,18 @@ public class PrepareMessage extends Message.Request { public static final Message.Codec<PrepareMessage> codec = new Message.Codec<PrepareMessage>() { - public PrepareMessage decode(ByteBuf body, int version) + public PrepareMessage decode(ByteBuf body, ProtocolVersion version) { String query = CBUtil.readLongString(body); return new PrepareMessage(query); } - public void encode(PrepareMessage msg, ByteBuf dest, int version) + public void encode(PrepareMessage msg, ByteBuf dest, ProtocolVersion version) { CBUtil.writeLongString(msg.query, dest); } - public int encodedSize(PrepareMessage msg, int version) + public int encodedSize(PrepareMessage msg, ProtocolVersion version) { return CBUtil.sizeOfLongString(msg.query); } http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/transport/messages/QueryMessage.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/transport/messages/QueryMessage.java b/src/java/org/apache/cassandra/transport/messages/QueryMessage.java index 2bd5efc..25d4e9e 100644 --- a/src/java/org/apache/cassandra/transport/messages/QueryMessage.java +++ b/src/java/org/apache/cassandra/transport/messages/QueryMessage.java @@ -31,6 +31,7 @@ import org.apache.cassandra.tracing.Tracing; import org.apache.cassandra.transport.CBUtil; import org.apache.cassandra.transport.Message; import org.apache.cassandra.transport.ProtocolException; +import org.apache.cassandra.transport.ProtocolVersion; import org.apache.cassandra.utils.JVMStabilityInspector; import org.apache.cassandra.utils.UUIDGen; @@ -41,26 +42,26 @@ public class QueryMessage extends Message.Request { public static final Message.Codec<QueryMessage> codec = new Message.Codec<QueryMessage>() { - public QueryMessage decode(ByteBuf body, int version) + public QueryMessage decode(ByteBuf body, ProtocolVersion version) { String query = CBUtil.readLongString(body); return new QueryMessage(query, QueryOptions.codec.decode(body, version)); } - public void encode(QueryMessage msg, ByteBuf dest, int version) + public void encode(QueryMessage msg, ByteBuf dest, ProtocolVersion version) { CBUtil.writeLongString(msg.query, dest); - if (version == 1) + if (version == ProtocolVersion.V1) CBUtil.writeConsistencyLevel(msg.options.getConsistency(), dest); else QueryOptions.codec.encode(msg.options, dest, version); } - public int encodedSize(QueryMessage msg, int version) + public int encodedSize(QueryMessage msg, ProtocolVersion version) { int size = CBUtil.sizeOfLongString(msg.query); - if (version == 1) + if (version == ProtocolVersion.V1) { size += CBUtil.sizeOfConsistencyLevel(msg.options.getConsistency()); } http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/transport/messages/ReadyMessage.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/transport/messages/ReadyMessage.java b/src/java/org/apache/cassandra/transport/messages/ReadyMessage.java index f0a4681..2ee8881 100644 --- a/src/java/org/apache/cassandra/transport/messages/ReadyMessage.java +++ b/src/java/org/apache/cassandra/transport/messages/ReadyMessage.java @@ -20,6 +20,7 @@ package org.apache.cassandra.transport.messages; import io.netty.buffer.ByteBuf; import org.apache.cassandra.transport.Message; +import org.apache.cassandra.transport.ProtocolVersion; /** * Message to indicate that the server is ready to receive requests. @@ -28,16 +29,16 @@ public class ReadyMessage extends Message.Response { public static final Message.Codec<ReadyMessage> codec = new Message.Codec<ReadyMessage>() { - public ReadyMessage decode(ByteBuf body, int version) + public ReadyMessage decode(ByteBuf body, ProtocolVersion version) { return new ReadyMessage(); } - public void encode(ReadyMessage msg, ByteBuf dest, int version) + public void encode(ReadyMessage msg, ByteBuf dest, ProtocolVersion version) { } - public int encodedSize(ReadyMessage msg, int version) + public int encodedSize(ReadyMessage msg, ProtocolVersion version) { return 0; } http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/transport/messages/RegisterMessage.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/transport/messages/RegisterMessage.java b/src/java/org/apache/cassandra/transport/messages/RegisterMessage.java index c8e48b0..2356dae 100644 --- a/src/java/org/apache/cassandra/transport/messages/RegisterMessage.java +++ b/src/java/org/apache/cassandra/transport/messages/RegisterMessage.java @@ -29,7 +29,7 @@ public class RegisterMessage extends Message.Request { public static final Message.Codec<RegisterMessage> codec = new Message.Codec<RegisterMessage>() { - public RegisterMessage decode(ByteBuf body, int version) + public RegisterMessage decode(ByteBuf body, ProtocolVersion version) { int length = body.readUnsignedShort(); List<Event.Type> eventTypes = new ArrayList<>(length); @@ -38,14 +38,14 @@ public class RegisterMessage extends Message.Request return new RegisterMessage(eventTypes); } - public void encode(RegisterMessage msg, ByteBuf dest, int version) + public void encode(RegisterMessage msg, ByteBuf dest, ProtocolVersion version) { dest.writeShort(msg.eventTypes.size()); for (Event.Type type : msg.eventTypes) CBUtil.writeEnumValue(type, dest); } - public int encodedSize(RegisterMessage msg, int version) + public int encodedSize(RegisterMessage msg, ProtocolVersion version) { int size = 2; for (Event.Type type : msg.eventTypes) @@ -69,7 +69,7 @@ public class RegisterMessage extends Message.Request assert tracker instanceof Server.ConnectionTracker; for (Event.Type type : eventTypes) { - if (type.minimumVersion > connection.getVersion()) + if (type.minimumVersion.isGreaterThan(connection.getVersion())) throw new ProtocolException("Event " + type.name() + " not valid for protocol version " + connection.getVersion()); ((Server.ConnectionTracker) tracker).register(type, connection().channel()); } http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/transport/messages/ResultMessage.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/transport/messages/ResultMessage.java b/src/java/org/apache/cassandra/transport/messages/ResultMessage.java index b76243f..05a1276 100644 --- a/src/java/org/apache/cassandra/transport/messages/ResultMessage.java +++ b/src/java/org/apache/cassandra/transport/messages/ResultMessage.java @@ -36,19 +36,19 @@ public abstract class ResultMessage extends Message.Response { public static final Message.Codec<ResultMessage> codec = new Message.Codec<ResultMessage>() { - public ResultMessage decode(ByteBuf body, int version) + public ResultMessage decode(ByteBuf body, ProtocolVersion version) { Kind kind = Kind.fromId(body.readInt()); return kind.subcodec.decode(body, version); } - public void encode(ResultMessage msg, ByteBuf dest, int version) + public void encode(ResultMessage msg, ByteBuf dest, ProtocolVersion version) { dest.writeInt(msg.kind.id); msg.kind.subcodec.encode(msg, dest, version); } - public int encodedSize(ResultMessage msg, int version) + public int encodedSize(ResultMessage msg, ProtocolVersion version) { return 4 + msg.kind.subcodec.encodedSize(msg, version); } @@ -116,17 +116,17 @@ public abstract class ResultMessage extends Message.Response public static final Message.Codec<ResultMessage> subcodec = new Message.Codec<ResultMessage>() { - public ResultMessage decode(ByteBuf body, int version) + public ResultMessage decode(ByteBuf body, ProtocolVersion version) { return new Void(); } - public void encode(ResultMessage msg, ByteBuf dest, int version) + public void encode(ResultMessage msg, ByteBuf dest, ProtocolVersion version) { assert msg instanceof Void; } - public int encodedSize(ResultMessage msg, int version) + public int encodedSize(ResultMessage msg, ProtocolVersion version) { return 0; } @@ -156,19 +156,19 @@ public abstract class ResultMessage extends Message.Response public static final Message.Codec<ResultMessage> subcodec = new Message.Codec<ResultMessage>() { - public ResultMessage decode(ByteBuf body, int version) + public ResultMessage decode(ByteBuf body, ProtocolVersion version) { String keyspace = CBUtil.readString(body); return new SetKeyspace(keyspace); } - public void encode(ResultMessage msg, ByteBuf dest, int version) + public void encode(ResultMessage msg, ByteBuf dest, ProtocolVersion version) { assert msg instanceof SetKeyspace; CBUtil.writeString(((SetKeyspace)msg).keyspace, dest); } - public int encodedSize(ResultMessage msg, int version) + public int encodedSize(ResultMessage msg, ProtocolVersion version) { assert msg instanceof SetKeyspace; return CBUtil.sizeOfString(((SetKeyspace)msg).keyspace); @@ -191,19 +191,19 @@ public abstract class ResultMessage extends Message.Response { public static final Message.Codec<ResultMessage> subcodec = new Message.Codec<ResultMessage>() { - public ResultMessage decode(ByteBuf body, int version) + public ResultMessage decode(ByteBuf body, ProtocolVersion version) { return new Rows(ResultSet.codec.decode(body, version)); } - public void encode(ResultMessage msg, ByteBuf dest, int version) + public void encode(ResultMessage msg, ByteBuf dest, ProtocolVersion version) { assert msg instanceof Rows; Rows rowMsg = (Rows)msg; ResultSet.codec.encode(rowMsg.result, dest, version); } - public int encodedSize(ResultMessage msg, int version) + public int encodedSize(ResultMessage msg, ProtocolVersion version) { assert msg instanceof Rows; Rows rowMsg = (Rows)msg; @@ -235,19 +235,19 @@ public abstract class ResultMessage extends Message.Response { public static final Message.Codec<ResultMessage> subcodec = new Message.Codec<ResultMessage>() { - public ResultMessage decode(ByteBuf body, int version) + public ResultMessage decode(ByteBuf body, ProtocolVersion version) { MD5Digest id = MD5Digest.wrap(CBUtil.readBytes(body)); ResultSet.PreparedMetadata metadata = ResultSet.PreparedMetadata.codec.decode(body, version); ResultSet.ResultMetadata resultMetadata = ResultSet.ResultMetadata.EMPTY; - if (version > 1) + if (version.isGreaterThan(ProtocolVersion.V1)) resultMetadata = ResultSet.ResultMetadata.codec.decode(body, version); return new Prepared(id, -1, metadata, resultMetadata); } - public void encode(ResultMessage msg, ByteBuf dest, int version) + public void encode(ResultMessage msg, ByteBuf dest, ProtocolVersion version) { assert msg instanceof Prepared; Prepared prepared = (Prepared)msg; @@ -255,11 +255,11 @@ public abstract class ResultMessage extends Message.Response CBUtil.writeBytes(prepared.statementId.bytes, dest); ResultSet.PreparedMetadata.codec.encode(prepared.metadata, dest, version); - if (version > 1) + if (version.isGreaterThan(ProtocolVersion.V1)) ResultSet.ResultMetadata.codec.encode(prepared.resultMetadata, dest, version); } - public int encodedSize(ResultMessage msg, int version) + public int encodedSize(ResultMessage msg, ProtocolVersion version) { assert msg instanceof Prepared; Prepared prepared = (Prepared)msg; @@ -268,7 +268,7 @@ public abstract class ResultMessage extends Message.Response int size = 0; size += CBUtil.sizeOfBytes(prepared.statementId.bytes); size += ResultSet.PreparedMetadata.codec.encodedSize(prepared.metadata, version); - if (version > 1) + if (version.isGreaterThan(ProtocolVersion.V1)) size += ResultSet.ResultMetadata.codec.encodedSize(prepared.resultMetadata, version); return size; } @@ -348,19 +348,19 @@ public abstract class ResultMessage extends Message.Response public static final Message.Codec<ResultMessage> subcodec = new Message.Codec<ResultMessage>() { - public ResultMessage decode(ByteBuf body, int version) + public ResultMessage decode(ByteBuf body, ProtocolVersion version) { return new SchemaChange(Event.SchemaChange.deserializeEvent(body, version)); } - public void encode(ResultMessage msg, ByteBuf dest, int version) + public void encode(ResultMessage msg, ByteBuf dest, ProtocolVersion version) { assert msg instanceof SchemaChange; SchemaChange scm = (SchemaChange)msg; scm.change.serializeEvent(dest, version); } - public int encodedSize(ResultMessage msg, int version) + public int encodedSize(ResultMessage msg, ProtocolVersion version) { assert msg instanceof SchemaChange; SchemaChange scm = (SchemaChange)msg; http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/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 8966aeb..bf4a619 100644 --- a/src/java/org/apache/cassandra/transport/messages/StartupMessage.java +++ b/src/java/org/apache/cassandra/transport/messages/StartupMessage.java @@ -35,20 +35,21 @@ public class StartupMessage extends Message.Request { public static final String CQL_VERSION = "CQL_VERSION"; public static final String COMPRESSION = "COMPRESSION"; + public static final String PROTOCOL_VERSIONS = "PROTOCOL_VERSIONS"; public static final Message.Codec<StartupMessage> codec = new Message.Codec<StartupMessage>() { - public StartupMessage decode(ByteBuf body, int version) + public StartupMessage decode(ByteBuf body, ProtocolVersion version) { return new StartupMessage(upperCaseKeys(CBUtil.readStringMap(body))); } - public void encode(StartupMessage msg, ByteBuf dest, int version) + public void encode(StartupMessage msg, ByteBuf dest, ProtocolVersion version) { CBUtil.writeStringMap(msg.options, dest); } - public int encodedSize(StartupMessage msg, int version) + public int encodedSize(StartupMessage msg, ProtocolVersion version) { return CBUtil.sizeOfStringMap(msg.options); } @@ -68,7 +69,7 @@ public class StartupMessage extends Message.Request if (cqlVersion == null) throw new ProtocolException("Missing value CQL_VERSION in STARTUP message"); - try + try { if (new CassandraVersion(cqlVersion).compareTo(new CassandraVersion("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)); http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/java/org/apache/cassandra/transport/messages/SupportedMessage.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/transport/messages/SupportedMessage.java b/src/java/org/apache/cassandra/transport/messages/SupportedMessage.java index 539085f..0367b78 100644 --- a/src/java/org/apache/cassandra/transport/messages/SupportedMessage.java +++ b/src/java/org/apache/cassandra/transport/messages/SupportedMessage.java @@ -24,6 +24,7 @@ import io.netty.buffer.ByteBuf; import org.apache.cassandra.transport.CBUtil; import org.apache.cassandra.transport.Message; +import org.apache.cassandra.transport.ProtocolVersion; /** * Message to indicate that the server is ready to receive requests. @@ -32,17 +33,17 @@ public class SupportedMessage extends Message.Response { public static final Message.Codec<SupportedMessage> codec = new Message.Codec<SupportedMessage>() { - public SupportedMessage decode(ByteBuf body, int version) + public SupportedMessage decode(ByteBuf body, ProtocolVersion version) { return new SupportedMessage(CBUtil.readStringToStringListMap(body)); } - public void encode(SupportedMessage msg, ByteBuf dest, int version) + public void encode(SupportedMessage msg, ByteBuf dest, ProtocolVersion version) { CBUtil.writeStringToStringListMap(msg.supported, dest); } - public int encodedSize(SupportedMessage msg, int version) + public int encodedSize(SupportedMessage msg, ProtocolVersion version) { return CBUtil.sizeOfStringToStringListMap(msg.supported); } http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/src/resources/org/apache/cassandra/cql3/functions/JavaSourceUDF.txt ---------------------------------------------------------------------- diff --git a/src/resources/org/apache/cassandra/cql3/functions/JavaSourceUDF.txt b/src/resources/org/apache/cassandra/cql3/functions/JavaSourceUDF.txt index 802081f..5dafd98 100644 --- a/src/resources/org/apache/cassandra/cql3/functions/JavaSourceUDF.txt +++ b/src/resources/org/apache/cassandra/cql3/functions/JavaSourceUDF.txt @@ -5,6 +5,7 @@ import java.util.*; import org.apache.cassandra.cql3.functions.JavaUDF; import org.apache.cassandra.cql3.functions.UDFContext; +import org.apache.cassandra.transport.ProtocolVersion; import com.datastax.driver.core.TypeCodec; import com.datastax.driver.core.TupleValue; @@ -17,7 +18,7 @@ public final class #class_name# extends JavaUDF super(returnCodec, argCodecs, udfContext); } - protected ByteBuffer executeImpl(int protocolVersion, List<ByteBuffer> params) + protected ByteBuffer executeImpl(ProtocolVersion protocolVersion, List<ByteBuffer> params) { #return_type# result = #execute_internal_name#( #arguments# @@ -25,7 +26,7 @@ public final class #class_name# extends JavaUDF return super.decompose(protocolVersion, result); } - protected Object executeAggregateImpl(int protocolVersion, Object firstParam, List<ByteBuffer> params) + protected Object executeAggregateImpl(ProtocolVersion protocolVersion, Object firstParam, List<ByteBuffer> params) { #return_type# result = #execute_internal_name#( #arguments_aggregate# http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/test/long/org/apache/cassandra/cql3/ViewLongTest.java ---------------------------------------------------------------------- diff --git a/test/long/org/apache/cassandra/cql3/ViewLongTest.java b/test/long/org/apache/cassandra/cql3/ViewLongTest.java index 4dded85..a5d17ea 100644 --- a/test/long/org/apache/cassandra/cql3/ViewLongTest.java +++ b/test/long/org/apache/cassandra/cql3/ViewLongTest.java @@ -33,11 +33,12 @@ import com.datastax.driver.core.Row; import com.datastax.driver.core.exceptions.NoHostAvailableException; import com.datastax.driver.core.exceptions.WriteTimeoutException; import org.apache.cassandra.batchlog.BatchlogManager; +import org.apache.cassandra.transport.ProtocolVersion; import org.apache.cassandra.utils.WrappedRunnable; public class ViewLongTest extends CQLTester { - int protocolVersion = 4; + ProtocolVersion protocolVersion = ProtocolVersion.V4; private final List<String> views = new ArrayList<>(); @BeforeClass http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/test/unit/org/apache/cassandra/Util.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/Util.java b/test/unit/org/apache/cassandra/Util.java index f93ce5c..6410f2c 100644 --- a/test/unit/org/apache/cassandra/Util.java +++ b/test/unit/org/apache/cassandra/Util.java @@ -48,6 +48,8 @@ import org.apache.cassandra.db.Directories.DataDirectory; import org.apache.cassandra.db.compaction.AbstractCompactionTask; import org.apache.cassandra.db.compaction.CompactionManager; import org.apache.cassandra.db.marshal.AbstractType; +import org.apache.cassandra.db.marshal.AsciiType; +import org.apache.cassandra.db.marshal.Int32Type; import org.apache.cassandra.db.partitions.*; import org.apache.cassandra.db.rows.*; import org.apache.cassandra.dht.IPartitioner; @@ -60,6 +62,8 @@ import org.apache.cassandra.gms.VersionedValue; import org.apache.cassandra.io.sstable.Descriptor; import org.apache.cassandra.io.sstable.format.SSTableReader; import org.apache.cassandra.service.StorageService; +import org.apache.cassandra.service.pager.PagingState; +import org.apache.cassandra.transport.ProtocolVersion; import org.apache.cassandra.utils.ByteBufferUtil; import org.apache.cassandra.utils.CounterId; import org.apache.cassandra.utils.FBUtilities; @@ -707,4 +711,23 @@ public class Util } return () -> BlacklistedDirectories.clearUnwritableUnsafe(); } + + public static PagingState makeSomePagingState(ProtocolVersion protocolVersion) + { + CFMetaData metadata = CFMetaData.Builder.create("ks", "tbl") + .addPartitionKey("k", AsciiType.instance) + .addClusteringColumn("c1", AsciiType.instance) + .addClusteringColumn("c1", Int32Type.instance) + .addRegularColumn("myCol", AsciiType.instance) + .build(); + + ByteBuffer pk = ByteBufferUtil.bytes("someKey"); + + ColumnDefinition def = metadata.getColumnDefinition(new ColumnIdentifier("myCol", false)); + Clustering c = Clustering.make(ByteBufferUtil.bytes("c1"), ByteBufferUtil.bytes(42)); + Row row = BTreeRow.singleCellRow(c, BufferCell.live(def, 0, ByteBufferUtil.EMPTY_BYTE_BUFFER)); + PagingState.RowMark mark = PagingState.RowMark.create(metadata, row, protocolVersion); + return new PagingState(pk, mark, 10, 0); + } + } http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/test/unit/org/apache/cassandra/cql3/CQL3TypeLiteralTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/CQL3TypeLiteralTest.java b/test/unit/org/apache/cassandra/cql3/CQL3TypeLiteralTest.java index ee4bb35..6728da2 100644 --- a/test/unit/org/apache/cassandra/cql3/CQL3TypeLiteralTest.java +++ b/test/unit/org/apache/cassandra/cql3/CQL3TypeLiteralTest.java @@ -31,7 +31,7 @@ import org.junit.Test; import org.apache.cassandra.db.marshal.*; import org.apache.cassandra.serializers.*; -import org.apache.cassandra.transport.Server; +import org.apache.cassandra.transport.ProtocolVersion; import org.apache.cassandra.utils.ByteBufferUtil; import org.apache.cassandra.utils.UUIDGen; @@ -270,7 +270,7 @@ public class CQL3TypeLiteralTest // test each native type against each supported protocol version (although it doesn't make sense to // iterate through all protocol versions as of C* 3.0). - for (int version = Server.MIN_SUPPORTED_VERSION; version <= Server.CURRENT_VERSION; version++) + for (ProtocolVersion version : ProtocolVersion.SUPPORTED) { for (Map.Entry<CQL3Type.Native, List<Value>> entry : nativeTypeValues.entrySet()) { @@ -288,7 +288,7 @@ public class CQL3TypeLiteralTest // test 100 collections with varying element/key/value types against each supported protocol version, // type of collection is randomly chosen - for (int version = Server.MIN_SUPPORTED_VERSION; version <= Server.CURRENT_VERSION; version++) + for (ProtocolVersion version : ProtocolVersion.SUPPORTED) { for (int n = 0; n < 100; n++) { @@ -305,7 +305,7 @@ public class CQL3TypeLiteralTest // supported anymore and so the size of a collection is always on 4 bytes). ByteBuffer emptyCollection = ByteBufferUtil.bytes(0); - for (int version = Server.MIN_SUPPORTED_VERSION; version <= Server.CURRENT_VERSION; version++) + for (ProtocolVersion version : ProtocolVersion.SUPPORTED) { for (boolean frozen : Arrays.asList(true, false)) { @@ -333,7 +333,7 @@ public class CQL3TypeLiteralTest { // test 100 tuples with varying element/key/value types against each supported protocol version - for (int version = Server.MIN_SUPPORTED_VERSION; version <= Server.CURRENT_VERSION; version++) + for (ProtocolVersion version : ProtocolVersion.SUPPORTED) { for (int n = 0; n < 100; n++) { @@ -348,7 +348,7 @@ public class CQL3TypeLiteralTest { // test 100 UDTs with varying element/key/value types against each supported protocol version - for (int version = Server.MIN_SUPPORTED_VERSION; version <= Server.CURRENT_VERSION; version++) + for (ProtocolVersion version : ProtocolVersion.SUPPORTED) { for (int n = 0; n < 100; n++) { @@ -365,7 +365,7 @@ public class CQL3TypeLiteralTest // like 'tuple<map, list<user>, tuple, user>' or 'map<tuple<int, text>, set<inet>>' with // random types against each supported protocol version. - for (int version = Server.MIN_SUPPORTED_VERSION; version <= Server.CURRENT_VERSION; version++) + for (ProtocolVersion version : ProtocolVersion.SUPPORTED) { for (int n = 0; n < 100; n++) { @@ -375,7 +375,7 @@ public class CQL3TypeLiteralTest } } - static void compareCqlLiteral(int version, Value value) + static void compareCqlLiteral(ProtocolVersion version, Value value) { ByteBuffer buffer = value.value != null ? value.value.duplicate() : null; String msg = "Failed to get expected value for type " + value.cql3Type + " / " + value.cql3Type.getType() + " with protocol-version " + version + " expected:\"" + value.expected + '"'; @@ -391,7 +391,7 @@ public class CQL3TypeLiteralTest } } - static Value randomNested(int version) + static Value randomNested(ProtocolVersion version) { AbstractType type = randomNestedType(2); @@ -419,7 +419,7 @@ public class CQL3TypeLiteralTest throw new AssertionError(); } - static Value generateCollectionValue(int version, CollectionType collectionType, boolean allowNull) + static Value generateCollectionValue(ProtocolVersion version, CollectionType collectionType, boolean allowNull) { StringBuilder expected = new StringBuilder(); ByteBuffer buffer; @@ -492,7 +492,7 @@ public class CQL3TypeLiteralTest /** * Generates a value for any type or type structure. */ - static Value generateAnyValue(int version, CQL3Type type) + static Value generateAnyValue(ProtocolVersion version, CQL3Type type) { if (type instanceof CQL3Type.Native) return generateNativeValue(type, false); @@ -505,7 +505,7 @@ public class CQL3TypeLiteralTest throw new AssertionError(); } - static Value generateTupleValue(int version, TupleType tupleType, boolean allowNull) + static Value generateTupleValue(ProtocolVersion version, TupleType tupleType, boolean allowNull) { StringBuilder expected = new StringBuilder(); ByteBuffer buffer; @@ -550,7 +550,7 @@ public class CQL3TypeLiteralTest return new Value(expected.toString(), tupleType.asCQL3Type(), buffer); } - static Value generateUserDefinedValue(int version, UserType userType, boolean allowNull) + static Value generateUserDefinedValue(ProtocolVersion version, UserType userType, boolean allowNull) { StringBuilder expected = new StringBuilder(); ByteBuffer buffer; http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/test/unit/org/apache/cassandra/cql3/CQLTester.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/CQLTester.java b/test/unit/org/apache/cassandra/cql3/CQLTester.java index 7cdd893..2a5afc2 100644 --- a/test/unit/org/apache/cassandra/cql3/CQLTester.java +++ b/test/unit/org/apache/cassandra/cql3/CQLTester.java @@ -32,13 +32,13 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; import com.google.common.base.Objects; -import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import org.junit.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.datastax.driver.core.*; +import com.datastax.driver.core.DataType; import com.datastax.driver.core.ResultSet; import org.apache.cassandra.SchemaLoader; import org.apache.cassandra.concurrent.ScheduledExecutors; @@ -61,8 +61,8 @@ import org.apache.cassandra.serializers.TypeSerializer; import org.apache.cassandra.service.ClientState; import org.apache.cassandra.service.QueryState; import org.apache.cassandra.service.StorageService; -import org.apache.cassandra.transport.Event; -import org.apache.cassandra.transport.Server; +import org.apache.cassandra.transport.*; +import org.apache.cassandra.transport.ProtocolVersion; import org.apache.cassandra.transport.messages.ResultMessage; import org.apache.cassandra.utils.ByteBufferUtil; import org.apache.cassandra.utils.FBUtilities; @@ -87,31 +87,41 @@ public abstract class CQLTester private static org.apache.cassandra.transport.Server server; protected static final int nativePort; protected static final InetAddress nativeAddr; - private static final Map<Integer, Cluster> clusters = new HashMap<>(); - private static final Map<Integer, Session> sessions = new HashMap<>(); + private static final Map<ProtocolVersion, Cluster> clusters = new HashMap<>(); + private static final Map<ProtocolVersion, Session> sessions = new HashMap<>(); private static boolean isServerPrepared = false; - public static final List<Integer> PROTOCOL_VERSIONS; + public static final List<ProtocolVersion> PROTOCOL_VERSIONS = new ArrayList<>(ProtocolVersion.SUPPORTED.size()); + + /** Return the current server version if supported by the driver, else + * the latest that is supported. + * + * @return - the preferred versions that is also supported by the driver + */ + public static final ProtocolVersion getDefaultVersion() + { + return PROTOCOL_VERSIONS.contains(ProtocolVersion.CURRENT) + ? ProtocolVersion.CURRENT + : PROTOCOL_VERSIONS.get(PROTOCOL_VERSIONS.size() - 1); + } static { DatabaseDescriptor.daemonInitialization(); // The latest versions might not be supported yet by the java driver - ImmutableList.Builder<Integer> builder = ImmutableList.builder(); - for (int version = Server.MIN_SUPPORTED_VERSION; version <= Server.CURRENT_VERSION; version++) + for (ProtocolVersion version : ProtocolVersion.SUPPORTED) { try { - ProtocolVersion.fromInt(version); - builder.add(version); + com.datastax.driver.core.ProtocolVersion.fromInt(version.asInt()); + PROTOCOL_VERSIONS.add(version); } catch (IllegalArgumentException e) { - break; + logger.warn("Protocol Version {} not supported by java driver", version); } } - PROTOCOL_VERSIONS = builder.build(); nativeAddr = InetAddress.getLoopbackAddress(); @@ -348,7 +358,7 @@ public abstract class CQLTester server = new Server.Builder().withHost(nativeAddr).withPort(nativePort).build(); server.start(); - for (int version : PROTOCOL_VERSIONS) + for (ProtocolVersion version : PROTOCOL_VERSIONS) { if (clusters.containsKey(version)) continue; @@ -357,7 +367,7 @@ public abstract class CQLTester .addContactPoints(nativeAddr) .withClusterName("Test Cluster") .withPort(nativePort) - .withProtocolVersion(ProtocolVersion.fromInt(version)) + .withProtocolVersion(com.datastax.driver.core.ProtocolVersion.fromInt(version.asInt())) .build(); clusters.put(version, cluster); sessions.put(version, cluster.connect()); @@ -708,17 +718,17 @@ public abstract class CQLTester return Schema.instance.getCFMetaData(KEYSPACE, currentTable()); } - protected com.datastax.driver.core.ResultSet executeNet(int protocolVersion, String query, Object... values) throws Throwable + protected com.datastax.driver.core.ResultSet executeNet(ProtocolVersion protocolVersion, String query, Object... values) throws Throwable { return sessionNet(protocolVersion).execute(formatQuery(query), values); } protected Session sessionNet() { - return sessionNet(PROTOCOL_VERSIONS.get(PROTOCOL_VERSIONS.size() - 1)); + return sessionNet(getDefaultVersion()); } - protected Session sessionNet(int protocolVersion) + protected Session sessionNet(ProtocolVersion protocolVersion) { requireNetwork(); @@ -786,10 +796,10 @@ public abstract class CQLTester protected void assertRowsNet(ResultSet result, Object[]... rows) { - assertRowsNet(PROTOCOL_VERSIONS.get(PROTOCOL_VERSIONS.size() - 1), result, rows); + assertRowsNet(getDefaultVersion(), result, rows); } - protected void assertRowsNet(int protocolVersion, ResultSet result, Object[]... rows) + protected void assertRowsNet(ProtocolVersion protocolVersion, ResultSet result, Object[]... rows) { // necessary as we need cluster objects to supply CodecRegistry. // It's reasonably certain that the network setup has already been done @@ -811,7 +821,7 @@ public abstract class CQLTester Object[] expected = rows[i]; Row actual = iter.next(); - Assert.assertEquals(String.format("Invalid number of (expected) values provided for row %d (using protocol version %d)", + Assert.assertEquals(String.format("Invalid number of (expected) values provided for row %d (using protocol version %s)", i, protocolVersion), meta.size(), expected.length); @@ -821,18 +831,18 @@ public abstract class CQLTester com.datastax.driver.core.TypeCodec<Object> codec = clusters.get(protocolVersion).getConfiguration() .getCodecRegistry() .codecFor(type); - ByteBuffer expectedByteValue = codec.serialize(expected[j], ProtocolVersion.fromInt(protocolVersion)); + ByteBuffer expectedByteValue = codec.serialize(expected[j], com.datastax.driver.core.ProtocolVersion.fromInt(protocolVersion.asInt())); int expectedBytes = expectedByteValue == null ? -1 : expectedByteValue.remaining(); ByteBuffer actualValue = actual.getBytesUnsafe(meta.getName(j)); int actualBytes = actualValue == null ? -1 : actualValue.remaining(); if (!Objects.equal(expectedByteValue, actualValue)) Assert.fail(String.format("Invalid value for row %d column %d (%s of type %s), " + "expected <%s> (%d bytes) but got <%s> (%d bytes) " + - "(using protocol version %d)", + "(using protocol version %s)", i, j, meta.getName(j), type, codec.format(expected[j]), expectedBytes, - codec.format(codec.deserialize(actualValue, ProtocolVersion.fromInt(protocolVersion))), + codec.format(codec.deserialize(actualValue, com.datastax.driver.core.ProtocolVersion.fromInt(protocolVersion.asInt()))), actualBytes, protocolVersion)); } @@ -846,11 +856,11 @@ public abstract class CQLTester iter.next(); i++; } - Assert.fail(String.format("Got less rows than expected. Expected %d but got %d (using protocol version %d).", + Assert.fail(String.format("Got less rows than expected. Expected %d but got %d (using protocol version %s).", rows.length, i, protocolVersion)); } - Assert.assertTrue(String.format("Got %s rows than expected. Expected %d but got %d (using protocol version %d)", + Assert.assertTrue(String.format("Got %s rows than expected. Expected %d but got %d (using protocol version %s)", rows.length>i ? "less" : "more", rows.length, i, protocolVersion), i == rows.length); } @@ -1114,12 +1124,12 @@ public abstract class CQLTester protected void assertInvalidThrowMessage(String errorMessage, Class<? extends Throwable> exception, String query, Object... values) throws Throwable { - assertInvalidThrowMessage(Integer.MIN_VALUE, errorMessage, exception, query, values); + assertInvalidThrowMessage(Optional.empty(), errorMessage, exception, query, values); } // if a protocol version > Integer.MIN_VALUE is supplied, executes // the query via the java driver, mimicking a real client. - protected void assertInvalidThrowMessage(int protocolVersion, + protected void assertInvalidThrowMessage(Optional<ProtocolVersion> protocolVersion, String errorMessage, Class<? extends Throwable> exception, String query, @@ -1127,10 +1137,10 @@ public abstract class CQLTester { try { - if (protocolVersion == Integer.MIN_VALUE) + if (!protocolVersion.isPresent()) execute(query, values); else - executeNet(protocolVersion, query, values); + executeNet(protocolVersion.get(), query, values); String q = USE_PREPARED_VALUES ? query + " (values: " + formatAllValues(values) + ")" @@ -1497,7 +1507,7 @@ public abstract class CQLTester return m; } - protected com.datastax.driver.core.TupleType tupleTypeOf(int protocolVersion, DataType...types) + protected com.datastax.driver.core.TupleType tupleTypeOf(ProtocolVersion protocolVersion, DataType...types) { requireNetwork(); return clusters.get(protocolVersion).getMetadata().newTupleType(types); http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/test/unit/org/apache/cassandra/cql3/ViewFilteringTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/ViewFilteringTest.java b/test/unit/org/apache/cassandra/cql3/ViewFilteringTest.java index 0cecfa2..cc8bfe9 100644 --- a/test/unit/org/apache/cassandra/cql3/ViewFilteringTest.java +++ b/test/unit/org/apache/cassandra/cql3/ViewFilteringTest.java @@ -36,11 +36,12 @@ import org.apache.cassandra.config.ColumnDefinition; import org.apache.cassandra.db.ColumnFamilyStore; import org.apache.cassandra.db.Keyspace; import org.apache.cassandra.db.SystemKeyspace; +import org.apache.cassandra.transport.ProtocolVersion; import org.apache.cassandra.utils.FBUtilities; public class ViewFilteringTest extends CQLTester { - int protocolVersion = 4; + ProtocolVersion protocolVersion = ProtocolVersion.V4; private final List<String> views = new ArrayList<>(); @BeforeClass http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/test/unit/org/apache/cassandra/cql3/ViewSchemaTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/ViewSchemaTest.java b/test/unit/org/apache/cassandra/cql3/ViewSchemaTest.java index b34f475..e4e203e 100644 --- a/test/unit/org/apache/cassandra/cql3/ViewSchemaTest.java +++ b/test/unit/org/apache/cassandra/cql3/ViewSchemaTest.java @@ -40,6 +40,7 @@ import org.apache.cassandra.config.Schema; import org.apache.cassandra.db.SystemKeyspace; import org.apache.cassandra.serializers.SimpleDateSerializer; import org.apache.cassandra.serializers.TimeSerializer; +import org.apache.cassandra.transport.ProtocolVersion; import org.apache.cassandra.utils.ByteBufferUtil; import org.junit.After; import org.junit.Before; @@ -51,7 +52,7 @@ import com.datastax.driver.core.exceptions.InvalidQueryException; public class ViewSchemaTest extends CQLTester { - int protocolVersion = 4; + ProtocolVersion protocolVersion = ProtocolVersion.V4; private final List<String> views = new ArrayList<>(); @BeforeClass http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/test/unit/org/apache/cassandra/cql3/ViewTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/ViewTest.java b/test/unit/org/apache/cassandra/cql3/ViewTest.java index ccfadef..5b18276 100644 --- a/test/unit/org/apache/cassandra/cql3/ViewTest.java +++ b/test/unit/org/apache/cassandra/cql3/ViewTest.java @@ -40,13 +40,14 @@ import org.apache.cassandra.config.ColumnDefinition; import org.apache.cassandra.db.ColumnFamilyStore; import org.apache.cassandra.db.Keyspace; import org.apache.cassandra.db.SystemKeyspace; +import org.apache.cassandra.transport.ProtocolVersion; import org.apache.cassandra.utils.FBUtilities; import static org.junit.Assert.assertTrue; public class ViewTest extends CQLTester { - int protocolVersion = 4; + ProtocolVersion protocolVersion = ProtocolVersion.V4; private final List<String> views = new ArrayList<>(); @BeforeClass http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/test/unit/org/apache/cassandra/cql3/functions/TimeFctsTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/functions/TimeFctsTest.java b/test/unit/org/apache/cassandra/cql3/functions/TimeFctsTest.java index f6fca20..5b9737f 100644 --- a/test/unit/org/apache/cassandra/cql3/functions/TimeFctsTest.java +++ b/test/unit/org/apache/cassandra/cql3/functions/TimeFctsTest.java @@ -27,7 +27,7 @@ import org.apache.cassandra.db.marshal.LongType; import org.apache.cassandra.db.marshal.SimpleDateType; import org.apache.cassandra.db.marshal.TimeUUIDType; import org.apache.cassandra.db.marshal.TimestampType; -import org.apache.cassandra.transport.Server; +import org.apache.cassandra.transport.ProtocolVersion; import org.apache.cassandra.utils.ByteBufferUtil; import org.apache.cassandra.utils.UUIDGen; import org.joda.time.DateTime; @@ -201,6 +201,6 @@ public class TimeFctsTest private static ByteBuffer executeFunction(Function function, ByteBuffer input) { List<ByteBuffer> params = Arrays.asList(input); - return ((ScalarFunction) function).execute(Server.CURRENT_VERSION, params); + return ((ScalarFunction) function).execute(ProtocolVersion.CURRENT, params); } } http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/test/unit/org/apache/cassandra/cql3/validation/entities/UFPureScriptTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/UFPureScriptTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/UFPureScriptTest.java index 82ed63d..d5f17e1 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/entities/UFPureScriptTest.java +++ b/test/unit/org/apache/cassandra/cql3/validation/entities/UFPureScriptTest.java @@ -37,6 +37,7 @@ import org.apache.cassandra.cql3.CQLTester; import org.apache.cassandra.cql3.UntypedResultSet; import org.apache.cassandra.cql3.functions.FunctionName; import org.apache.cassandra.exceptions.FunctionExecutionException; +import org.apache.cassandra.transport.ProtocolVersion; import org.apache.cassandra.utils.UUIDGen; public class UFPureScriptTest extends CQLTester @@ -85,7 +86,7 @@ public class UFPureScriptTest extends CQLTester assertRows(execute("SELECT " + fName1 + "(lst), " + fName2 + "(st), " + fName3 + "(mp) FROM %s WHERE key = 1"), row(list, set, map)); - for (int version : PROTOCOL_VERSIONS) + for (ProtocolVersion version : PROTOCOL_VERSIONS) assertRowsNet(version, executeNet(version, "SELECT " + fName1 + "(lst), " + fName2 + "(st), " + fName3 + "(mp) FROM %s WHERE key = 1"), row(list, set, map)); @@ -204,7 +205,7 @@ public class UFPureScriptTest extends CQLTester row("three", "one", "two")); // same test - but via native protocol - for (int version : PROTOCOL_VERSIONS) + for (ProtocolVersion version : PROTOCOL_VERSIONS) assertRowsNet(version, executeNet(version, cqlSelect), row("three", "one", "two")); http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/test/unit/org/apache/cassandra/cql3/validation/entities/UFPureScriptTupleCollectionTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/UFPureScriptTupleCollectionTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/UFPureScriptTupleCollectionTest.java index 7465a2a..a1801b3 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/entities/UFPureScriptTupleCollectionTest.java +++ b/test/unit/org/apache/cassandra/cql3/validation/entities/UFPureScriptTupleCollectionTest.java @@ -31,7 +31,7 @@ import com.datastax.driver.core.DataType; import com.datastax.driver.core.TupleType; import com.datastax.driver.core.TupleValue; import org.apache.cassandra.cql3.CQLTester; -import org.apache.cassandra.transport.Server; +import org.apache.cassandra.transport.ProtocolVersion; public class UFPureScriptTupleCollectionTest extends CQLTester { @@ -109,14 +109,14 @@ public class UFPureScriptTupleCollectionTest extends CQLTester // we use protocol V3 here to encode the expected version because the server // always serializes Collections using V3 - see CollectionSerializer's // serialize and deserialize methods. - TupleType tType = tupleTypeOf(Server.VERSION_3, + TupleType tType = tupleTypeOf(ProtocolVersion.V3, DataType.cdouble(), DataType.list(DataType.cdouble()), DataType.set(DataType.text()), DataType.map(DataType.cint(), DataType.cboolean())); TupleValue tup = tType.newValue(1d, list, set, map); - for (int version : PROTOCOL_VERSIONS) + for (ProtocolVersion version : PROTOCOL_VERSIONS) { assertRowsNet(version, executeNet(version, "SELECT " + fTup1 + "(tup) FROM %s WHERE key = 1"), http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/test/unit/org/apache/cassandra/cql3/validation/entities/UFTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/UFTest.java b/test/unit/org/apache/cassandra/cql3/validation/entities/UFTest.java index 4bcc599..1eccc3f 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/entities/UFTest.java +++ b/test/unit/org/apache/cassandra/cql3/validation/entities/UFTest.java @@ -34,6 +34,7 @@ import org.junit.Assert; import org.junit.Test; import com.datastax.driver.core.*; +import com.datastax.driver.core.DataType; import com.datastax.driver.core.exceptions.InvalidQueryException; import org.apache.cassandra.config.Config; import org.apache.cassandra.config.DatabaseDescriptor; @@ -52,8 +53,8 @@ import org.apache.cassandra.exceptions.InvalidRequestException; import org.apache.cassandra.schema.KeyspaceMetadata; import org.apache.cassandra.service.ClientState; import org.apache.cassandra.service.ClientWarn; -import org.apache.cassandra.transport.Event; -import org.apache.cassandra.transport.Server; +import org.apache.cassandra.transport.*; +import org.apache.cassandra.transport.ProtocolVersion; import org.apache.cassandra.transport.messages.ResultMessage; import org.apache.cassandra.utils.ByteBufferUtil; import org.apache.cassandra.utils.UUIDGen; @@ -998,7 +999,7 @@ public class UFTest extends CQLTester row(list, set, map)); // same test - but via native protocol - for (int version : PROTOCOL_VERSIONS) + for (ProtocolVersion version : PROTOCOL_VERSIONS) assertRowsNet(version, executeNet(version, "SELECT " + fList + "(lst), " + fSet + "(st), " + fMap + "(mp) FROM %s WHERE key = 1"), row(list, set, map)); @@ -1107,7 +1108,7 @@ public class UFTest extends CQLTester Assert.assertNull(row.getBytes("t")); Assert.assertNull(row.getBytes("u")); - for (int version : PROTOCOL_VERSIONS) + for (ProtocolVersion version : PROTOCOL_VERSIONS) { Row r = executeNet(version, "SELECT " + fList + "(lst) as l, " + @@ -1228,13 +1229,13 @@ public class UFTest extends CQLTester // we use protocol V3 here to encode the expected version because the server // always serializes Collections using V3 - see CollectionSerializer's // serialize and deserialize methods. - TupleType tType = tupleTypeOf(Server.VERSION_3, + TupleType tType = tupleTypeOf(ProtocolVersion.V3, DataType.cdouble(), DataType.list(DataType.cdouble()), DataType.set(DataType.text()), DataType.map(DataType.cint(), DataType.cboolean())); TupleValue tup = tType.newValue(1d, list, set, map); - for (int version : PROTOCOL_VERSIONS) + for (ProtocolVersion version : PROTOCOL_VERSIONS) { assertRowsNet(version, executeNet(version, "SELECT " + fTup0 + "(tup) FROM %s WHERE key = 1"), @@ -1261,7 +1262,7 @@ public class UFTest extends CQLTester createTable("CREATE TABLE %s (key int primary key, udt frozen<" + KEYSPACE + '.' + type + ">)"); execute("INSERT INTO %s (key, udt) VALUES (1, {txt: 'one', i:1})"); - for (int version : PROTOCOL_VERSIONS) + for (ProtocolVersion version : PROTOCOL_VERSIONS) { executeNet(version, "USE " + KEYSPACE); @@ -1325,7 +1326,7 @@ public class UFTest extends CQLTester assertRows(execute("SELECT " + fUdt2 + "(udt) FROM %s WHERE key = 1"), row(1)); - for (int version : PROTOCOL_VERSIONS) + for (ProtocolVersion version : PROTOCOL_VERSIONS) { List<Row> rowsNet = executeNet(version, "SELECT " + fUdt0 + "(udt) FROM %s WHERE key = 1").all(); Assert.assertEquals(1, rowsNet.size()); @@ -1587,7 +1588,7 @@ public class UFTest extends CQLTester assertRows(execute("SELECT " + fName1 + "(lst), " + fName2 + "(st), " + fName3 + "(mp) FROM %s WHERE key = 1"), row("three", "one", "two")); - for (int version : PROTOCOL_VERSIONS) + for (ProtocolVersion version : PROTOCOL_VERSIONS) assertRowsNet(version, executeNet(version, "SELECT " + fName1 + "(lst), " + fName2 + "(st), " + fName3 + "(mp) FROM %s WHERE key = 1"), row("three", "one", "two")); @@ -1843,7 +1844,7 @@ public class UFTest extends CQLTester "LANGUAGE JAVA\n" + "AS 'throw new RuntimeException();'"); - for (int version : PROTOCOL_VERSIONS) + for (ProtocolVersion version : PROTOCOL_VERSIONS) { try { @@ -1854,11 +1855,11 @@ public class UFTest extends CQLTester catch (com.datastax.driver.core.exceptions.FunctionExecutionException fee) { // Java driver neither throws FunctionExecutionException nor does it set the exception code correctly - Assert.assertTrue(version >= Server.VERSION_4); + Assert.assertTrue(version.isGreaterOrEqualTo(ProtocolVersion.V4)); } catch (InvalidQueryException e) { - Assert.assertTrue(version < Server.VERSION_4); + Assert.assertTrue(version.isSmallerThan(ProtocolVersion.V4)); } } } http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/CallClone.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/CallClone.java b/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/CallClone.java index 9efa83a..4e0e1d3 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/CallClone.java +++ b/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/CallClone.java @@ -24,6 +24,7 @@ import java.util.List; import com.datastax.driver.core.TypeCodec; import org.apache.cassandra.cql3.functions.JavaUDF; import org.apache.cassandra.cql3.functions.UDFContext; +import org.apache.cassandra.transport.ProtocolVersion; /** * Used by {@link org.apache.cassandra.cql3.validation.entities.UFVerifierTest}. @@ -35,12 +36,12 @@ public final class CallClone extends JavaUDF super(returnDataType, argDataTypes, udfContext); } - protected Object executeAggregateImpl(int protocolVersion, Object firstParam, List<ByteBuffer> params) + protected Object executeAggregateImpl(ProtocolVersion protocolVersion, Object firstParam, List<ByteBuffer> params) { throw new UnsupportedOperationException(); } - protected ByteBuffer executeImpl(int protocolVersion, List<ByteBuffer> params) + protected ByteBuffer executeImpl(ProtocolVersion protocolVersion, List<ByteBuffer> params) { try { http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/CallComDatastax.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/CallComDatastax.java b/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/CallComDatastax.java index 4555ff5..c4cef58 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/CallComDatastax.java +++ b/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/CallComDatastax.java @@ -25,6 +25,7 @@ import com.datastax.driver.core.DataType; import com.datastax.driver.core.TypeCodec; import org.apache.cassandra.cql3.functions.JavaUDF; import org.apache.cassandra.cql3.functions.UDFContext; +import org.apache.cassandra.transport.ProtocolVersion; /** * Used by {@link org.apache.cassandra.cql3.validation.entities.UFVerifierTest}. @@ -36,12 +37,12 @@ public final class CallComDatastax extends JavaUDF super(returnDataType, argDataTypes, udfContext); } - protected Object executeAggregateImpl(int protocolVersion, Object firstParam, List<ByteBuffer> params) + protected Object executeAggregateImpl(ProtocolVersion protocolVersion, Object firstParam, List<ByteBuffer> params) { throw new UnsupportedOperationException(); } - protected ByteBuffer executeImpl(int protocolVersion, List<ByteBuffer> params) + protected ByteBuffer executeImpl(ProtocolVersion protocolVersion, List<ByteBuffer> params) { DataType.cint(); return null; http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/CallFinalize.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/CallFinalize.java b/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/CallFinalize.java index b1ec15f..dfb523e 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/CallFinalize.java +++ b/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/CallFinalize.java @@ -24,6 +24,7 @@ import java.util.List; import com.datastax.driver.core.TypeCodec; import org.apache.cassandra.cql3.functions.JavaUDF; import org.apache.cassandra.cql3.functions.UDFContext; +import org.apache.cassandra.transport.ProtocolVersion; /** * Used by {@link org.apache.cassandra.cql3.validation.entities.UFVerifierTest}. @@ -35,12 +36,12 @@ public final class CallFinalize extends JavaUDF super(returnDataType, argDataTypes, udfContext); } - protected Object executeAggregateImpl(int protocolVersion, Object firstParam, List<ByteBuffer> params) + protected Object executeAggregateImpl(ProtocolVersion protocolVersion, Object firstParam, List<ByteBuffer> params) { throw new UnsupportedOperationException(); } - protected ByteBuffer executeImpl(int protocolVersion, List<ByteBuffer> params) + protected ByteBuffer executeImpl(ProtocolVersion protocolVersion, List<ByteBuffer> params) { try { http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/CallOrgApache.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/CallOrgApache.java b/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/CallOrgApache.java index 728e482..34a82ed 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/CallOrgApache.java +++ b/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/CallOrgApache.java @@ -25,6 +25,7 @@ import com.datastax.driver.core.TypeCodec; import org.apache.cassandra.config.DatabaseDescriptor; import org.apache.cassandra.cql3.functions.JavaUDF; import org.apache.cassandra.cql3.functions.UDFContext; +import org.apache.cassandra.transport.ProtocolVersion; /** * Used by {@link org.apache.cassandra.cql3.validation.entities.UFVerifierTest}. @@ -36,12 +37,12 @@ public final class CallOrgApache extends JavaUDF super(returnDataType, argDataTypes, udfContext); } - protected Object executeAggregateImpl(int protocolVersion, Object firstParam, List<ByteBuffer> params) + protected Object executeAggregateImpl(ProtocolVersion protocolVersion, Object firstParam, List<ByteBuffer> params) { throw new UnsupportedOperationException(); } - protected ByteBuffer executeImpl(int protocolVersion, List<ByteBuffer> params) + protected ByteBuffer executeImpl(ProtocolVersion protocolVersion, List<ByteBuffer> params) { DatabaseDescriptor.getClusterName(); return null; http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithField.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithField.java b/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithField.java index 4c38b44..33625fe 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithField.java +++ b/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithField.java @@ -24,6 +24,7 @@ import java.util.List; import com.datastax.driver.core.TypeCodec; import org.apache.cassandra.cql3.functions.JavaUDF; import org.apache.cassandra.cql3.functions.UDFContext; +import org.apache.cassandra.transport.ProtocolVersion; /** * Used by {@link org.apache.cassandra.cql3.validation.entities.UFVerifierTest}. @@ -35,12 +36,12 @@ public final class ClassWithField extends JavaUDF super(returnDataType, argDataTypes, udfContext); } - protected Object executeAggregateImpl(int protocolVersion, Object firstParam, List<ByteBuffer> params) + protected Object executeAggregateImpl(ProtocolVersion protocolVersion, Object firstParam, List<ByteBuffer> params) { throw new UnsupportedOperationException(); } - protected ByteBuffer executeImpl(int protocolVersion, List<ByteBuffer> params) + protected ByteBuffer executeImpl(ProtocolVersion protocolVersion, List<ByteBuffer> params) { return null; } http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithInitializer.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithInitializer.java b/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithInitializer.java index cc2738a..4f83bfe 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithInitializer.java +++ b/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithInitializer.java @@ -24,6 +24,7 @@ import java.util.List; import com.datastax.driver.core.TypeCodec; import org.apache.cassandra.cql3.functions.JavaUDF; import org.apache.cassandra.cql3.functions.UDFContext; +import org.apache.cassandra.transport.ProtocolVersion; /** * Used by {@link org.apache.cassandra.cql3.validation.entities.UFVerifierTest}. @@ -35,12 +36,12 @@ public final class ClassWithInitializer extends JavaUDF super(returnDataType, argDataTypes, udfContext); } - protected Object executeAggregateImpl(int protocolVersion, Object firstParam, List<ByteBuffer> params) + protected Object executeAggregateImpl(ProtocolVersion protocolVersion, Object firstParam, List<ByteBuffer> params) { throw new UnsupportedOperationException(); } - protected ByteBuffer executeImpl(int protocolVersion, List<ByteBuffer> params) + protected ByteBuffer executeImpl(ProtocolVersion protocolVersion, List<ByteBuffer> params) { return null; } http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithInitializer2.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithInitializer2.java b/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithInitializer2.java index 780c0e4..df4c78a 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithInitializer2.java +++ b/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithInitializer2.java @@ -24,6 +24,7 @@ import java.util.List; import com.datastax.driver.core.TypeCodec; import org.apache.cassandra.cql3.functions.JavaUDF; import org.apache.cassandra.cql3.functions.UDFContext; +import org.apache.cassandra.transport.ProtocolVersion; /** * Used by {@link org.apache.cassandra.cql3.validation.entities.UFVerifierTest}. @@ -35,12 +36,12 @@ public final class ClassWithInitializer2 extends JavaUDF super(returnDataType, argDataTypes, udfContext); } - protected Object executeAggregateImpl(int protocolVersion, Object firstParam, List<ByteBuffer> params) + protected Object executeAggregateImpl(ProtocolVersion protocolVersion, Object firstParam, List<ByteBuffer> params) { throw new UnsupportedOperationException(); } - protected ByteBuffer executeImpl(int protocolVersion, List<ByteBuffer> params) + protected ByteBuffer executeImpl(ProtocolVersion protocolVersion, List<ByteBuffer> params) { return null; } http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithInitializer3.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithInitializer3.java b/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithInitializer3.java index e163ec9..d30ada3 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithInitializer3.java +++ b/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithInitializer3.java @@ -24,6 +24,7 @@ import java.util.List; import com.datastax.driver.core.TypeCodec; import org.apache.cassandra.cql3.functions.JavaUDF; import org.apache.cassandra.cql3.functions.UDFContext; +import org.apache.cassandra.transport.ProtocolVersion; /** * Used by {@link org.apache.cassandra.cql3.validation.entities.UFVerifierTest}. @@ -35,12 +36,12 @@ public final class ClassWithInitializer3 extends JavaUDF super(returnDataType, argDataTypes, udfContext); } - protected Object executeAggregateImpl(int protocolVersion, Object firstParam, List<ByteBuffer> params) + protected Object executeAggregateImpl(ProtocolVersion protocolVersion, Object firstParam, List<ByteBuffer> params) { throw new UnsupportedOperationException(); } - protected ByteBuffer executeImpl(int protocolVersion, List<ByteBuffer> params) + protected ByteBuffer executeImpl(ProtocolVersion protocolVersion, List<ByteBuffer> params) { return null; } http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithInnerClass.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithInnerClass.java b/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithInnerClass.java index 3c4dc9b..091597f 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithInnerClass.java +++ b/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithInnerClass.java @@ -24,6 +24,7 @@ import java.util.List; import com.datastax.driver.core.TypeCodec; import org.apache.cassandra.cql3.functions.JavaUDF; import org.apache.cassandra.cql3.functions.UDFContext; +import org.apache.cassandra.transport.ProtocolVersion; /** * Used by {@link org.apache.cassandra.cql3.validation.entities.UFVerifierTest}. @@ -35,12 +36,12 @@ public final class ClassWithInnerClass extends JavaUDF super(returnDataType, argDataTypes, udfContext); } - protected Object executeAggregateImpl(int protocolVersion, Object firstParam, List<ByteBuffer> params) + protected Object executeAggregateImpl(ProtocolVersion protocolVersion, Object firstParam, List<ByteBuffer> params) { throw new UnsupportedOperationException(); } - protected ByteBuffer executeImpl(int protocolVersion, List<ByteBuffer> params) + protected ByteBuffer executeImpl(ProtocolVersion protocolVersion, List<ByteBuffer> params) { return null; } http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithInnerClass2.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithInnerClass2.java b/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithInnerClass2.java index b316040..ac5b06f 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithInnerClass2.java +++ b/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithInnerClass2.java @@ -24,6 +24,7 @@ import java.util.List; import com.datastax.driver.core.TypeCodec; import org.apache.cassandra.cql3.functions.JavaUDF; import org.apache.cassandra.cql3.functions.UDFContext; +import org.apache.cassandra.transport.ProtocolVersion; /** * Used by {@link org.apache.cassandra.cql3.validation.entities.UFVerifierTest}. @@ -35,12 +36,12 @@ public final class ClassWithInnerClass2 extends JavaUDF super(returnDataType, argDataTypes, udfContext); } - protected Object executeAggregateImpl(int protocolVersion, Object firstParam, List<ByteBuffer> params) + protected Object executeAggregateImpl(ProtocolVersion protocolVersion, Object firstParam, List<ByteBuffer> params) { throw new UnsupportedOperationException(); } - protected ByteBuffer executeImpl(int protocolVersion, List<ByteBuffer> params) + protected ByteBuffer executeImpl(ProtocolVersion protocolVersion, List<ByteBuffer> params) { // this is fine new Runnable() { http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithStaticInitializer.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithStaticInitializer.java b/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithStaticInitializer.java index c97a94a..c927667 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithStaticInitializer.java +++ b/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithStaticInitializer.java @@ -24,6 +24,7 @@ import java.util.List; import com.datastax.driver.core.TypeCodec; import org.apache.cassandra.cql3.functions.JavaUDF; import org.apache.cassandra.cql3.functions.UDFContext; +import org.apache.cassandra.transport.ProtocolVersion; /** * Used by {@link org.apache.cassandra.cql3.validation.entities.UFVerifierTest}. @@ -35,12 +36,12 @@ public final class ClassWithStaticInitializer extends JavaUDF super(returnDataType, argDataTypes, udfContext); } - protected Object executeAggregateImpl(int protocolVersion, Object firstParam, List<ByteBuffer> params) + protected Object executeAggregateImpl(ProtocolVersion protocolVersion, Object firstParam, List<ByteBuffer> params) { throw new UnsupportedOperationException(); } - protected ByteBuffer executeImpl(int protocolVersion, List<ByteBuffer> params) + protected ByteBuffer executeImpl(ProtocolVersion protocolVersion, List<ByteBuffer> params) { return null; } http://git-wip-us.apache.org/repos/asf/cassandra/blob/e0adc166/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithStaticInnerClass.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithStaticInnerClass.java b/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithStaticInnerClass.java index 1b019cc..9ce5d71 100644 --- a/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithStaticInnerClass.java +++ b/test/unit/org/apache/cassandra/cql3/validation/entities/udfverify/ClassWithStaticInnerClass.java @@ -24,6 +24,7 @@ import java.util.List; import com.datastax.driver.core.TypeCodec; import org.apache.cassandra.cql3.functions.JavaUDF; import org.apache.cassandra.cql3.functions.UDFContext; +import org.apache.cassandra.transport.ProtocolVersion; /** * Used by {@link org.apache.cassandra.cql3.validation.entities.UFVerifierTest}. @@ -35,12 +36,12 @@ public final class ClassWithStaticInnerClass extends JavaUDF super(returnDataType, argDataTypes, udfContext); } - protected Object executeAggregateImpl(int protocolVersion, Object firstParam, List<ByteBuffer> params) + protected Object executeAggregateImpl(ProtocolVersion protocolVersion, Object firstParam, List<ByteBuffer> params) { throw new UnsupportedOperationException(); } - protected ByteBuffer executeImpl(int protocolVersion, List<ByteBuffer> params) + protected ByteBuffer executeImpl(ProtocolVersion protocolVersion, List<ByteBuffer> params) { return null; }