阅读超过数百万的cassandra记录

时间:2016-09-16 14:19:08

标签: spring-boot cassandra spring-data

我正在使用Cassandra存储我的应用程序发生的所有事件.6个月后它有超过数百万的数据。

我在阅读cassandra

中的所有记录时遇到以下错误

CLI -

cqlsh> use abc;
cqlsh:abc> select count(*) from interaction;
OperationTimedOut: errors={}, last_host=localhost

从春季数据(使用允许过滤)

Caused by: com.datastax.driver.core.exceptions.ReadTimeoutException: Cassandra timeout during read query at consistency ONE (1 responses were required but only 0 replica responded)
    at com.datastax.driver.core.exceptions.ReadTimeoutException.copy(ReadTimeoutException.java:69)
    at com.datastax.driver.core.DefaultResultSetFuture.extractCauseFromExecutionException(DefaultResultSetFuture.java:256)
    at com.datastax.driver.core.DefaultResultSetFuture.getUninterruptibly(DefaultResultSetFuture.java:172)
    at com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:52)
    at com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:36)
    at com.germinait.replica.CassandraTransfer.startTransfer(CassandraTransfer.java:43)
    at com.germinait.replica.DemoApplication.run(DemoApplication.java:22)
    at org.springframework.boot.SpringApplication.runCommandLineRunners(SpringApplication.java:673)
    ... 5 more
Caused by: com.datastax.driver.core.exceptions.ReadTimeoutException: Cassandra timeout during read query at consistency ONE (1 responses were required but only 0 replica responded)
    at com.datastax.driver.core.exceptions.ReadTimeoutException.copy(ReadTimeoutException.java:69)
    at com.datastax.driver.core.Responses$Error.asException(Responses.java:94)
    at com.datastax.driver.core.DefaultResultSetFuture.onSet(DefaultResultSetFuture.java:108)
    at com.datastax.driver.core.RequestHandler.setFinalResult(RequestHandler.java:235)
    at com.datastax.driver.core.RequestHandler.onSet(RequestHandler.java:379)
    at com.datastax.driver.core.Connection$Dispatcher.messageReceived(Connection.java:584)
    at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
    at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)
    at org.jboss.netty.handler.codec.oneone.OneToOneDecoder.handleUpstream(OneToOneDecoder.java:70)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
    at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791)
    at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)
    at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:462)
    at org.jboss.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:443)
    at org.jboss.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:303)
    at org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564)
    at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:

我不确定如何阅读大量数据。

让我知道如何使用spring-data或其他替代方法来读取这些大数据。

2 个答案:

答案 0 :(得分:1)

  1. 更改并查看驱动程序读取超时
  2. https://datastax.github.io/java-driver/manual/socket_options/

    Cluster cluster = Cluster.builder()
        .addContactPoint("127.0.0.1")
        .withSocketOptions(
                new SocketOptions()
                        .setConnectTimeoutMillis(2000))
        .build();
    
    1. 更改Cassandra服务器配置以允许大量读写
    2.   

      read_request_timeout_in_ms,range_request_timeout_in_ms,   write_request_timeout_in_ms,cas_contention_timeout_in_ms,   truncate_request_timeout_in_ms

      另外,请查看此答案以获取更多信息。

      Cassandra read timeout

答案 1 :(得分:0)

如果你想知道一个表包含多少行, 你可以有一个计数器表,它在插入记录时递增,在删除行时递减。