Skip to content

Commit

Permalink
Cassandra 3.x + CQL: Remove the use of thrift protocol and rpc port t…
Browse files Browse the repository at this point in the history
…o prepare for Cassandra 4.x

Closes #177
  • Loading branch information
Jinn-Niam authored and slachiewicz committed Jan 6, 2024
1 parent d381705 commit 452a932
Show file tree
Hide file tree
Showing 29 changed files with 421 additions and 795 deletions.
22 changes: 12 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ under the License.
<slf4jVersion>1.7.36</slf4jVersion>
<log4jVersion>2.22.1</log4jVersion>
<commonsLoggingVersion>1.3.0</commonsLoggingVersion>
<datastax.driver.version>4.17.0</datastax.driver.version>
<buildHelperPluginVersion>3.5.0</buildHelperPluginVersion>
<project.build.outputTimestamp>2023-12-31T19:39:02Z</project.build.outputTimestamp>
</properties>
Expand All @@ -120,10 +121,6 @@ under the License.
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
</exclusion>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
Expand All @@ -134,11 +131,6 @@ under the License.
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.cassandra</groupId>
<artifactId>cassandra-thrift</artifactId>
<version>${cassandraVersion}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-settings</artifactId>
Expand Down Expand Up @@ -203,7 +195,17 @@ under the License.
<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-core-shaded</artifactId>
<version>4.17.0</version>
<version>${datastax.driver.version}</version>
</dependency>
<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-query-builder</artifactId>
<version>${datastax.driver.version}</version>
</dependency>
<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-mapper-runtime</artifactId>
<version>${datastax.driver.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-testing</groupId>
Expand Down
23 changes: 16 additions & 7 deletions src/it/smoke/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,19 @@ under the License.
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.cassandra</groupId>
<artifactId>cassandra-thrift</artifactId>
<version>@cassandraVersion@</version>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-core-shaded</artifactId>
<version>@datastax.driver.version@</version>
</dependency>
<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-query-builder</artifactId>
<version>@datastax.driver.version@</version>
</dependency>
<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-mapper-runtime</artifactId>
<version>@datastax.driver.version@</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down Expand Up @@ -115,7 +125,7 @@ under the License.
</executions>
<configuration>
<systemPropertyVariables>
<rpcPort>${cassandraPort}</rpcPort>
<nativeTransportPort>${cassandra.nativeTransportPort}</nativeTransportPort>
<storagePort>${cassandra.storagePort}</storagePort>
<stopPort>${cassandra.stopPort}</stopPort>
</systemPropertyVariables>
Expand All @@ -138,7 +148,6 @@ under the License.
<goals>
<goal>start</goal>
<goal>load</goal>
<goal>cu-load</goal>
<goal>stop</goal>
</goals>
</execution>
Expand All @@ -159,7 +168,7 @@ under the License.
<loadAfterFirstStart>false</loadAfterFirstStart>
<cuLoadAfterFirstStart>false</cuLoadAfterFirstStart>
<startNativeTransport>true</startNativeTransport>
<rpcPort>${cassandraPort}</rpcPort>
<nativeTransportPort>${cassandra.nativeTransportPort}</nativeTransportPort>
<storagePort>${cassandra.storagePort}</storagePort>
<stopPort>${cassandra.stopPort}</stopPort>
</configuration>
Expand All @@ -177,7 +186,7 @@ under the License.
</goals>
<configuration>
<portNames>
<portName>cassandraPort</portName>
<portName>cassandra.nativeTransportPort</portName>
<portName>cassandra.storagePort</portName>
<portName>cassandra.stopPort</portName>
</portNames>
Expand Down
26 changes: 8 additions & 18 deletions src/it/smoke/src/test/java/smoke/SmokeIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,10 @@
*/
package smoke;

import org.apache.cassandra.thrift.Cassandra;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TFramedTransport;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
import com.datastax.oss.driver.api.core.CqlSession;
import org.junit.Test;

import java.net.InetSocketAddress;
import java.util.AbstractMap;
import java.util.Map;

Expand All @@ -35,19 +31,13 @@
public class SmokeIT
{
@Test
public void connectToKeyspace() throws Exception
{
TTransport tr = new TFramedTransport(new TSocket("localhost", Integer.getInteger( "rpcPort", 9160 )));
TProtocol proto = new TBinaryProtocol(tr);
Cassandra.Client client = new Cassandra.Client(proto);
tr.open();
try
{
assertThat(client.describe_keyspace("testkeyspace").getStrategy_options().entrySet(),
public void connectToKeyspace_Cql() throws Exception{
try (CqlSession cqlSession = CqlSession.builder()
.addContactPoint(new InetSocketAddress("localhost", Integer.getInteger("nativeTransportPort", 9042)))
.withLocalDatacenter("datacenter1")
.build()) {
assertThat(cqlSession.getMetadata().getKeyspace("testkeyspace").get().getReplication().entrySet(),
hasItem((Map.Entry<String, String>)new AbstractMap.SimpleEntry<String,String>("replication_factor","1")));
} finally
{
tr.close();
}
}
}
19 changes: 0 additions & 19 deletions src/it/smoke/src/test/resources/dataSet.xml

This file was deleted.

22 changes: 16 additions & 6 deletions src/it/spaces in path/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,19 @@ under the License.
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.cassandra</groupId>
<artifactId>cassandra-thrift</artifactId>
<version>@cassandraVersion@</version>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-core-shaded</artifactId>
<version>@datastax.driver.version@</version>
</dependency>
<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-query-builder</artifactId>
<version>@datastax.driver.version@</version>
</dependency>
<dependency>
<groupId>com.datastax.oss</groupId>
<artifactId>java-driver-mapper-runtime</artifactId>
<version>@datastax.driver.version@</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down Expand Up @@ -115,7 +125,7 @@ under the License.
</executions>
<configuration>
<systemPropertyVariables>
<rpcPort>${cassandraPort}</rpcPort>
<nativeTransportPort>${cassandra.nativeTransportPort}</nativeTransportPort>
<storagePort>${cassandra.storagePort}</storagePort>
<stopPort>${cassandra.stopPort}</stopPort>
</systemPropertyVariables>
Expand Down Expand Up @@ -157,7 +167,7 @@ under the License.
<configuration>
<loadAfterFirstStart>false</loadAfterFirstStart>
<startNativeTransport>true</startNativeTransport>
<rpcPort>${cassandraPort}</rpcPort>
<nativeTransportPort>${cassandra.nativeTransportPort}</nativeTransportPort>
<storagePort>${cassandra.storagePort}</storagePort>
<stopPort>${cassandra.stopPort}</stopPort>
</configuration>
Expand All @@ -175,7 +185,7 @@ under the License.
</goals>
<configuration>
<portNames>
<portName>cassandraPort</portName>
<portName>cassandra.nativeTransportPort</portName>
<portName>cassandra.storagePort</portName>
<portName>cassandra.stopPort</portName>
</portNames>
Expand Down
26 changes: 8 additions & 18 deletions src/it/spaces in path/src/test/java/smoke/SmokeIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,10 @@
*/
package smoke;

import org.apache.cassandra.thrift.Cassandra;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.protocol.TProtocol;
import org.apache.thrift.transport.TFramedTransport;
import org.apache.thrift.transport.TSocket;
import org.apache.thrift.transport.TTransport;
import com.datastax.oss.driver.api.core.CqlSession;
import org.junit.Test;

import java.net.InetSocketAddress;
import java.util.AbstractMap;
import java.util.Map;

Expand All @@ -35,19 +31,13 @@
public class SmokeIT
{
@Test
public void connectToKeyspace() throws Exception
{
TTransport tr = new TFramedTransport(new TSocket("localhost", Integer.getInteger( "rpcPort", 9160 )));
TProtocol proto = new TBinaryProtocol(tr);
Cassandra.Client client = new Cassandra.Client(proto);
tr.open();
try
{
assertThat(client.describe_keyspace("testkeyspacewithspace").getStrategy_options().entrySet(),
public void connectToKeyspace_Cql() throws Exception{
try (CqlSession cqlSession = CqlSession.builder()
.addContactPoint(new InetSocketAddress("localhost", Integer.getInteger("nativeTransportPort", 9042)))
.withLocalDatacenter("datacenter1")
.build()) {
assertThat(cqlSession.getMetadata().getKeyspace("testkeyspacewithspace").get().getReplication().entrySet(),
hasItem((Map.Entry<String, String>)new AbstractMap.SimpleEntry<String,String>("replication_factor","1")));
} finally
{
tr.close();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,6 @@ public abstract class AbstractCassandraMojo
@Parameter(defaultValue = "127.0.0.1", required = true)
protected String rpcAddress;

/**
* Port to listen to for the RPC interface.
*
*/
@Parameter( property="cassandra.rpcPort", defaultValue="9160")
protected int rpcPort;

/**
* Port to listen to for the JMX interface.
*
Expand All @@ -157,7 +150,7 @@ public abstract class AbstractCassandraMojo
*
* @since 2.0.0-1
*/
@Parameter( property="cassandra.startNativeTransport", defaultValue="false")
@Parameter( property="cassandra.startNativeTransport", defaultValue="true")
protected boolean startNativeTransport;

/**
Expand Down Expand Up @@ -452,7 +445,6 @@ private void createCassandraYaml( File cassandraYaml, File data, File commitlog,
config.append( "listen_address: " ).append( listenAddress ).append( "\n" );
config.append( "storage_port: " ).append( storagePort ).append( "\n" );
config.append( "rpc_address: " ).append( rpcAddress ).append( "\n" );
config.append( "rpc_port: " ).append( rpcPort ).append( "\n" );
config.append( "native_transport_port: " ).append( nativeTransportPort ).append( "\n" );
config.append( "start_native_transport: " ).append( startNativeTransport ).append( "\n" );
if ( seeds != null )
Expand Down
Loading

0 comments on commit 452a932

Please sign in to comment.