diff --git a/CHANGES.txt b/CHANGES.txt index 3dabef5ab235..defc57fbc7fd 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -11,6 +11,7 @@ Merged from 3.11: * Remove unnecessary String.format invocation in QueryProcessor when getting a prepared statement from cache (CASSANDRA-17202) * Fix the capital P usage in the CQL parser (CASSANDRA-17919) Merged from 3.0: + * Pass down all contact points to driver for cassandra-stress (CASSANDRA-18025) * Validate the existence of a datacenter in nodetool rebuild (CASSANDRA-14319) * Suppress CVE-2023-2251 (CASSANDRA-18497) * Do not remove SSTables when cause of FSReadError is OutOfMemoryError while using best_effort disk failure policy (CASSANDRA-18336) diff --git a/tools/stress/src/org/apache/cassandra/stress/settings/StressSettings.java b/tools/stress/src/org/apache/cassandra/stress/settings/StressSettings.java index 7026eb0cce81..4287123f4947 100644 --- a/tools/stress/src/org/apache/cassandra/stress/settings/StressSettings.java +++ b/tools/stress/src/org/apache/cassandra/stress/settings/StressSettings.java @@ -128,12 +128,11 @@ public JavaDriverClient getJavaDriverClient(String keyspace) try { - String currentNode = node.randomNode(); if (client != null) return client; EncryptionOptions encOptions = transport.getEncryptionOptions(); - JavaDriverClient c = new JavaDriverClient(this, currentNode, port.nativePort, encOptions); + JavaDriverClient c = new JavaDriverClient(this, node.nodes, port.nativePort, encOptions); c.connect(mode.compression()); if (keyspace != null) c.execute("USE \"" + keyspace + "\";", org.apache.cassandra.db.ConsistencyLevel.ONE); diff --git a/tools/stress/src/org/apache/cassandra/stress/util/JavaDriverClient.java b/tools/stress/src/org/apache/cassandra/stress/util/JavaDriverClient.java index e0b734ed2e3f..cf0eede34c72 100644 --- a/tools/stress/src/org/apache/cassandra/stress/util/JavaDriverClient.java +++ b/tools/stress/src/org/apache/cassandra/stress/util/JavaDriverClient.java @@ -19,6 +19,8 @@ import java.net.InetAddress; import java.net.InetSocketAddress; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -47,7 +49,7 @@ public class JavaDriverClient InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory()); } - public final String host; + public final List hosts; public final int port; public final String username; public final String password; @@ -65,13 +67,18 @@ public class JavaDriverClient public JavaDriverClient(StressSettings settings, String host, int port) { - this(settings, host, port, new EncryptionOptions()); + this(settings, Collections.singletonList(host), port, new EncryptionOptions()); } - public JavaDriverClient(StressSettings settings, String host, int port, EncryptionOptions encryptionOptions) + public JavaDriverClient(StressSettings settings, List hosts, int port) + { + this(settings, hosts, port, new EncryptionOptions()); + } + + public JavaDriverClient(StressSettings settings, List hosts, int port, EncryptionOptions encryptionOptions) { this.protocolVersion = settings.mode.protocolVersion; - this.host = host; + this.hosts = hosts; this.port = port; this.username = settings.mode.username; this.password = settings.mode.password; @@ -133,10 +140,16 @@ public void connect(ProtocolOptions.Compression compression) throws Exception .setMaxRequestsPerConnection(HostDistance.LOCAL, maxPendingPerConnection) .setNewConnectionThreshold(HostDistance.LOCAL, 100); - HostAndPort hap = HostAndPort.fromString(host).withDefaultPort(port); - InetSocketAddress contact = new InetSocketAddress(InetAddress.getByName(hap.getHost()), hap.getPort()); + List contacts = new ArrayList<>(); + for (String host : hosts) + { + HostAndPort hap = HostAndPort.fromString(host).withDefaultPort(port); + InetSocketAddress contact = new InetSocketAddress(InetAddress.getByName(hap.getHost()), hap.getPort()); + contacts.add(contact); + } + Cluster.Builder clusterBuilder = Cluster.builder() - .addContactPointsWithPorts(contact) + .addContactPointsWithPorts(contacts) .withPoolingOptions(poolingOpts) .withoutJMXReporting() .withProtocolVersion(protocolVersion)