Cassandra Query Failures: All host(s) tried for query failed (no host was tried)

自闭症网瘾萝莉.ら 提交于 2019-12-05 02:03:49

问题


I am not able to do queries against the Cassandra Node. I am able to make the connection to the cluster and connect. However while doing the the query, it fails

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

This is how I am connecting to the cluster:

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

I am using latest stable version of Cassandra 2.2.3 with the Datastax driver:

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

Any pointers are highly appreciated

Thanks Masti


回答1:


Here is the solve: Issue was with

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

Here I only have a single node in AWS cloud to test my adapter and it was throwing Cassandra off. Removing that solves the issue

Thanks



来源:https://stackoverflow.com/questions/33662481/cassandra-query-failures-all-hosts-tried-for-query-failed-no-host-was-tried

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!