我正在使用 datastax cassandra 2.1 驱动程序并以约 8000 IOPS 的速率执行读/写操作。我使用池选项来配置我的会话,并使用单独的会话进行读取和写入,每个会话都连接到集群中的不同节点作为联系点。这可以正常工作 5 分钟,但之后我得到了很多异常,例如:
失败:com.datastax.driver.core.exceptions.NoHostAvailableException:所有主机尝试查询失败(尝试:/10.0.1.123:9042(com.datastax.driver.core.TransportException:[/10.0.1.123: 9042] 连接已关闭),/10.0.1.56:9042(com.datastax.driver.core.exceptions.DriverException:尝试获取可用连接时超时(您可能希望增加每个主机连接的驱动程序数量)) )
任何人都可以在这里帮助我解决可能的问题吗?
异常要求我增加每台主机的连接数,但我可以为这个参数设置多高的值?此外,我无法设置CoreConnectionsPerHost
超过 2,因为它会抛出异常,说 2 是最大值。
这就是我创建每个读/写会话的方式。
PoolingOptions poolingOpts = new PoolingOptions();
poolingOpts.setCoreConnectionsPerHost(HostDistance.REMOTE, 2);
poolingOpts.setMaxConnectionsPerHost(HostDistance.REMOTE, 200);
poolingOpts.setMaxSimultaneousRequestsPerConnectionThreshold(HostDistance.REMOTE, 128);
poolingOpts.setMinSimultaneousRequestsPerConnectionThreshold(HostDistance.REMOTE, 2);
cluster = Cluster
.builder()
.withPoolingOptions( poolingOpts )
.addContactPoint(ip)
.withRetryPolicy( DowngradingConsistencyRetryPolicy.INSTANCE )
.withReconnectionPolicy( new ConstantReconnectionPolicy( 100L ) ).build();
Session s = cluster.connect(keySpace);