private String getTopologyFromRandomNodeWithRetry ( Set < Host > activeHosts ) { int count = NUM_RETRIES_PER_NODE ; String nodeResponse ; Exception lastEx ; final Host randomHost = getRandomHost ( activeHosts ) ; do { try { lastEx = null ; nodeResponse = getResponseViaHttp ( randomHost . getHostName ( ) ) ; if ( nodeResponse != null ) { Logger . info ( "Received topology from " + randomHost ) ; return nodeResponse ; } } catch ( Exception e ) { Logger . info ( "cannot get topology from : " + randomHost ) ; lastEx = e ; } finally { count -- ; } } while ( ( count > 0 ) ) ; if ( lastEx != null ) { if ( lastEx instanceof ConnectTimeoutException ) { throw new TimeoutException ( "Unable to obtain topology" , lastEx ) . setHost ( randomHost ) ; } throw new DynoException ( String . format ( "Unable to obtain topology from %s" , randomHost ) , lastEx ) ; } else { throw new DynoException ( String . format ( "Could not contact dynomite manager for token map on %s" , randomHost ) ) ; } }
Tries multiple nodes and it only bubbles up the last node s exception . We want to bubble up the exception in order for the last node to be removed from the connection pool .