Source:
<code>public <V, K extends Exception> V runWithRetryOnHost( InetSocketAddress specifiedHost, FunctionCheckedException<Cassandra.Client, V, K> fn) throws K { int numTries = 0; boolean shouldRetryOnDifferentHost = false; Set<InetSocketAddress> triedHosts = Sets.newHashSet(); while (true) { if (log.isTraceEnabled()) { log.trace("Running function on host {}.", specifiedHost.getHostString()); } CassandraClientPoolingContainer hostPool = currentPools.get(specifiedHost); if (blacklistedHosts.containsKey(specifiedHost) || hostPool == null || shouldRetryOnDifferentHost) { log.warn("Randomly redirected a query intended for host {}.", specifiedHost); Optional<CassandraClientPoolingContainer> hostPoolCandidate = getRandomGoodHostForPredicate(address -> !triedHosts.contains(address)); hostPool = hostPoolCandidate.orElseGet(this::getRandomGoodHost); } try { return runWithPooledResourceRecordingMetrics(hostPool, fn); } catch (Exception e) { numTries++; triedHosts.add(hostPool.getHost()); this.<K>handleException(numTries, hostPool.getHost(), e); <START> tracingPrefsConfig.run(); <END> if (isRetriableWithBackoffException( tracingPrefsConfig.shouldRetryOnDifferentHostOnThriftTimedOutExceptions(), e)) { log.warn("Retrying with backoff a query intended for host {}.", hostPool.getHost(), e); try { Thread.sleep(numTries * 1000 + (ThreadLocalRandom.current().nextInt(1000) - 500)); } catch (InterruptedException i) { throw new RuntimeException(i); } if (numTries >= MAX_TRIES_SAME_HOST) { shouldRetryOnDifferentHost = true; } } } } }</code><technical_language>remove refreshing of prefs this code path. care of process instantiates object (see AbstractKeyValueService#constructor)</technical_language>

Target:
public <V, K extends Exception> V runWithRetryOnHost( InetSocketAddress specifiedHost, FunctionCheckedException<Cassandra.Client, V, K> fn) throws K { int numTries = 0; boolean shouldRetryOnDifferentHost = false; Set<InetSocketAddress> triedHosts = Sets.newHashSet(); while (true) { if (log.isTraceEnabled()) { log.trace("Running function on host {}.", specifiedHost.getHostString()); } CassandraClientPoolingContainer hostPool = currentPools.get(specifiedHost); if (blacklistedHosts.containsKey(specifiedHost) || hostPool == null || shouldRetryOnDifferentHost) { log.warn("Randomly redirected a query intended for host {}.", specifiedHost); Optional<CassandraClientPoolingContainer> hostPoolCandidate = getRandomGoodHostForPredicate(address -> !triedHosts.contains(address)); hostPool = hostPoolCandidate.orElseGet(this::getRandomGoodHost); } try { return runWithPooledResourceRecordingMetrics(hostPool, fn); } catch (Exception e) { numTries++; triedHosts.add(hostPool.getHost()); this.<K>handleException(numTries, hostPool.getHost(), e); if (isRetriableWithBackoffException( tracingPrefsConfig.shouldRetryOnDifferentHostOnThriftTimedOutExceptions(), e)) { log.warn("Retrying with backoff a query intended for host {}.", hostPool.getHost(), e); try { Thread.sleep(numTries * 1000 + (ThreadLocalRandom.current().nextInt(1000) - 500)); } catch (InterruptedException i) { throw new RuntimeException(i); } if (numTries >= MAX_TRIES_SAME_HOST) { shouldRetryOnDifferentHost = true; } } } } }