Vadim
Vadim

Reputation: 825

How to set read request timeout for cassandra

I try to create new endpoints for cassandra with different read request timeout. The endpoint with big timeout for requests with big data responds. I found Scala code with com.datastax.cassandra driver and cassandra-default.yaml with read_request_timeout parameter. How to set read_request_timeout in Cluster builder or in other places in code ?

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

Upvotes: 0

Views: 5843

Answers (1)

undefined_variable
undefined_variable

Reputation: 6228

Set at query level using :

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

If you want to set while cluster bulding use :

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

Socket Options

Upvotes: 2

Related Questions