Reputation: 7432
I have some data that must be written to Cassandra. Initially I thought this would be simple by just setting up a RetryPolicy for ReadTimeout, WriteTimeout, Unavailable and RequestError. However, the only two retry decisions that I see are tryNextHost
and retry
.
retry
appears to try forever, but it tries the same host over and over again. Even if the node cleanly leaves the cluster and announces its departure (handing off ownership of its range to another node), this retry policy appears to continue to try to send to the same host.
tryNextHost
solves that problem, but it appears to only try each host once and then gives up (lets the exception bubble up).
I need a retry policy that rotates through hosts (or at least moves hosts when one cleanly leaves the cluster) but I can set to retry forever. I investigated writing my own RetryDecision but there is no public constructor and even if I got around that, I don't see a way to get around this since its constructor is pretty limited.
How can I retry forever AND rotate hosts?
Upvotes: 0
Views: 549
Reputation: 2312
RetryPolicy
alone will not allow you to do that. The other component involved is LoadBalancingPolicy, which determines which hosts will be tried (in other words, it generates the sequence over which repeated tryNextHost
calls would iterate).
So I guess you could write a custom load balancing policy that returns infinite iterators. But frankly that's quite unusual and you should consider the implications of requests potentially looping forever.
Upvotes: 2