diff --git a/achilles-embedded/src/main/java/info/archinnov/achilles/embedded/AchillesInitializer.java b/achilles-embedded/src/main/java/info/archinnov/achilles/embedded/AchillesInitializer.java index 8c3110b25..c53f32c9b 100644 --- a/achilles-embedded/src/main/java/info/archinnov/achilles/embedded/AchillesInitializer.java +++ b/achilles-embedded/src/main/java/info/archinnov/achilles/embedded/AchillesInitializer.java @@ -112,6 +112,7 @@ private Cluster createCluster(String host, int cqlPort, TypedMap parameters) { final LoadBalancingPolicy loadBalancingPolicy = parameters.getTyped(LOAD_BALANCING_POLICY); final RetryPolicy retryPolicy = parameters.getTyped(RETRY_POLICY); final ReconnectionPolicy reconnectionPolicy = parameters.getTyped(RECONNECTION_POLICY); + final ProtocolVersion protocolVersion = parameters.getTypedOr(CASSANDRA_CONNECTION_PROTOCOL_VERSION,ProtocolVersion.NEWEST_SUPPORTED); final SocketOptions socketOptions = new SocketOptions(); socketOptions.setKeepAlive(true); socketOptions.setConnectTimeoutMillis(15000); @@ -125,7 +126,7 @@ private Cluster createCluster(String host, int cqlPort, TypedMap parameters) { .withLoadBalancingPolicy(loadBalancingPolicy) .withRetryPolicy(retryPolicy) .withReconnectionPolicy(reconnectionPolicy) - .withProtocolVersion(ProtocolVersion.NEWEST_SUPPORTED) + .withProtocolVersion(protocolVersion) .withSocketOptions(socketOptions) .withoutJMXReporting() .build(); diff --git a/achilles-embedded/src/main/java/info/archinnov/achilles/embedded/CassandraEmbeddedConfigParameters.java b/achilles-embedded/src/main/java/info/archinnov/achilles/embedded/CassandraEmbeddedConfigParameters.java index a79a21b68..1bf2a8142 100644 --- a/achilles-embedded/src/main/java/info/archinnov/achilles/embedded/CassandraEmbeddedConfigParameters.java +++ b/achilles-embedded/src/main/java/info/archinnov/achilles/embedded/CassandraEmbeddedConfigParameters.java @@ -68,6 +68,8 @@ public class CassandraEmbeddedConfigParameters { public static final String CASSANDRA_CQL_PORT = "cqlPort"; + public static final String CASSANDRA_CONNECTION_PROTOCOL_VERSION = "connectionProtocolVersion"; + public static final String CASSANDRA_STORAGE_PORT = "storagePort"; public static final String CASSANDRA_STORAGE_SSL_PORT = "storageSSLPort"; diff --git a/achilles-embedded/src/main/java/info/archinnov/achilles/embedded/CassandraEmbeddedServerBuilder.java b/achilles-embedded/src/main/java/info/archinnov/achilles/embedded/CassandraEmbeddedServerBuilder.java index e566d59b2..f216922c9 100644 --- a/achilles-embedded/src/main/java/info/archinnov/achilles/embedded/CassandraEmbeddedServerBuilder.java +++ b/achilles-embedded/src/main/java/info/archinnov/achilles/embedded/CassandraEmbeddedServerBuilder.java @@ -25,6 +25,7 @@ import java.util.Map; import com.datastax.driver.core.Cluster; +import com.datastax.driver.core.ProtocolVersion; import com.datastax.driver.core.Session; import info.archinnov.achilles.type.TypedMap; @@ -88,6 +89,8 @@ public class CassandraEmbeddedServerBuilder { private int cqlPort; + private ProtocolVersion protocolVersion; + private int jmxPort; private int thriftPort; @@ -316,6 +319,18 @@ public CassandraEmbeddedServerBuilder withCQLPort(int clqPort) { return this; } + /** + * Specify the connection protocol version for the embedded Cassandra + * server. If not set, the version will be the newest supported. + * + * @param protocolVersion connection protocol version + * @return CassandraEmbeddedServerBuilder + */ + public CassandraEmbeddedServerBuilder withConnectionProtocol(ProtocolVersion protocolVersion) { + this.protocolVersion = protocolVersion; + return this; + } + /** * Specify the JMX port for the embedded Cassandra * server. If not set, the port will be randomized at runtime