Cassandra查询失败:所有主机尝试查询失败(未尝试主机)

时间:2015-11-12 00:33:59

标签: cassandra cassandra-2.0 datastax datastax-java-driver

我无法对Cassandra Node进行查询。我能够连接到群集并连接。但是在执行查询时,它失败了

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>

任何指针都非常受欢迎

由于 Masti

1 个答案:

答案 0 :(得分:3)

这是解决方案:问题是

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

在这里,我只在AWS云中有一个节点来测试我的适配器,它正在抛弃Cassandra。删除它解决了问题

由于