Cassandra 连接的健康检查(使用 hector)? [英] Health check for Cassandra connection (using hector)?

查看:38
本文介绍了Cassandra 连接的健康检查(使用 hector)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我的应用程序的操作监控,我正在寻找类似于常用的SQL 连接验证"查询的内容

For operations monitoring of my application, I am looking for something similar to the commonly used "SQL connection validation" query

选择 1;

在 Cassandra 中,使用 Hector 驱动程序.我尝试过查看 Cluster.getKnownPoolHosts() 和 .getConnectionManager().getActivePools() 之类的方法.但似乎他们的状态并没有持续更新,只有当我真正尝试通过查询访问 Cassandra 时才如此.

in Cassandra, using the Hector driver. I have tried things like looking at Cluster.getKnownPoolHosts() and .getConnectionManager().getActivePools(). But it seems that their status is not continuously updated, only when I actually try to access Cassandra with a query.

我希望我的健康检查独立于任何需要存在的键空间或用户 CF,所以仅仅运行一个虚拟"查询似乎很困难(反对什么?).当然,它不应占用大量内存或产生任何显着负载.

I'd like my health check to be independent of any keyspaces or user CFs that need to exist, so just running a "dummy" query seems difficult (against what?). And of course it shouldn't take a lot of memory or generate any significant load.

我可以在不运行真正查询的情况下以某种方式强制 Hector 更新其连接池状态吗?

Can I force Hector somehow to update its connection pool status without running a real query?

(顺便说一句:CQL 甚至不接受SELECT 1"作为有效查询.)

(BTW: CQL doesn't even accept "SELECT 1" as a valid query.)

推荐答案

我目前使用的解决方案似乎是迄今为止最健壮的解决方案(使用 Cassandra 1.1 和 1.2 测试)是对系统"的简单查询":

The solution I'm currently using, and which seems to be the most robust so far (tested with Cassandra 1.1 and 1.2) is a simple query on "system":

查询<字符串>query = Query.selectQuery("*", "system", null, 1,consistencyLevel, StringSerializer.get());

这不是我想要的,因为它是一个真实"的查询,但另一方面,它不会给出任何误报.

It's not exactly what I wanted since it's a "real" query, but on the other hand it doesn't give any false positives.

这篇关于Cassandra 连接的健康检查(使用 hector)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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