Source:
public Set<InetSocketAddress> refreshTokenRanges() { Set<InetSocketAddress> servers = Sets.newHashSet(); try { ImmutableRangeMap.Builder<LightweightOppToken, List<InetSocketAddress>> newTokenRing = ImmutableRangeMap.builder(); List<TokenRange> tokenRanges = getTokenRanges(); if (tokenRanges.size() == 1) { String onlyEndpoint = Iterables.getOnlyElement(Iterables.getOnlyElement(tokenRanges).getEndpoints()); InetSocketAddress onlyHost = getAddressForHost(onlyEndpoint); newTokenRing.put(Range.all(), ImmutableList.of(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(); tokenRangeWritesLogger.updateTokenRanges(tokenMap.asMapOfRanges().keySet()); return servers; } catch (Exception e) { log.warn("Couldn't grab new token ranges for token aware cassandra mapping!", e); return tokenMap.asMapOfRanges().values().stream().flatMap(Collection::stream).collect(Collectors.toSet()); } }

Target:
public Set<InetSocketAddress> refreshTokenRanges() { Set<InetSocketAddress> servers = Sets.newHashSet(); try { ImmutableRangeMap.Builder<LightweightOppToken, List<InetSocketAddress>> newTokenRing = ImmutableRangeMap.builder(); List<TokenRange> tokenRanges = getTokenRanges(); if (tokenRanges.size() == 1) { String onlyEndpoint = Iterables.getOnlyElement(Iterables.getOnlyElement(tokenRanges).getEndpoints()); InetSocketAddress onlyHost = getAddressForHost(onlyEndpoint); newTokenRing.put(Range.all(), ImmutableList.of(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()); } }