public boolean addCassandraHost ( CassandraHost cassandraHost ) { if ( ! getHosts ( ) . contains ( cassandraHost ) ) { HClientPool pool = null ; try { cassandraHostConfigurator . applyConfig ( cassandraHost ) ; pool = cassandraHostConfigurator . getLoadBalancingPolicy ( ) . createConnection ( clientFactory , cassandraHost , monitor ) ; hostPools . putIfAbsent ( cassandraHost , pool ) ; log . info ( "Added host {} to pool" , cassandraHost . getName ( ) ) ; listenerHandler . fireOnAddHost ( cassandraHost , true , null , null ) ; return true ; } catch ( HectorTransportException hte ) { String errorMessage = "Transport exception host to HConnectionManager: " + cassandraHost ; log . error ( errorMessage , hte ) ; listenerHandler . fireOnAddHost ( cassandraHost , false , errorMessage , hte ) ; } catch ( Exception ex ) { String errorMessage = "General exception host to HConnectionManager: " + cassandraHost ; log . error ( errorMessage , ex ) ; listenerHandler . fireOnAddHost ( cassandraHost , false , errorMessage , ex ) ; } } else { String message = "Host already existed for pool " + cassandraHost . getName ( ) ; log . info ( message ) ; listenerHandler . fireOnAddHost ( cassandraHost , false , message , null ) ; } return false ; }
Returns true if the host was successfully added . In any sort of failure exceptions are caught and logged returning false .