2

I am using java driver version: 2.1.4
Cassandra version: dsc-cassandra-2.1.10
Output from cql gives the following

cqlsh 5.0.1 | Cassandra 2.1.10 | CQL spec 3.2.1 | Native protocol v3

I am protocol V3. But it throws an exception when I try to set it to more than 128 requests per connection. This seems to be a restriction in V2. Explained below:

The following code block:

PoolingOptions poolingOptions = new PoolingOptions();
poolingOptions.setCoreConnectionsPerHost(HostDistance.LOCAL, 8);

Cluster cluster = Cluster.builder()
                         .addContactPoints(x.x.x.x)
                         .withPoolingOptions(poolingOptions)
                         .withProtocolVersion(ProtocolVersion.V3)
                         .build();

System.out.println("Protocol version = "+myCurrentVersion);
System.out.println("LOCAL CORE = "+poolingOptions.getCoreConnectionsPerHost(HostDistance.LOCAL));
System.out.println("LOCAL MAX = "+poolingOptions.getMaxConnectionsPerHost(HostDistance.LOCAL));
System.out.println("Max sim requests = "+poolingOptions.getMaxSimultaneousRequestsPerConnectionThreshold(HostDistance.LOCAL));
System.out.println("Max sim requests per host = "+poolingOptions.getMaxSimultaneousRequestsPerHostThreshold(HostDistance.LOCAL));

 poolingOptions
.setMaxSimultaneousRequestsPerHostThreshold(HostDistance.LOCAL, 3000);

 poolingOptions
.setMaxSimultaneousRequestsPerConnectionThreshold(HostDistance.LOCAL, 128);         

System.out.println("LOCAL CORE = "+poolingOptions.getCoreConnectionsPerHost(HostDistance.LOCAL));
System.out.println("LOCAL MAX = "+poolingOptions.getMaxConnectionsPerHost(HostDistance.LOCAL));
System.out.println("Max sim requests = "+poolingOptions.getMaxSimultaneousRequestsPerConnectionThreshold(HostDistance.LOCAL));
System.out.println("Max sim requests per host = "+poolingOptions.getMaxSimultaneousRequestsPerHostThreshold(HostDistance.LOCAL));

The output is:

Protocol version = V3
LOCAL CORE = 1
LOCAL MAX = 8
Max sim requests = 100
Max sim requests per host = 1024
Exception in thread "main" java.lang.IllegalArgumentException: Max simultaneous requests per connection for LOCAL hosts must be in the range (0, 128)
    at com.datastax.driver.core.PoolingOptions.checkRequestsPerConnectionRange(PoolingOptions.java:370)
    at com.datastax.driver.core.PoolingOptions.setMaxSimultaneousRequestsPerConnectionThreshold(PoolingOptions.java:175)
    at ca.txio.pricehistoryservice.main.ConnectionOptionTest.main(ConnectionOptionTest.java:38)

According to the Cassandra documentation https://docs.datastax.com/en/developer/java-driver/2.1/manual/native_protocol/ and http://docs.datastax.com/en/developer/java-driver/2.1/manual/pooling/

I am protocol V3. But why am I restricted to 128 requests per connection. This seems to be a restriction in V2. Could someone please explain how to find what version I actually am, and if indeed V3, why can't I have more than 128 simultaneous connections?

GenerousJoker
  • 87
  • 1
  • 12

1 Answers1

2

With ProtocolVersion#V3 or above, there are up to 32768 requests per connection, and the pool defaults to a fixed size of 1. You will typically raise the maximum capacity by allowing more simultaneous requests per connection (setMaxRequestsPerConnection(HostDistance, int))

Ref: http://docs.datastax.com/en/drivers/java/2.1/com/datastax/driver/core/PoolingOptions.html#setMaxRequestsPerConnection-com.datastax.driver.core.HostDistance-int-

Laxmikant
  • 1,551
  • 1
  • 13
  • 30
  • Yes, which is what I tried. Please look at the code and the exception I get, when I try to set it to anything above 128. Also the java driver only has a setMaxSimultaneousRequestsPerConnectionThreshold(HostDistance.LOCAL, 128). Not a setMaxRequestsPerConnection – GenerousJoker Oct 31 '17 at 13:50
  • please upgrade your driver version to 2.1.7. Ref: https://docs.datastax.com/en/developer/java-driver/2.1/upgrade_guide/ The following properties in PoolingOptions were renamed: MaxSimultaneousRequestsPerConnectionThreshold to NewConnectionThreshold MaxSimultaneousRequestsPerHostThreshold to MaxRequestsPerConnection The old getters/setters were deprecated, but they delegate to the new ones. Also, note that the connection pool for protocol v3 can now be configured to use multiple connections. See this page for more information. – Laxmikant Nov 01 '17 at 06:44