Cassandra在分页查询期间读取TimeOut

时间:2016-02-08 12:40:27

标签: java cassandra-2.0 datastax

我有2个cassandra节点,replica_factor = 2。我正在尝试从我的代码中运行 select()。all(),并使用 setFetchSize(50000)。当我在一段时间后开始迭代结果时,它会在一致性ONE的读取查询期间抛出readTimeOutException Cassandra超时(需要1个响应,但只有0个副本响应)。有人可以给我一些建议吗?

我正在使用以下代码创建群集

PoolingOptions poolingOptions = new PoolingOptions();
        poolingOptions.setCoreConnectionsPerHost(HostDistance.LOCAL, 52)
        .setMaxConnectionsPerHost(HostDistance.LOCAL, 80)
        .setMaxRequestsPerConnection(HostDistance.LOCAL, 500);

    SocketOptions socketOption = new SocketOptions();
    socketOption.setReadTimeoutMillis(600000)
    .setReceiveBufferSize(1024*512)
    .setSendBufferSize(1024*512)
    .setKeepAlive(true).setConnectTimeoutMillis(1800000);

    cluster = Cluster.builder()
            .addContactPoints(cassandraHosts.get("HOST_1"), cassandraHosts.get("HOST_2"))
            .withPoolingOptions(poolingOptions)
            .withPort(cassandraPort)
            .withSocketOptions(socketOption)
            .withLoadBalancingPolicy(new TokenAwarePolicy(new DCAwareRoundRobinPolicy())).build();
    Session session = cluster.connect(cassandraDB);
  • Cassandra版本:2.2.1
  • Java 7
  • 是否有其他方法可以执行select all all query而无需读取超时异常

0 个答案:

没有答案