Does Datastax Cassandra Java Driver provides fallback mechanism for cassandra Connection to next available host?
For example, if cluster has 4 Host nodes and client application is connected to Host-1.Now, When Host-1 is down, is it possible to provide a mechanism that application try to connect to Host-2 and then Host-3 ... & so on !!!
Additionally,
1) Datastax driver provides the facility to write custom Retry policy RetryPolicy(MyCustomRetryPolicy.RETRY_POLIOCY_INSTANCE);
but this invokes in case of error (ReadTimeout, writeTimeout, RequestError etc) but at the point, when one node leaves, this doesn't get invoke.
2) Another way, is to add SpeculativeExecutionPolicy withSpeculativeExecutionPolicy(new ConstantSpeculativeExecutionPolicy(10000,2))
but I am not sure if this solves the problem?
Is there any other proper mechanism provided by Java Driver of cassandra or SpeculativeExecutionPolicy is the only option?
0
votes
1 Answers
0
votes
Cassandra Java Driver uses first node only to discover the other nodes in the cluster. Then it uses configured policy to connect to nodes - by default it's token-aware/datacenter-aware policy. First part means that drivers "knows" which node is responsible for handling data with given partition key, and 2nd part is aware where the nodes are located. You can of course to customize your policy, but default settings should be ok. More information is in the official docs.
If in your case fallback doesn't happen, then please share more details.