You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by Kevin Burton <bu...@spinn3r.com> on 2015/07/12 19:07:31 UTC

Configuring the java client to retry on write failure.

I can’t seem to find a decent resource to really explain this…

Our app seems to fail some write requests, a VERY low percentage.  I’d like
to retry the write requests that fail due to number of replicas not being
correct.

http://docs.datastax.com/en/developer/java-driver/2.0/common/drivers/reference/tuningPolicies_c.html

This is the best resource I can find.

I think the best strategy is to look at DefaultRetryPolicy and then create
a custom one that keeps retrying on write failures up to say 1 minute.
Latency isn’t critical for us as this is a batch processing system.

The biggest issue is how to test it?  I could unit test that my methods
return on the correct inputs but not really in real world situations.

What’s the best way to unit test this?

-- 

Founder/CEO Spinn3r.com
Location: *San Francisco, CA*
blog: http://burtonator.wordpress.com
… or check out my Google+ profile
<https://plus.google.com/102718274791889610666/posts>

Re: Configuring the java client to retry on write failure.

Posted by Mikhail Strebkov <st...@gmail.com>.
Hi Kevin,

Here is what we use, works for us in production:
https://gist.github.com/kluyg/46ae3dee9000a358edf9

To unit test it, you'll need to check that your custom retry policy returns
the RetryDecision you want for the inputs.

To verify that it works in production, you can wrap it in a
LoggingRetryPolicy like this:

  .withRetryPolicy(new LoggingRetryPolicy(new MyRetryPolicy(maxRetries =
3)))

and you'll see the retries in the logs.

Kind regards,
Mikhail

On Sun, Jul 12, 2015 at 10:07 AM, Kevin Burton <bu...@spinn3r.com> wrote:

> I can’t seem to find a decent resource to really explain this…
>
> Our app seems to fail some write requests, a VERY low percentage.  I’d
> like to retry the write requests that fail due to number of replicas not
> being correct.
>
>
> http://docs.datastax.com/en/developer/java-driver/2.0/common/drivers/reference/tuningPolicies_c.html
>
> This is the best resource I can find.
>
> I think the best strategy is to look at DefaultRetryPolicy and then create
> a custom one that keeps retrying on write failures up to say 1 minute.
> Latency isn’t critical for us as this is a batch processing system.
>
> The biggest issue is how to test it?  I could unit test that my methods
> return on the correct inputs but not really in real world situations.
>
> What’s the best way to unit test this?
>
> --
>
> Founder/CEO Spinn3r.com
> Location: *San Francisco, CA*
> blog: http://burtonator.wordpress.com
> … or check out my Google+ profile
> <https://plus.google.com/102718274791889610666/posts>
>
>