Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions adapters/adapters-base/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ dependencies {

api("com.google.guava:guava:${project.rootProject.guavaVersion}")
compileOnly('org.jetbrains:annotations:23.0.0')
compileOnly('com.datastax.cassandra:cassandra-driver-core:3.11.3')
compileOnly('org.apache.cassandra:java-driver-core:4.19.1')
implementation("org.slf4j:slf4j-api:${project.slf4jVersion}")

testImplementation('com.datastax.cassandra:cassandra-driver-core:3.11.3')
testImplementation('org.apache.cassandra:java-driver-core:4.19.1')
testImplementation "org.junit.jupiter:junit-jupiter-api:${project.junitVersion}"
testImplementation "org.junit.jupiter:junit-jupiter-params:${project.junitVersion}"
testImplementation "org.assertj:assertj-core:3.24.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
import java.util.Map;
import java.util.Objects;

import com.datastax.driver.core.ConsistencyLevel;
import com.datastax.driver.core.Host;
import com.datastax.driver.core.Metadata;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.Session;
import com.datastax.driver.core.Statement;
import com.datastax.oss.driver.api.core.ConsistencyLevel;
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.cql.ResultSet;
import com.datastax.oss.driver.api.core.cql.Statement;
import com.datastax.oss.driver.api.core.metadata.Metadata;
import com.datastax.oss.driver.api.core.metadata.Node;
import org.apache.cassandra.sidecar.common.response.NodeSettings;
import org.apache.cassandra.sidecar.common.server.CQLSessionProvider;
import org.apache.cassandra.sidecar.common.server.ClusterMembershipOperations;
Expand Down Expand Up @@ -56,7 +56,7 @@ public class CassandraAdapter implements ICassandraAdapter
protected final CQLSessionProvider cqlSessionProvider;
protected final InetSocketAddress localNativeTransportAddress;
protected final DriverUtils driverUtils;
private volatile Host host;
private volatile Node host;
private final StorageOperations storageOperations;
private final ClusterMembershipOperations clusterMembershipOperations;
private final TableOperations tableOperations;
Expand Down Expand Up @@ -95,7 +95,7 @@ public CassandraAdapter(DnsResolver dnsResolver,
@NotNull
public Metadata metadata() throws CassandraUnavailableException
{
return cqlSessionProvider.get().getCluster().getMetadata();
return cqlSessionProvider.get().getMetadata();
}

/**
Expand All @@ -117,13 +117,13 @@ public Map<String, String> v2NodeSettings()

@Override
@NotNull
public ResultSet executeLocal(Statement statement)
public ResultSet executeLocal(Statement<?> statement)
{
Session activeSession = cqlSessionProvider.get();
CqlSession activeSession = cqlSessionProvider.get();
Metadata metadata = metadata();
Host host = getHost(metadata);
statement.setConsistencyLevel(ConsistencyLevel.ONE);
statement.setHost(host);
Node host = getHost(metadata);
statement = statement.setConsistencyLevel(ConsistencyLevel.ONE)
.setNode(host);
return activeSession.execute(statement);
}

Expand All @@ -139,7 +139,7 @@ public InetSocketAddress localNativeTransportAddress()
public InetSocketAddress localStorageBroadcastAddress()
{
Metadata metadata = metadata();
return getHost(metadata).getBroadcastSocketAddress();
return getHost(metadata).getBroadcastAddress().get();
}

/**
Expand Down Expand Up @@ -248,7 +248,7 @@ protected CompactionStatsOperations createCompactionStatsOperations(StorageOpera
}

@NotNull
protected Host getHost(Metadata metadata)
protected Node getHost(Metadata metadata)
{
if (host != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import java.util.Map;

import com.datastax.driver.core.Row;
import com.datastax.oss.driver.api.core.cql.Row;
import org.apache.cassandra.sidecar.db.DataObjectMappingException;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -53,7 +53,7 @@ public static ConnectedClientStats from(@NotNull Row row) throws DataObjectMappi

public ConnectedClientStats(@NotNull Row row)
{
this.address = row.getInet("address").getHostAddress();
this.address = row.getInetAddress("address").getHostAddress();
this.port = row.getInt("port");
this.hostname = row.getString("hostname");
this.username = row.getString("username");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

import com.datastax.driver.core.BoundStatement;
import com.datastax.driver.core.ResultSet;
import com.datastax.oss.driver.api.core.cql.BoundStatement;
import com.datastax.oss.driver.api.core.cql.ResultSet;
import org.apache.cassandra.sidecar.adapters.base.db.schema.ConnectedClientsSchema;
import org.apache.cassandra.sidecar.common.server.ICassandraAdapter;
import org.apache.cassandra.sidecar.common.utils.Preconditions;
Expand All @@ -46,7 +46,7 @@ public ConnectedClientStatsDatabaseAccessor(TableSchemaFetcher tableSchemaFetche
public ConnectedClientStatsSummary summary()
{
Preconditions.checkState(tableSchema.isInitialized(), () -> tableSchema.getClass().getSimpleName() + " is not initialized yet");
BoundStatement statement = tableSchema.connectionsByUser().bind();
BoundStatement statement = tableSchema.connectionsByUser().bind().setConsistencyLevel(tableSchema.getConsistencyLevel());
ResultSet resultSet = execute(statement);
return ConnectedClientStatsSummary.from(resultSet);
}
Expand All @@ -58,7 +58,7 @@ public ConnectedClientStatsSummary summary()
public Stream<ConnectedClientStats> stats()
{
Preconditions.checkState(tableSchema.isInitialized(), () -> tableSchema.getClass().getSimpleName() + " is not initialized yet");
BoundStatement statement = tableSchema.stats().bind();
BoundStatement statement = tableSchema.stats().bind().setConsistencyLevel(tableSchema.getConsistencyLevel());
ResultSet resultSet = execute(statement);
return StreamSupport.stream(resultSet.spliterator(), false)
.map(ConnectedClientStats::from);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;

import com.datastax.driver.core.ResultSet;
import com.datastax.oss.driver.api.core.cql.ResultSet;
import org.apache.cassandra.sidecar.db.DataObjectMappingException;
import org.jetbrains.annotations.NotNull;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@

package org.apache.cassandra.sidecar.adapters.base.db.schema;

import com.datastax.driver.core.PreparedStatement;
import com.datastax.driver.core.Session;
import com.datastax.oss.driver.api.core.ConsistencyLevel;
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.cql.PreparedStatement;
import org.apache.cassandra.sidecar.db.schema.CassandraSystemTableSchema;
import org.jetbrains.annotations.NotNull;

Expand All @@ -42,12 +43,18 @@ protected String keyspaceName()
}

@Override
public void prepareStatements(@NotNull Session session)
public void prepareStatements(@NotNull CqlSession session)
{
statsStatement = prepare(statsStatement, session, statsStatement());
connectionsByUserStatement = prepare(connectionsByUserStatement, session, selectConnectionsByUserStatement());
}

@Override
public ConsistencyLevel getConsistencyLevel()
{
return ConsistencyLevel.LOCAL_QUORUM;
}

@Override
protected String tableName()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

import org.junit.jupiter.api.Test;

import com.datastax.driver.core.ColumnDefinitions;
import com.datastax.driver.core.Row;
import com.datastax.oss.driver.api.core.cql.ColumnDefinitions;
import com.datastax.oss.driver.api.core.cql.Row;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.ArgumentMatchers.anyString;
Expand Down Expand Up @@ -109,7 +109,7 @@ private void setupMockData(Row mockRow, boolean isMissingFields)
when(mockRow.getColumnDefinitions().contains(anyString())).thenReturn(true);
}

when(mockRow.getInet("address")).thenReturn(InetAddress.getLoopbackAddress());
when(mockRow.getInetAddress("address")).thenReturn(InetAddress.getLoopbackAddress());
when(mockRow.getInt("port")).thenReturn(0);
when(mockRow.getString("hostname")).thenReturn("localhost");
when(mockRow.getString("username")).thenReturn("u1");
Expand All @@ -125,6 +125,5 @@ private void setupMockData(Row mockRow, boolean isMissingFields)
when(mockRow.getMap("authentication_metadata", String.class, String.class)).thenReturn(authMetadata);
when(mockRow.getString("authentication_mode")).thenReturn(authMode);
when(mockRow.getMap("client_options", String.class, String.class)).thenReturn(clientOptions);

}
}
2 changes: 1 addition & 1 deletion adapters/adapters-cassandra41/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ dependencies {
api(project(":adapters:adapters-base"))

compileOnly('org.jetbrains:annotations:23.0.0')
compileOnly('com.datastax.cassandra:cassandra-driver-core:3.11.3')
compileOnly('org.apache.cassandra:java-driver-core:4.19.1')
implementation("org.slf4j:slf4j-api:${project.slf4jVersion}")
}

Expand Down
2 changes: 1 addition & 1 deletion adapters/adapters-cassandra50/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ dependencies {
api(project(":adapters:adapters-cassandra41"))

compileOnly('org.jetbrains:annotations:23.0.0')
compileOnly('com.datastax.cassandra:cassandra-driver-core:3.11.3')
compileOnly('org.apache.cassandra:java-driver-core:4.19.1')
implementation("org.slf4j:slf4j-api:${project.slf4jVersion}")
}

Expand Down
3 changes: 1 addition & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,9 @@ allprojects {
}

repositories {
mavenCentral()

// for dtest jar
mavenLocal()
mavenCentral()
}

checkstyle {
Expand Down
4 changes: 1 addition & 3 deletions conf/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,5 @@
<appender-ref ref="STDOUT" />
</root>


<logger name="com.datastax.driver.core" level="ERROR" />
<logger name="com.datastax.driver.core.ControlConnection" level="OFF" />
<logger name="com.datastax.oss.driver" level="ERROR" />
</configuration>
2 changes: 1 addition & 1 deletion conf/sidecar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ driver_parameters:
path: path/to/keystore.p12
password: password
num_connections: 6
# local_dc: datacenter1
local_dc: datacenter1
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

local_dc becomes a mandatory field. Java driver will not establish connectivity with the cluster unless local data centre is known. Default behaviour of 4.x version.


healthcheck:
initial_delay: 0ms
Expand Down
2 changes: 1 addition & 1 deletion examples/lifecycle/conf/sidecar.yaml.template
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ driver_parameters:
path: path/to/keystore.p12
password: password
num_connections: 6
# local_dc: datacenter1
local_dc: datacenter1

healthcheck:
initial_delay: 0ms
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ swaggerVersion=2.2.21
kryoVersion=4.0.2
# OSHI dependencies
oshiVersion=6.9.0
analyticsVersion=0.3.0
analyticsVersion=0.4-SNAPSHOT
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Temporary increment to test Analytics and Sidecar locally. Due to shared interface of CQLSessionProvider (which references driver 3.x API that changed), both projects have to be upgraded together.

kafkaClientVersion=3.7.0
2 changes: 1 addition & 1 deletion integration-framework/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ dependencies {
api('org.mockito:mockito-inline:4.10.0')
api("org.assertj:assertj-core:${assertjCoreVersion}")

api('com.datastax.cassandra:cassandra-driver-core:3.11.5')
api('org.apache.cassandra:java-driver-core:4.19.1')
implementation("com.google.inject:guice:${guiceVersion}")

implementation("com.google.guava:guava:27.0.1-jre")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@
import org.slf4j.LoggerFactory;

import com.codahale.metrics.MetricRegistry;
import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.ResultSet;
import com.datastax.driver.core.Session;
import com.datastax.driver.core.SimpleStatement;
import com.datastax.oss.driver.api.core.CqlSession;
import com.datastax.oss.driver.api.core.CqlSessionBuilder;
import com.datastax.oss.driver.api.core.DefaultConsistencyLevel;
import com.datastax.oss.driver.api.core.cql.ResultSet;
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
Expand Down Expand Up @@ -323,7 +324,7 @@ protected void createTestKeyspace(QualifiedName name, Map<String, Integer> rf)
createTestKeyspace(name.maybeQuotedKeyspace(), rf);
}

protected void createTestKeyspace(Session session, QualifiedName name, Map<String, Integer> rf)
protected void createTestKeyspace(CqlSession session, QualifiedName name, Map<String, Integer> rf)
{
createTestKeyspace(session, name.maybeQuotedKeyspace(), rf);
}
Expand All @@ -333,7 +334,7 @@ protected void createTestKeyspace(String keyspace, Map<String, Integer> rf)
createTestKeyspace(cluster::schemaChangeIgnoringStoppedInstances, keyspace, rf);
}

protected void createTestKeyspace(Session session, String keyspace, Map<String, Integer> rf)
protected void createTestKeyspace(CqlSession session, String keyspace, Map<String, Integer> rf)
{
createTestKeyspace(session::execute, keyspace, rf);
}
Expand All @@ -350,7 +351,7 @@ protected void createTestTable(QualifiedName name, String createTableStatement)
createTestTable(cluster::schemaChangeIgnoringStoppedInstances, name, createTableStatement);
}

protected void createTestTable(Session session, QualifiedName name, String createTableStatement)
protected void createTestTable(CqlSession session, QualifiedName name, String createTableStatement)
{
createTestTable(session::execute, name, createTableStatement);
}
Expand Down Expand Up @@ -578,21 +579,20 @@ protected ResultSet queryAllDataWithDriver(QualifiedName table)
*/
protected ResultSet queryAllDataWithDriver(QualifiedName table, ConsistencyLevel consistency)
{
Cluster driverCluster = createDriverCluster(cluster.delegate());
Session session = driverCluster.connect();
SimpleStatement statement = new SimpleStatement(String.format("SELECT * FROM %s;", table));
statement.setConsistencyLevel(com.datastax.driver.core.ConsistencyLevel.valueOf(consistency.name()));
CqlSession session = createDriverSession(cluster.delegate());
SimpleStatement statement = SimpleStatement.newInstance(String.format("SELECT * FROM %s;", table))
.setConsistencyLevel(DefaultConsistencyLevel.valueOf(consistency.name()));
return session.execute(statement);
}

// Utility methods

public static Cluster createDriverCluster(ICluster<? extends IInstance> dtest)
public static CqlSession createDriverSession(ICluster<? extends IInstance> dtest)
{
return createDriverCluster(dtest, null);
return createDriverSession(dtest, null);
}

public static Cluster createDriverCluster(ICluster<? extends IInstance> dtest, Consumer<com.datastax.driver.core.Cluster.Builder> overrideBuilder)
public static CqlSession createDriverSession(ICluster<? extends IInstance> dtest, Consumer<CqlSessionBuilder> overrideBuilder)
{
dtest.stream().forEach((i) -> {
if (!i.config().has(Feature.NATIVE_PROTOCOL) || !i.config().has(Feature.GOSSIP))
Expand All @@ -601,12 +601,12 @@ public static Cluster createDriverCluster(ICluster<? extends IInstance> dtest, C
"but one or more is missing");
}
});
Cluster.Builder builder = Cluster.builder()
.withoutMetrics();
CqlSessionBuilder builder = CqlSession.builder();
dtest.stream().forEach((i) -> {
InetSocketAddress address = new InetSocketAddress(i.broadcastAddress().getAddress(),
i.config().getInt("native_transport_port"));
builder.addContactPointsWithPorts(address);
builder.addContactPoint(address);
builder.withLocalDatacenter(i.config().localDatacenter());
});
if (overrideBuilder != null)
{
Expand Down Expand Up @@ -733,8 +733,8 @@ public IntegrationTestModule(Iterable<? extends IInstance> instances,
public CQLSessionProvider cqlSessionProvider()
{
List<InetSocketAddress> contactPoints = buildContactPoints(instances);
return new TemporaryCqlSessionProvider(contactPoints,
SharedExecutorNettyOptions.INSTANCE);
IInstance instance = instances.iterator().next();
return new TemporaryCqlSessionProvider(contactPoints, instance.config().localDatacenter(), null);
}

@Provides
Expand Down
Loading