gpt4 book ai didi

Cassandra查询失败: All host(s) tried for query failed (no host was tried)

转载 作者:行者123 更新时间:2023-12-02 23:51:19 49 4
gpt4 key购买 nike

我无法对 Cassandra 节点进行查询。我能够连接到集群并进行连接。然而,在执行查询时,它失败了

Caused by: com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (no host was tried)
at com.datastax.driver.core.RequestHandler.reportNoMoreHosts(RequestHandler.java:217)
at com.datastax.driver.core.RequestHandler.access$1000(RequestHandler.java:44)
at com.datastax.driver.core.RequestHandler$SpeculativeExecution.sendRequest(RequestHandler.java:276)
at com.datastax.driver.core.RequestHandler.startNewExecution(RequestHandler.java:117)
at com.datastax.driver.core.RequestHandler.sendRequest(RequestHandler.java:93)
at com.datastax.driver.core.SessionManager.executeAsync(SessionManager.java:127)
... 3 more

这就是我连接到集群的方式:

    List<String> servers = config.getCassandraServers();
Builder builder = Cluster.builder();
for (String server : servers) {
builder.addContactPoints(server);
}

PoolingOptions opts = new PoolingOptions();
opts.setCoreConnectionsPerHost(HostDistance.LOCAL, opts.getCoreConnectionsPerHost(HostDistance.LOCAL));

// setup socket exceptions
SocketOptions socketOpts = new SocketOptions();
socketOpts.setReceiveBufferSize(1048576);
socketOpts.setSendBufferSize(1048576);
socketOpts.setTcpNoDelay(false);

cluster = builder.withSocketOptions(socketOpts)
.withRetryPolicy(DowngradingConsistencyRetryPolicy.INSTANCE)
.withPoolingOptions(opts)
.withReconnectionPolicy(new ConstantReconnectionPolicy(100L))
.withLoadBalancingPolicy(new DCAwareRoundRobinPolicy(getColo(config)))
.build();

cluster.connect();

我正在使用最新稳定版本的 Cassandra 2.2.3 和 Datastax 驱动程序:

<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>2.1.8</version>
</dependency>

非常感谢任何指点

谢谢马斯蒂

最佳答案

这是解决方案:问题在于

.withLoadBalancingPolicy(new DCAwareRoundRobinPolicy(getColo(config)))

这里,我在 AWS 云中只有一个节点来测试我的适配器,它导致 Cassandra 无法运行。删除即可解决问题

谢谢

关于Cassandra查询失败: All host(s) tried for query failed (no host was tried),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33662481/

49 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com