Source:
public Set<InetSocketAddress> refreshTokenRangesAndGetServers() { Set<InetSocketAddress> servers = Sets.newHashSet(); try { ImmutableRangeMap.Builder<LightweightOppToken, List<InetSocketAddress>> newTokenRing = ImmutableRangeMap.builder(); List<TokenRange> tokenRanges = getTokenRanges(); myLocation = new HostLocationSupplier(getSnitch(), myLocation).get(); localHosts = refreshLocalHosts(tokenRanges); if (tokenRanges.size() == 1) { String onlyEndpoint = Iterables.getOnlyElement(Iterables.getOnlyElement(tokenRanges).getEndpoints()); InetSocketAddress onlyHost = getAddressForHost(onlyEndpoint); newTokenRing.put(Range.all(), ImmutableList.of(onlyHost)); servers.add(onlyHost); } else { for (TokenRange tokenRange : tokenRanges) { List<InetSocketAddress> hosts = tokenRange.getEndpoints().stream() .map(this::getAddressForHostThrowUnchecked).collect(Collectors.toList()); servers.addAll(hosts); LightweightOppToken startToken = new LightweightOppToken( BaseEncoding.base16().decode(tokenRange.getStart_token().toUpperCase())); LightweightOppToken endToken = new LightweightOppToken( BaseEncoding.base16().decode(tokenRange.getEnd_token().toUpperCase())); if (startToken.compareTo(endToken) <= 0) { newTokenRing.put(Range.openClosed(startToken, endToken), hosts); } else { newTokenRing.put(Range.greaterThan(startToken), hosts); newTokenRing.put(Range.atMost(endToken), hosts); } } } tokenMap = newTokenRing.build(); return servers; } catch (Exception e) { log.info("Couldn't grab new token ranges for token aware cassandra mapping. We will retry in seconds.", SafeArg.of("poolRefreshIntervalSeconds", config.poolRefreshIntervalSeconds()), e); return tokenMap.asMapOfRanges().values().stream().flatMap(Collection::stream).collect(Collectors.toSet()); } }

Target:
public Set<InetSocketAddress> refreshTokenRangesAndGetServers() { Set<InetSocketAddress> servers = Sets.newHashSet(); try { ImmutableRangeMap.Builder<LightweightOppToken, List<InetSocketAddress>> newTokenRing = ImmutableRangeMap.builder(); List<TokenRange> tokenRanges = getTokenRanges(); localHosts = refreshLocalHosts(tokenRanges); if (tokenRanges.size() == 1) { String onlyEndpoint = Iterables.getOnlyElement(Iterables.getOnlyElement(tokenRanges).getEndpoints()); InetSocketAddress onlyHost = getAddressForHost(onlyEndpoint); newTokenRing.put(Range.all(), ImmutableList.of(onlyHost)); servers.add(onlyHost); } else { for (TokenRange tokenRange : tokenRanges) { List<InetSocketAddress> hosts = tokenRange.getEndpoints().stream() .map(this::getAddressForHostThrowUnchecked).collect(Collectors.toList()); servers.addAll(hosts); LightweightOppToken startToken = new LightweightOppToken( BaseEncoding.base16().decode(tokenRange.getStart_token().toUpperCase())); LightweightOppToken endToken = new LightweightOppToken( BaseEncoding.base16().decode(tokenRange.getEnd_token().toUpperCase())); if (startToken.compareTo(endToken) <= 0) { newTokenRing.put(Range.openClosed(startToken, endToken), hosts); } else { newTokenRing.put(Range.greaterThan(startToken), hosts); newTokenRing.put(Range.atMost(endToken), hosts); } } } tokenMap = newTokenRing.build(); return servers; } catch (Exception e) { log.info("Couldn't grab new token ranges for token aware cassandra mapping. We will retry in seconds.", SafeArg.of("poolRefreshIntervalSeconds", config.poolRefreshIntervalSeconds()), e); Set<InetSocketAddress> resolvedConfigAddresses = config.servers() .accept(new CassandraServersConfigs.ThriftHostsExtractingVisitor()); Set<InetSocketAddress> lastKnownAddresses = tokenMap.asMapOfRanges().values().stream().flatMap( Collection::stream).collect(Collectors.toSet()); return Sets.union(resolvedConfigAddresses, lastKnownAddresses); } }