Skip to content

Commit

Permalink
Merge branch 'cassandra-3.11' into cassandra-4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
smiklosovic committed May 19, 2023
2 parents ff82029 + e1e88e5 commit dc6ad3f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -47,7 +49,7 @@ public class JavaDriverClient
InternalLoggerFactory.setDefaultFactory(new Slf4JLoggerFactory());
}

public final String host;
public final List<String> hosts;
public final int port;
public final String username;
public final String password;
Expand All @@ -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<String> hosts, int port)
{
this(settings, hosts, port, new EncryptionOptions());
}

public JavaDriverClient(StressSettings settings, List<String> 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;
Expand Down Expand Up @@ -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<InetSocketAddress> 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)
Expand Down

0 comments on commit dc6ad3f

Please sign in to comment.