cassandra - HConnectionManager (Hector) connection state -


i'm connecting cassandra db via hector.

when given wrong socket (in purpose) connection fails message:

info cassandrahostretryservice - downed host retry service started queue size -1 , retry delay 10s error hconnectionmanager - not start connection pool host 132.202.35.14(160.202.35.14):9160 info cassandrahostretryservice - host detected down added retry queue: 132.202.35.14(160.202.35.14):9160 info jmxmonitor - registering jmx me.prettyprint.cassandra.service_rtbcluster:servicetype=hector,monitortype=hector 

and keeps on trying java.net.connectexception: connection timed out: connect every few seconds. know if connection had failed or succeeded since once succeeds take actions.

my code looks this:

cassandrahostconfigurator cassandrahostconfigurator = new cassandrahostconfigurator(this.socket); cluster = new thriftcluster(this.clustername, cassandrahostconfigurator); configurableconsistencylevel consistencylevelpolicy = new configurableconsistencylevel(); consistencylevelpolicy.setdefaultreadconsistencylevel(getconsistencylevelpolicy()); keyspace = hfactory.createkeyspace(keyspacename, cluster, consistencylevelpolicy); fireconnectionevent(true); 

as can see i'm firing connection event, i'm getting there anyways - whether connection succeeded or fails , have no way distinguish between two. there event can catch or other way can informed of connection state?

i'm not sure it's optimal way, since not find better answer did:

created 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 socket " + this.socket + ". connection cassandra down!!!");     } 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -