Skip to content

Commit

Permalink
Merge branch '3.x' (at 3.11.5) into scylla-3.x
Browse files Browse the repository at this point in the history
Update to 3.11.5 from upstream repo.
  • Loading branch information
avelanarius committed Sep 28, 2023
2 parents 5abdcb1 + 7fd265f commit 4769101
Show file tree
Hide file tree
Showing 56 changed files with 705 additions and 82 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ not yet have been released. You can find the documentation for the latest
version through the [Java driver
docs](https://docs.scylladb.com/using-scylla/scylla-java-driver/) or via the release tags,
[e.g.
3.11.4.0](https://github.com/scylladb/java-driver/releases/tag/3.11.4.0).*
3.11.5.0](https://github.com/scylladb/java-driver/releases/tag/3.11.5.0).*

A modern, [feature-rich](manual/) and highly tunable Java client
library for Apache Cassandra (2.1+) and using exclusively Cassandra's binary protocol
Expand Down Expand Up @@ -62,7 +62,7 @@ it in your application using the following Maven dependency
<dependency>
<groupId>com.scylladb</groupId>
<artifactId>scylla-driver-core</artifactId>
<version>3.11.4.0</version>
<version>3.11.5.0</version>
</dependency>
```

Expand All @@ -72,7 +72,7 @@ Note that the object mapper is published as a separate artifact:
<dependency>
<groupId>com.scylladb</groupId>
<artifactId>scylla-driver-mapping</artifactId>
<version>3.11.4.0</version>
<version>3.11.5.0</version>
</dependency>
```

Expand All @@ -82,7 +82,7 @@ The 'extras' module is also published as a separate artifact:
<dependency>
<groupId>com.scylladb</groupId>
<artifactId>scylla-driver-extras</artifactId>
<version>3.11.4.0</version>
<version>3.11.5.0</version>
</dependency>
```

Expand All @@ -92,7 +92,7 @@ to avoid the explicit dependency to Netty.

## Compatibility

The Java client driver 3.11.4.0 ([branch scylla-3.x](https://github.com/scylladb/java-driver/tree/scylla-3.x)) is compatible with
The Java client driver 3.11.5.0 ([branch scylla-3.x](https://github.com/scylladb/java-driver/tree/scylla-3.x)) is compatible with
Scylla and Apache Cassandra 2.1, 2.2, 3.0+.

UDT and tuple support is available only when using Apache Cassandra 2.1 or higher.
Expand Down
4 changes: 4 additions & 0 deletions changelog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
3.x versions get published.
-->

### 3.11.5
- [improvement] JAVA-3114: Shade io.dropwizard.metrics:metrics-core in shaded driver
- [improvement] JAVA-3115: SchemaChangeListener#onKeyspaceChanged can fire when keyspace has not changed if using SimpleStrategy replication

### 3.11.4
- [improvement] JAVA-3079: Upgrade Netty to 4.1.94, 3.x edition
- [improvement] JAVA-3082: Fix maven build for Apple-silicon
Expand Down
12 changes: 10 additions & 2 deletions driver-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<parent>
<groupId>com.scylladb</groupId>
<artifactId>scylla-driver-parent</artifactId>
<version>3.11.4.1-SNAPSHOT</version>
<version>3.11.5.0-SNAPSHOT</version>
</parent>

<artifactId>scylla-driver-core</artifactId>
Expand Down Expand Up @@ -287,8 +287,9 @@
JNR does not provide OSGi bundles, so exclude it; the driver can live without it
Explicitly import javax.security.cert because it's required by Netty, but Netty has been explicitly excluded
-->
<Import-Package><![CDATA[com.google.common.*;version="16.0.1",!jnr.*,!io.netty.*,javax.security.cert,*]]></Import-Package>
<Import-Package><![CDATA[com.google.common.*;version="16.0.1",!jnr.*,!io.netty.*,!com.codahale.metrics,javax.security.cert,javax.management,*]]></Import-Package>
<Private-Package>com.datastax.shaded.*</Private-Package>
<Export-Package>com.datastax.shaded.metrics;*</Export-Package>
</instructions>
</configuration>
</execution>
Expand All @@ -302,6 +303,7 @@
<artifactSet>
<includes>
<include>io.netty:*</include>
<include>io.dropwizard.metrics:metrics-core</include>
</includes>
<excludes>
<exclude>io.netty:netty-transport-native-epoll</exclude>
Expand All @@ -312,6 +314,10 @@
<pattern>io.netty</pattern>
<shadedPattern>com.datastax.shaded.netty</shadedPattern>
</relocation>
<relocation>
<pattern>com.codahale.metrics</pattern>
<shadedPattern>com.datastax.shaded.metrics</shadedPattern>
</relocation>
</relocations>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.DontIncludeResourceTransformer">
Expand All @@ -328,6 +334,8 @@
<resource>META-INF/maven/io.netty/netty-handler/pom.xml</resource>
<resource>META-INF/maven/io.netty/netty-transport/pom.properties</resource>
<resource>META-INF/maven/io.netty/netty-transport/pom.xml</resource>
<resource>META-INF/maven/io.dropwizard.metrics/metrics-core/pom.properties</resource>
<resource>META-INF/maven/io.dropwizard.metrics/metrics-core/pom.xml</resource>
</resources>
</transformer>
<!-- Pick up the alternate manifest that was generated by the alternate execution of the bundle plugin -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public boolean equals(Object o) {

SimpleStrategy that = (SimpleStrategy) o;

return replicationFactor == that.replicationFactor;
return replicationFactor.equals(that.replicationFactor);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.ITestResult;
import org.testng.SkipException;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
Expand Down Expand Up @@ -1181,4 +1182,17 @@ private static <T> T instantiate(Class<? extends T> clazz)
return (T) constructor.newInstance(enclosingInstance);
}
}

protected boolean isCassandraVersionOrHigher(String version) {
return CCMBridge.getGlobalCassandraVersion().compareTo(VersionNumber.parse(version)) >= 0;
}

protected void skipTestWithCassandraVersionOrHigher(String version, String testKind) {
if (isCassandraVersionOrHigher(version)) {
throw new SkipException(
String.format(
"%s tests not applicable to cassandra version >= %s (configured: %s)",
testKind, version, CCMBridge.getGlobalCassandraVersion()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ public void should_handle_failing_or_missing_contact_points() throws UnknownHost
cluster =
Cluster.builder()
.withPort(scassandra.getBinaryPort())
// scassandra supports max V4 protocol
.withProtocolVersion(ProtocolVersion.V4)
.addContactPoints(
ipOfNode(1),
failingHosts.get(0).address,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class DirectCompressionTest extends CompressionTest {
*/
@Test(groups = "short")
public void should_function_with_snappy_compression() throws Exception {
skipTestWithCassandraVersionOrHigher("4.0.0", "snappy");
compressionTest(ProtocolOptions.Compression.SNAPPY);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.datastax.driver.core.querybuilder.Insert;
import com.datastax.driver.core.schemabuilder.Create;
import com.datastax.driver.core.schemabuilder.SchemaBuilder;
import com.datastax.driver.core.utils.CassandraVersion;
import java.nio.ByteBuffer;
import java.util.Collection;
import java.util.Random;
Expand Down Expand Up @@ -105,22 +106,42 @@ public void onTestContextInitialized() {
*/
@Test(groups = "isolated")
public void should_throw_exception_when_frame_exceeds_configured_max() {
skipTestWithCassandraVersionOrHigher("4.0.0", "frame-size exceeding with default-protocol");
run_frame_size_exceeding_queries(session());
}

/**
* With cassandra 4.0.0+, V5 protocol is default which breaks requests into segments. Force V4
* protocol to allow us to test frame-size limitation code.
*/
@CassandraVersion("4.0.0")
@Test(groups = "isolated")
public void should_throw_exception_when_frame_exceeds_configured_max_v4_protocol_cassandra4() {
Cluster cluster =
register(createClusterBuilder().withProtocolVersion(ProtocolVersion.V4).build());
Session session = register(cluster.connect());
useKeyspace(session, keyspace);

run_frame_size_exceeding_queries(session);
}

private void run_frame_size_exceeding_queries(Session session) {
try {
session().execute(select().from(tableName).where(eq("k", 0)));
session.execute(select().from(tableName).where(eq("k", 0)));
fail("Exception expected");
} catch (FrameTooLongException ftle) {
// Expected.
}

// Both hosts should remain up.
Collection<Host> hosts = session().getState().getConnectedHosts();
Collection<Host> hosts = session.getState().getConnectedHosts();
assertThat(hosts).hasSize(2).extractingResultOf("isUp").containsOnly(true);

// Should be able to make a query that is less than the max frame size.
// Execute multiple time to exercise all hosts.
for (int i = 0; i < 10; i++) {
ResultSet result =
session().execute(select().from(tableName).where(eq("k", 0)).and(eq("c", 0)));
session.execute(select().from(tableName).where(eq("k", 0)).and(eq("c", 0)));
assertThat(result.getAvailableWithoutFetching()).isEqualTo(1);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public void beforeTestClass() throws Exception {
*/
@Test(groups = "isolated")
public void should_function_with_snappy_compression() throws Exception {
skipTestWithCassandraVersionOrHigher("4.0.0", "snappy");
compressionTest(ProtocolOptions.Compression.SNAPPY);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ public void should_init_policy_with_up_contact_points() throws Exception {
try {
cluster.init();

// To support astra, only hosts in Metadata#getContactPoints are passed to init()
// TestUtils#configureClusterBuilder only uses the first host as the contact point
// Remaining hosts are learned after connection via onAdd()
assertThat(policy.history)
.containsOnly(
entry(INIT, TestUtils.findHost(cluster, 1)),
Expand Down Expand Up @@ -104,8 +107,16 @@ public void should_send_down_notifications_after_init_when_contact_points_are_do
ccm().stop(nodeToStop);
ccm().waitForDown(nodeToStop);

// usually only one contact point is used to build the test cluster
// here we explicitly add both endpoints so we can test load
// balancing initial connection when the first connection point is down
HistoryPolicy policy = new HistoryPolicy(new RoundRobinPolicy());
Cluster cluster = register(createClusterBuilder().withLoadBalancingPolicy(policy).build());
Cluster cluster =
register(
createClusterBuilder()
.addContactPoints(ccm().getContactPoints().get(1))
.withLoadBalancingPolicy(policy)
.build());

try {
cluster.init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,10 @@ public OPPTokenIntegrationTest() {
protected Token.Factory tokenFactory() {
return OPPToken.FACTORY;
}

@Override
public void beforeTestClass(Object testInstance) throws Exception {
skipTestWithCassandraVersionOrHigher("4.0.0", "ByteOrderedPartitioner");
super.beforeTestClass(testInstance);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,10 @@ public OPPTokenVnodeIntegrationTest() {
protected Token.Factory tokenFactory() {
return Token.OPPToken.FACTORY;
}

@Override
public void beforeTestClass(Object testInstance) throws Exception {
skipTestWithCassandraVersionOrHigher("4.0.0", "ByteOrderedPartitioner");
super.beforeTestClass(testInstance);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.datastax.driver.core;

import static org.assertj.core.api.Assertions.assertThat;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
Expand Down Expand Up @@ -87,4 +88,77 @@ public void createUnspecifiedStrategyTest() throws Exception {

assertNull(strategy);
}

@Test(groups = "unit")
public void simpleStrategyEqualsTest() {
ReplicationStrategy rf3_1 =
ReplicationStrategy.create(
ImmutableMap.<String, String>builder()
.put("class", "SimpleStrategy")
.put("replication_factor", "3")
.build());

ReplicationStrategy rf3_2 =
ReplicationStrategy.create(
ImmutableMap.<String, String>builder()
.put("class", "SimpleStrategy")
.put("replication_factor", "3")
.build());

ReplicationStrategy rf2_1 =
ReplicationStrategy.create(
ImmutableMap.<String, String>builder()
.put("class", "SimpleStrategy")
.put("replication_factor", "2")
.build());

//noinspection EqualsWithItself
assertThat(rf3_1).isEqualTo(rf3_1);
assertThat(rf3_1).isEqualTo(rf3_2);
assertThat(rf3_1).isNotEqualTo(rf2_1);
}

public void networkTopologyStrategyEqualsTest() {
ReplicationStrategy network_dc1x2_dc2x2_1 =
ReplicationStrategy.create(
ImmutableMap.<String, String>builder()
.put("class", "NetworkTopologyStrategy")
.put("dc1", "2")
.put("dc2", "2")
.build());
ReplicationStrategy network_dc1x2_dc2x2_2 =
ReplicationStrategy.create(
ImmutableMap.<String, String>builder()
.put("class", "NetworkTopologyStrategy")
.put("dc1", "2")
.put("dc2", "2")
.build());
ReplicationStrategy network_dc1x1_dc2x2_1 =
ReplicationStrategy.create(
ImmutableMap.<String, String>builder()
.put("class", "NetworkTopologyStrategy")
.put("dc1", "1")
.put("dc2", "2")
.build());
ReplicationStrategy network_dc1x2_dc3x2_1 =
ReplicationStrategy.create(
ImmutableMap.<String, String>builder()
.put("class", "NetworkTopologyStrategy")
.put("dc1", "2")
.put("dc3", "2")
.build());
ReplicationStrategy network_dc1x2_1 =
ReplicationStrategy.create(
ImmutableMap.<String, String>builder()
.put("class", "NetworkTopologyStrategy")
.put("dc1", "2")
.build());

//noinspection EqualsWithItself
assertThat(network_dc1x2_dc2x2_1).isEqualTo(network_dc1x2_dc2x2_1);
assertThat(network_dc1x2_dc2x2_1).isEqualTo(network_dc1x2_dc2x2_2);
assertThat(network_dc1x2_dc2x2_1).isNotEqualTo(network_dc1x1_dc2x2_1);
assertThat(network_dc1x2_dc2x2_1).isNotEqualTo(network_dc1x2_dc3x2_1);
assertThat(network_dc1x2_dc2x2_1).isNotEqualTo(network_dc1x2_1);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@ public void should_receive_changes_made_while_control_connection_is_down_on_reco
// Perform some schema changes that we'll validate when the control connection comes back.
session2.execute("drop keyspace ks2");
session2.execute("drop table ks1.tbl2");
session2.execute("alter keyspace ks1 with durable_writes=false");

// Modifying keyspaces with a node down is not possible in 4.0+ (CASSANDRA-14404)
if (!isCassandraVersionOrHigher("4.0.0")) {
session2.execute("alter keyspace ks1 with durable_writes=false");
}

session2.execute("alter table ks1.tbl1 add new_col varchar");
session2.execute(String.format(CREATE_KEYSPACE_SIMPLE_FORMAT, "ks3", 1));
session2.execute("create table ks1.tbl3 (k text primary key, v text)");
Expand Down Expand Up @@ -152,8 +157,11 @@ public void should_receive_changes_made_while_control_connection_is_down_on_reco
.isDurableWrites()
.isEqualTo(prealteredKeyspace);

// New metadata should reflect that the durable writes attribute changed.
assertThat(alteredKeyspace.getValue()).hasName("ks1").isNotDurableWrites();
// Modifying keyspaces with a node down is not possible in 4.0+ (CASSANDRA-14404)
if (!isCassandraVersionOrHigher("4.0.0")) {
// New metadata should reflect that the durable writes attribute changed.
assertThat(alteredKeyspace.getValue()).hasName("ks1").isNotDurableWrites();
}

// Ensure the alter table event shows up.
ArgumentCaptor<TableMetadata> alteredTable = ArgumentCaptor.forClass(TableMetadata.class);
Expand Down
2 changes: 1 addition & 1 deletion driver-dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<parent>
<groupId>com.scylladb</groupId>
<artifactId>scylla-driver-parent</artifactId>
<version>3.11.4.1-SNAPSHOT</version>
<version>3.11.5.0-SNAPSHOT</version>
</parent>

<artifactId>scylla-driver-dist</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion driver-examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<parent>
<groupId>com.scylladb</groupId>
<artifactId>scylla-driver-parent</artifactId>
<version>3.11.4.1-SNAPSHOT</version>
<version>3.11.5.0-SNAPSHOT</version>
</parent>

<artifactId>scylla-driver-examples</artifactId>
Expand Down
Loading

0 comments on commit 4769101

Please sign in to comment.