Cassandra Java驱动程序协议版本和连接限制不匹配

编程入门 行业动态 更新时间:2024-10-25 14:31:19
本文介绍了Cassandra Java驱动程序协议版本和连接限制不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用Java驱动程序版本:2.1.4 Cassandra版本:dsc-cassandra-2.1.10 cql的输出给出以下内容

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

我是协议V3。但是,当我尝试将其设置为每个连接超过128个请求时,它将引发异常。这似乎是V2中的限制。解释如下:

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:

以下代码块:

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));

输出为:

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)

根据Cassandra文档 > docs.datastax/en/developer/java-driver/2.1/manual/native_protocol/ 和 > docs.datastax/en/developer/java-driver/2.1 / manual / pooling /

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

我是协议V3。但是为什么我每个连接限制为128个请求。这似乎是V2中的限制。有人可以解释一下如何找到我的实际版本,如果确实是V3,为什么我不能同时建立128个以上的并行连接?

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?

推荐答案

对于ProtocolVersion#V3或更高版本,每个连接最多有32768个请求,并且该池默认为固定大小1。通常,通过允许每个连接同时发出更多请求来提高最大容量( setMaxRequestsPerConnection (HostDistance,int))

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))

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

更多推荐

Cassandra Java驱动程序协议版本和连接限制不匹配

本文发布于:2023-10-18 23:57:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1505804.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:驱动程序   不匹配   协议   版本   Cassandra

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!