try {
Map<String, Host> ipToHost = Maps.newHashMap();
for (TokenRange range : keyspace.describeRing(dc, rack)) {
for (String endpoint : range.getEndpoints()) {
Host host = ipToHost.get(endpoint);
if (host == null) {
host = new Host(endpoint, defaultPort);
ipToHost.put(endpoint, host);
}
host.getTokenRanges().add(range);
}
}
previousHosts = Lists.newArrayList(ipToHost.values());
return previousHosts;