Datastax Cassandra 驱动程序重试策略延迟? [英] Datastax Cassandra Driver Retry Policy Delay?

查看:33
本文介绍了Datastax Cassandra 驱动程序重试策略延迟?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Datastax Cassandra 驱动程序并设置了 RetryPolicy 以在主机不可用时重试.但是,我注意到它会尽可能快地重试.我想改变它以增加重试之间的延迟,而不是在集群陷入困境时敲打它.这对于 OVERLOADED 请求错误尤其重要,因为我确实想在这些情况下重试,但会延迟很大.

I am using the Datastax Cassandra driver and have a RetryPolicy setup to retry when a host is unavailable. However, I have noticed that it retries as fast as it can. I would like to change it to have an increasing delay between retries rather than hammer the cluster if it is struggling. This is particularly important for OVERLOADED request errors since I do want to retry in these scenarios, but with a substantial delay.

延迟的正确位置在哪里?正确的机制是什么?我应该在我的 RetryPolicy 中抛出一个 Thread.sleep(...) 吗?

Where is the right place to put a delay and what is the right mechanism? Should I just throw a Thread.sleep(...) in my RetryPolicy?

我不介意占用一个在线请求(针对最大数量的正在进行的请求),但如果我们还没有在进行中的请求,我不同意完全阻止其他写入限制.

I don't mind taking up a request on-the-wire slot (towards the maximum number of in-flight requests) but I am not okay with completely blocking other writes if we are not yet at the in-flight request limit.

推荐答案

您可以通过添加延迟来实现自己的重试策略.最简单的方法是选择默认重试的源代码并自行修改,以实现重试的指数延迟或类似的东西.

You can implement your own retry policy by adding a delay. The simplest way is to pick the source code of the default retry and modify it yourself to implement an exponential delay for retry or something similar.

指数延迟看http://docs.datastax.com/en/drivers/java/3.0/com/datastax/driver/core/policies/ExponentialReconnectionPolicy.html 看看它是如何工作的

For exponential delay, just look at the source code of http://docs.datastax.com/en/drivers/java/3.0/com/datastax/driver/core/policies/ExponentialReconnectionPolicy.html to see how it works

这篇关于Datastax Cassandra 驱动程序重试策略延迟?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆