1
Ich benutze Cassandra 2.0.9 und vor kurzem verschoben, um DataStax Java-Treiber Version 3.0.0 von 2.0.5. Ich habe folgenden Ausnahme tritt häufig nach dem Verschieben auf Treiber 3.0.0NoHostAvailableException tritt häufig in Datastax-Treiber 3.0 auf
com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: localhost/127.0.0.1:9042 (com.datastax.driver.core.exceptions.DriverException: Timeout while trying to acquire available connection (you may want to increase the driver number of per-host connections)))
at com.datastax.driver.core.exceptions.NoHostAvailableException.copy(NoHostAvailableException.java:84)
at com.datastax.driver.core.exceptions.NoHostAvailableException.copy(NoHostAvailableException.java:37)
at com.datastax.driver.core.DriverThrowables.propagateCause(DriverThrowables.java:37)
at com.datastax.driver.core.DefaultResultSetFuture.getUninterruptibly(DefaultResultSetFuture.java:245)
at com.datastax.driver.core.AbstractSession.execute(AbstractSession.java:63)
Gibt es ein Verbindungsproblem in Treiber 3.0.0. Mein Code zum Verbinden von Cassandra Cluster ist
private static Cluster constructCluster(String hostName,String port) {
String[] hostNames = hostName.split(",");
SocketOptions sOptions = new SocketOptions();
sOptions.setKeepAlive(true);
QueryOptions qOptions = new QueryOptions().setConsistencyLevel(ConsistencyLevel.LOCAL_QUORUM)
.setFetchSize(500);
LatencyAwarePolicy loadBalancingPolicy = LatencyAwarePolicy.builder(DCAwareRoundRobinPolicy.builder().withLocalDc(defaultDC).build())
.build();
Cluster cluster = Cluster.builder()
.addContactPoints(hostNames)
.withLoadBalancingPolicy(loadBalancingPolicy)
.withPoolingOptions(new PoolingOptions())
.withQueryOptions(qOptions)
.withReconnectionPolicy(new ConstantReconnectionPolicy(TimeUnit.SECONDS.toMillis(5)))
.withRetryPolicy(new LoggingRetryPolicy(DefaultRetryPolicy.INSTANCE))
.withSocketOptions(sOptions)
.build();
LOGGER.log(Level.SEVERE, "host name {0}", hostName);
return cluster;
}
Kann mir jemand helfen?
tatsächlich verwende ich nur einen Cluster und eine Session-Instanz für die Abfrage. Obwohl es für mich vorkommt. –