Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Health check for Cassandra connection (using hector)?

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

SELECT 1;

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.

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.

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

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

like image 806
HansMari Avatar asked Apr 20 '12 12:04

HansMari


Video Answer


2 Answers

With CQL3, I'm using the following query:

SELECT now() FROM system.local;

It would be nice to get rid of the FROM clause altogther to make this generic, in case the user does not have access to the system keyspace or local column family for some reason. But as with the other answers, at least this should not give false positives.

like image 122
Eemeli Kantola Avatar answered Nov 12 '22 02:11

Eemeli Kantola


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<String> 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.

like image 33
HansMari Avatar answered Nov 12 '22 03:11

HansMari