Migration of Cassandra client Hector to java driver - replacement for ConnectionListener

122 Views Asked by At

Currently we are migrating Cassandra client from Hector to Java driver but unable to find replacement for ConnectionListener as this is used to avoid repeated client requests to the same DC which is already down for some reason.

Code :

         if(getClusterConnectionListenerForDCId(dcId).isAllHostsInThisDCClusterDown())
             {
            /* directly return failure w/o even trying: this is vital, because if we keep trying to write to a all-downed cluster again and again,and since hector is stupid enough not to skip writing to cluster given that it already knew the cluster is all down, every single remote local-quorum call will need to wait until timeout (10 second) again and again, when cross-DC channel has hiccup.
*/
                            return false;
                }

        //overridden function of ConnectionManagerListener

        @Override
            public void onAllHostsDown() {
                //when all hosts are down for a particular cluster, we want to disable writing to that particular cluser
                //until at least one host of the cluster recovers
                mIsAllHostsInThisDCClusterDown = true;
                smIsAnyDCClusterAllHostsDown = true;
                logger.warn("all hosts are down for DC: " + mDcId);
            } 
1

There are 1 best solutions below

0
doanduyhai On

but unable to find replacement for ConnectionListener as this is used to avoid repeated client requests to the same DC which is already down for some reason.

You don't need it anymore. With the Java driver you have the DCAwareLoadBalancingStrategy which will handle nodes/DC down time automatically for you