com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /127.0.0.1:9042 (com.datastax.driver.core.TransportException: [/127.0.0.1:9042] Cannot connect))
at com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:227) ~[cassandra-driver-core-2.1.7.1.jar:?]
at com.datastax.driver.core.ControlConnection.connect(ControlConnection.java:82) ~[cassandra-driver-core-2.1.7.1.jar:?]
at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:1307) ~[cassandra-driver-core-2.1.7.1.jar:?]
at com.datastax.driver.core.Cluster.init(Cluster.java:159) ~[cassandra-driver-core-2.1.7.1.jar:?]
at com.datastax.driver.core.Cluster.connect(Cluster.java:249) ~[cassandra-driver-core-2.1.7.1.jar:?]
at com.netflix.astyanax.cql.CqlKeyspaceImpl.setHosts(CqlKeyspaceImpl.java:404) [astyanax-cql-3.8.0.jar:3.8.0]
This results the caller to assume that the context is started and try to issue a cql statement resulting to a NPE that is really puzzling.
java.lang.NullPointerException: null
at com.netflix.astyanax.cql.direct.DirectCqlStatement.asPreparedStatement(DirectCqlStatement.java:80)
Moreover the ReconnectionPolicy is not applied because of this.
What are the options to solve this?
An easy one would be to add NPE checks and try to connect again
Another one would be to throw a RuntimeException (not elegant)
Hello,
More specifically in case that all hosts are unavailable in line: https://github.com/Netflix/astyanax/blob/master/astyanax-cql/src/main/java/com/netflix/astyanax/cql/CqlKeyspaceImpl.java#L404 will throw an exception that is not thrown back to the caller but just logged.
com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: /127.0.0.1:9042 (com.datastax.driver.core.TransportException: [/127.0.0.1:9042] Cannot connect)) at com.datastax.driver.core.ControlConnection.reconnectInternal(ControlConnection.java:227) ~[cassandra-driver-core-2.1.7.1.jar:?] at com.datastax.driver.core.ControlConnection.connect(ControlConnection.java:82) ~[cassandra-driver-core-2.1.7.1.jar:?] at com.datastax.driver.core.Cluster$Manager.init(Cluster.java:1307) ~[cassandra-driver-core-2.1.7.1.jar:?] at com.datastax.driver.core.Cluster.init(Cluster.java:159) ~[cassandra-driver-core-2.1.7.1.jar:?] at com.datastax.driver.core.Cluster.connect(Cluster.java:249) ~[cassandra-driver-core-2.1.7.1.jar:?] at com.netflix.astyanax.cql.CqlKeyspaceImpl.setHosts(CqlKeyspaceImpl.java:404) [astyanax-cql-3.8.0.jar:3.8.0]
This results the caller to assume that the context is started and try to issue a cql statement resulting to a NPE that is really puzzling.
java.lang.NullPointerException: null at com.netflix.astyanax.cql.direct.DirectCqlStatement.asPreparedStatement(DirectCqlStatement.java:80)
Moreover the ReconnectionPolicy is not applied because of this.
What are the options to solve this?
Or is there another way that that this could work?
Thank you in advance, Alex