一段时间后无法连接Cassandra [无法连接到任何主机,计划在10000毫秒内重试]

时间:2019-05-16 08:01:06

标签: java cassandra cassandra-3.0

我正在使用在AWS上具有三个实例的Cassandra集群。超过100个微服务同时访问Cassandra,每个微服务都有其自己的密钥空间和连接。经过一段时间后,这些服务都无法访问Cassandra并引发异常

Do we need to enable Pooling option for Cassandra connectivity?

Is there any issue option to get rid off this issue while creating a Cluster in java code.

What is the maximum number of connection can be used?

重新启动所有微服务后,它开始正常运行。但是一段时间后它开始发生。  -我们检查了堆使用情况,GC似乎正常。  -nodetool状态显示所有三个节点均为联合国,没有问题。  -我们尝试通过控制台(./cqlsh)连接Cassandra,该控制台在重新启动服务之前也无法正常工作。

Cassandra版本-apache-cassandra-3.11.2

We are using below jars for Cassandra drive for connection.

-cassandra-driver-core-3.6.0.jar</br>
-cassandra-driver-extras-3.6.0.jar</br>
-cassandra-driver-mapping-3.6.0.jar</br>

if (cluster == null || cluster.isClosed()) {                    
    Builder builder = Cluster.builder()
    .addContactPointsWithPorts(inetSocketAddress)
    .withClusterName(clusterName)
    .withReconnectionPolicy(new ConstantReconnectionPolicy(10000L));                    
    cluster = builder.build();
    cluster.getConfiguration().getSocketOptions()
    .setReadTimeoutMillis(readTimeoutMillis);
    cluster.getConfiguration().getSocketOptions()
    .setConnectTimeoutMillis(connectionTimeoutMillis);

}

c.d.d.c.ControlConnection Test Cluster-reconnection-1 [ERROR] [Control connection] Cannot connect to any host, scheduling retry in 10000 milliseconds
c.d.d.c.ControlConnection Test Cluster-reconnection-0 [ERROR] [Control connection] Cannot connect to any host, scheduling retry in 10000 milliseconds

2019-05-14 20:53:27.877 c.d.d.c.ControlConnection Test Cluster-worker-63522 [ERROR] [Control connection] Unexpected error while refreshing schema
java.util.concurrent.ExecutionException: com.datastax.driver.core.exceptions.OperationTimedOutException: [/localhost:9042] Operation timed out
    at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:476) ~[guava-19.0.jar:?]
    at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:455) ~[guava-19.0.jar:?]
    at com.datastax.driver.core.SchemaParser.get(SchemaParser.java:672) ~[cassandra-driver-core-3.6.0.jar:?]
    at com.datastax.driver.core.SchemaParser.access$500(SchemaParser.java:41) ~[cassandra-driver-core-3.6.0.jar:?]
    at com.datastax.driver.core.SchemaParser$V3SchemaParser.fetchSystemRows(SchemaParser.java:925) ~[cassandra-driver-core-3.6.0.jar:?]
    at com.datastax.driver.core.SchemaParser.refresh(SchemaParser.java:87) ~[cassandra-driver-core-3.6.0.jar:?]
    at com.datastax.driver.core.ControlConnection.refreshSchema(ControlConnection.java:408) ~[cassandra-driver-core-3.6.0.jar:?]
    at com.datastax.driver.core.ControlConnection.refreshSchema(ControlConnection.java:354) [cassandra-driver-core-3.6.0.jar:?]
    at com.datastax.driver.core.Cluster$Manager$SchemaRefreshRequestDeliveryCallback$1.runMayThrow(Cluster.java:2867) [cassandra-driver-core-3.6.0.jar:?]
    at com.datastax.driver.core.ExceptionCatchingRunnable.run(ExceptionCatchingRunnable.java:32) [cassandra-driver-core-3.6.0.jar:?]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_202]
    at com.google.common.util.concurrent.TrustedListenableFutureTask$TrustedFutureInterruptibleTask.runInterruptibly(TrustedListenableFutureTask.java:108) [guava-19.0.jar:?]
    at com.google.common.util.concurrent.InterruptibleTask.run(InterruptibleTask.java:41) [guava-19.0.jar:?]
    at com.google.common.util.concurrent.TrustedListenableFutureTask.run(TrustedListenableFutureTask.java:77) [guava-19.0.jar:?]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_202]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_202]
    at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:138) [netty-all-4.0.53.Final.jar:4.0.53.Final]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_202]
Caused by: com.datastax.driver.core.exceptions.OperationTimedOutException: [/localhost:9042] Operation timed out
    at com.datastax.driver.core.DefaultResultSetFuture.onTimeout(DefaultResultSetFuture.java:257) ~[cassandra-driver-core-3.6.0.jar:?]
    at com.datastax.driver.core.Connection$ResponseHandler$1.run(Connection.java:1575) ~[cassandra-driver-core-3.6.0.jar:?]
    at io.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:663) ~[netty-all-4.0.53.Final.jar:4.0.53.Final]
    at io.netty.util.HashedWheelTimer$HashedWheelBucket.expireTimeouts(HashedWheelTimer.java:738) ~[netty-all-4.0.53.Final.jar:4.0.53.Final]
    at io.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:466) ~[netty-all-4.0.53.Final.jar:4.0.53.Final]
    ... 2 more

0 个答案:

没有答案