如何为Cassandra设置读取请求超时

问题描述 投票:0回答:1

我尝试使用不同的读取请求超时为cassandra创建新的端点。具有大数据请求的超时很大的端点会响应。我使用com.datastax.cassandra驱动程序和带read_request_timeout参数的cassandra-default.yaml找到了Scala代码。如何在“集群”构建器或代码中的其他位置设置read_request_timeout?

Cluster
      .builder
      .addContactPoints(cassandraHost.split(","): _*)
      .withPort(cassandraPort)
      .withRetryPolicy(DefaultRetryPolicy.INSTANCE)
      .withLoadBalancingPolicy(
        new TokenAwarePolicy(DCAwareRoundRobinPolicy.builder().build())).build



# How long the coordinator should wait for read operations to complete
read_request_timeout_in_ms: 5000
java cassandra datastax
1个回答
0
投票

使用:在查询级别设置

session.execute(
        new SimpleStatement("CQL HERE").setReadTimeoutMillis(65000));

如果要在集群构建时设置,请使用:

Cluster cluster = Cluster.builder()
        .addContactPoint("127.0.0.1")
        .withSocketOptions(
                new SocketOptions()
                        .setConnectTimeoutMillis(2000))
        .build();

Socket Options

© www.soinside.com 2019 - 2024. All rights reserved.