这是我的设置:
> 4个节点Cassandra 1.2.19
> Astyanax 1.56.49
我正在设置配置
AstyanaxContext<Keyspace> context = new AstyanaxContext.Builder()
.forCluster(service.getClusterName())
.forKeyspace(service.getKeySpaceName())
.withAstyanaxConfiguration(new AstyanaxConfigurationImpl()
.setDiscoveryType(NodeDiscoveryType.NONE)
.setCqlVersion("3.0.0")
.setDefaultReadConsistencyLevel(consistencyLevel.getAstyanaxValue())
.setDefaultWriteConsistencyLevel(consistencyLevel.getAstyanaxValue())
)
.withConnectionPoolConfiguration(new ConnectionPoolConfigurationImpl("b2bConnectionPool")
.setPort(service.getPort())
.setMaxConnsPerHost(5)
.setSeeds(StringUtils.join(hosts, ","))
// increase default timeout for heavy operations (milliseconds)
.setSocketTimeout(15000)
.setSSLConnectionContext(sslContext)
.setAuthenticationCredentials(credentials)
)
.withConnectionPoolMonitor(new CountingConnectionPoolMonitor())
.buildKeyspace(ThriftFamilyFactory.getInstance());
现在有一个可重现的查询,需要很长时间,最后抛出一个OperationTimeoutException:
com.netflix.astyanax.connectionpool.exceptions.OperationTimeoutException: OperationTimeoutException: [host=myhost(myip):13260, latency=10001(40007), attempts=4]TimedOutException()
at com.netflix.astyanax.thrift.ThriftConverter.ToConnectionPoolException(ThriftConverter.java:171) ~[astyanax-thrift-1.56.49.jar:na]
at com.netflix.astyanax.thrift.AbstractOperationImpl.execute(AbstractOperationImpl.java:65) ~[astyanax-thrift-1.56.49.jar:na]
at com.netflix.astyanax.thrift.ThriftColumnFamilyQueryImpl$1$2.execute(ThriftColumnFamilyQueryImpl.java:190) ~[astyanax-thrift-1.56.49.jar:na]
at com.netflix.astyanax.thrift.ThriftColumnFamilyQueryImpl$1$2.execute(ThriftColumnFamilyQueryImpl.java:182) ~[astyanax-thrift-1.56.49.jar:na]
at com.netflix.astyanax.thrift.ThriftSyncConnectionFactoryImpl$ThriftConnection.execute(ThriftSyncConnectionFactoryImpl.java:151) ~[astyanax-thrift-1.56.49.jar:na]
at com.netflix.astyanax.connectionpool.impl.AbstractExecuteWithFailoverImpl.tryOperation(AbstractExecuteWithFailoverImpl.java:119) ~[astyanax-core-1.56.49.jar:na]
at com.netflix.astyanax.connectionpool.impl.AbstractHostPartitionConnectionPool.executeWithFailover(AbstractHostPartitionConnectionPool.java:338) ~[astyanax-core-1.56.49.jar:na]
at com.netflix.astyanax.thrift.ThriftColumnFamilyQueryImpl$1.execute(ThriftColumnFamilyQueryImpl.java:180) ~[astyanax-thrift-1.56.49.jar:na]
异常消息显示“latency = 10001”,我认为这应该是配置为15000 ms的套接字超时,但显然不是.如何在astyanax中增加查询操作的超时?
最佳答案 在尝试查询具有更大数据的节点时,我得到了类似的超时异常.我在cassandra.yaml中修改了这4个值,它解决了所有超时错误.
协调器应等待读取操作完成的时间
read_request_timeout_in_ms:15000
协调器应等待seq或索引扫描完成的时间
range_request_timeout_in_ms:30000
协调器应等待写入完成的时间
write_request_timeout_in_ms:30000
协调器应等待计数器写入完成的时间
counter_write_request_timeout_in_ms:15000
注意:您需要在群集中的所有节点中执行此操作,并且还需要在所有节点中重新启动Cassandra.