If you execute a query with CL = ONE, the driver tries to query only one node. Thus, if the request to this node fails (or the node is unavailable), an exception is immediately raised. This behavior is controlled by com.datastax.driver.core.policies.RetryPolicy specified when creating Cluster .
I would say that RetryPolicy , which captures the number of retry attempts, will fit your needs. Unfortunately, Cassandra Driver 1.0.3 is not bundled (I'm not sure about future versions). However, this can be implemented as follows:
public class MyRetryPolicy implements RetryPolicy { final int attempts; public MyRetryPolicy(int attempts) { this.attempts = attempts; } @Override public RetryDecision onReadTimeout(Query query, ConsistencyLevel cl, int requiredResponses, int receivedResponses, boolean dataRetrieved, int nbRetry) { return (nbRetry >= attempts) ? RetryDecision.rethrow() : RetryDecision.retry(cl) } ... <onWriteTimeout & onUnavailable methods with similar implementation> }
I'm not sure if MyRetryPolicy(2) be sufficient, since I do not delve into the inside of the driver. Perhaps another attempt will be made to send the same request to the same host. You can try MyRetryPolicy(10) , this should at least significantly reduce the number of crashes.
If some failures still remain (for example, 1 out of 1000), it might be worth looking at com.datastax.driver.core.ConvictionPolicy , finding its use and continuing your research.
source share