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

查看:69
本文介绍了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天全站免登陆