} catch (Exception e) { completelyUnresponsiveHosts.put(host, e); blacklist.add(host);
@Test public void shouldNotReturnHostsNotMatchingPredicateEvenWithNodeFailure() { CassandraService cassandra = clientPoolWithServersInCurrentPool(ImmutableSet.of(HOST_1, HOST_2)); blacklist.add(HOST_1); Optional<CassandraClientPoolingContainer> container = cassandra.getRandomGoodHostForPredicate(address -> address.equals(HOST_1)); assertContainerHasHostOne(container); }
@SuppressWarnings("unchecked") <K extends Exception> void handleExceptionFromRequest( RetryableCassandraRequest<?, K> req, InetSocketAddress hostTried, Exception ex) throws K { if (!isRetryable(ex)) { throw (K) ex; } RequestExceptionHandlerStrategy strategy = getStrategy(); req.triedOnHost(hostTried); req.registerException(ex); int numberOfAttempts = req.getNumberOfAttempts(); int numberOfAttemptsOnHost = req.getNumberOfAttemptsOnHost(hostTried); if (numberOfAttempts >= maxTriesTotal.get()) { throw logAndThrowException(numberOfAttempts, ex, req); } if (shouldBlacklist(ex, numberOfAttemptsOnHost)) { blacklist.add(hostTried); } logNumberOfAttempts(ex, numberOfAttempts); handleBackoff(req, hostTried, ex, strategy); handleRetryOnDifferentHosts(req, hostTried, ex, strategy); }
} catch (Exception e) { completelyUnresponsiveHosts.put(host, e); blacklist.add(host);
@SuppressWarnings("unchecked") <K extends Exception> void handleExceptionFromRequest( RetryableCassandraRequest<?, K> req, InetSocketAddress hostTried, Exception ex) throws K { if (!isRetryable(ex)) { throw (K) ex; } RequestExceptionHandlerStrategy strategy = getStrategy(); req.triedOnHost(hostTried); req.registerException(ex); int numberOfAttempts = req.getNumberOfAttempts(); int numberOfAttemptsOnHost = req.getNumberOfAttemptsOnHost(hostTried); if (numberOfAttempts >= maxTriesTotal.get()) { throw logAndThrowException(numberOfAttempts, ex, req); } if (shouldBlacklist(ex, numberOfAttemptsOnHost)) { blacklist.add(hostTried); } logNumberOfAttempts(ex, numberOfAttempts); handleBackoff(req, hostTried, ex, strategy); handleRetryOnDifferentHosts(req, hostTried, ex, strategy); }