I'm not sure it's the optimal way, but since I could not find a better answer this is what I did:
Created this method:
private boolean isConnected() {
List<KeyspaceDefinition> keyspaces = null;
try {
keyspaces = cluster.describeKeyspaces();
} catch (HectorException e) {
return false;
}
return (!CollectionUtils.isEmpty(keyspaces));
}
and then:
if (isConnected())
fireConnectionEvent(true);
else {
LOG.error("Could not connect to socket " + this.socket + ". Connection to Cassandra is down!!!");
}