Skip to content

Commit

Permalink
embedded: server builder now supports setting protocol version
Browse files Browse the repository at this point in the history
If not supplied the ProtocolVersion.NEWEST_SUPPORTED will be used
in order to maintain backwards compatibility.
  • Loading branch information
hjizettle committed Mar 26, 2021
1 parent b85a7f9 commit c41733f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -88,6 +89,8 @@ public class CassandraEmbeddedServerBuilder {

private int cqlPort;

private ProtocolVersion protocolVersion;

private int jmxPort;

private int thriftPort;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c41733f

Please sign in to comment.