Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

HDC avatar image
HDC asked ·

cassandra驱动是否有类似SocketOptions.DEFAULT_READ_TIMEOUT_MILLIS的写超时的参数?

我们在初始化连接的时候,没有retry策略,在初始化和cassandra集群的连接时,设置socketOption如下:

SocketOptions socketOptions = new SocketOptions();
socketOptions.setKeepAlive(configuration.isKeepAlive());
socketOptions.setConnectTimeoutMillis(configuration.getConnectTimeoutMillis());
socketOptions.setReadTimeoutMillis(configuration.getReadTimeoutMillis());

ReadTimeoutMillis这个设置是有效的。我们测试的过程是

1、建立和cassandra集群的连接

2、中断cassandra驱动所在的客户端和集群的网络,发生读取的请求

3、在ReadTimeoutMillis设置的超时时间左右会有超时的异常。

但是我没有找到类似 WriteTimeoutMillis的参数,当我们在中断网络之后,发生写入请求,这个超时时间有变化,一般在20s~30s之间。

我想知道有没有类似ReadTimeoutMillis的 WriteTimeoutMillis参数,可以再socketOption里面设置?

java driver
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered ·

是的,它确实。 较旧的Java driver版本使用DEFAULT_CONNECT_TIMEOUT_MILLIS进行写入请求。

Yes, it does. The older versions of the Java driver use DEFAULT_CONNECT_TIMEOUT_MILLIS for write requests. Cheers!

2 comments Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

我现在使用的cassandra驱动是 cassandra-driver-core-3.6.0-shaded.jar。

请问DEFAULT_CONNECT_TIMEOUT_MILLIS 是否也是作为这个版本的写入操作的超时呢?

0 Likes 0 ·

是的,它确实。请参阅Java driver 3.6 SocketOptions API文档。

Yes, it does. See the Java driver 3.6 SocketOptions API doc. Cheers!

1 Like 1 ·