HConnectionManager { 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; } HConnectionManager(String clusterName, CassandraHostConfigurator cassandraHostConfigurator); void doAddNodes(); boolean addCassandraHost(CassandraHost cassandraHost); boolean removeCassandraHost(CassandraHost cassandraHost); boolean suspendCassandraHost(CassandraHost cassandraHost); boolean unsuspendCassandraHost(CassandraHost cassandraHost); Set<CassandraHost> getSuspendedCassandraHosts(); Set<CassandraHost> getHosts(); List<String> getStatusPerPool(); void operateWithFailover(Operation<?> op); HOpTimer getTimer(); void setTimer(HOpTimer timer); void addListener(String listenerName, ConnectionManagerListener listener); void removeListener(String listenerName); void removeAllListeners(); Set<CassandraHost> getDownedHosts(); Collection<HClientPool> getActivePools(); long createClock(); String getClusterName(); void shutdown(); void setCassandraHostRetryDelay(int retryDelay);  }
@Test public void testAddCassandraHostFail() { setupClient(); CassandraHost cassandraHost = new CassandraHost("127.0.0.1", 9180); assertFalse(connectionManager.addCassandraHost(cassandraHost)); }