public Multimap<InetAddress, Range<Token>> getAddressRanges(TokenMetadata metadata)
    {
        Multimap<InetAddress, Range<Token>> map = HashMultimap.create();

        for (Token token : metadata.sortedTokens())
        {
            Range<Token> range = metadata.getPrimaryRangeFor(token);
            for (InetAddress ep : calculateNaturalEndpoints(token, metadata))
            {
                map.put(ep, range);
            }
        }

        return map;
    }
public Multimap < InetAddress , Range < Token > > getAddressRanges ( TokenMetadata metadata ) { Multimap < InetAddress , Range < Token > > map = HashMultimap . create ( ) ; for ( Token token : metadata . sortedTokens ( ) ) { Range < Token > range = metadata . getPrimaryRangeFor ( token ) ; for ( InetAddress ep : calculateNaturalEndpoints ( token , metadata ) ) { map . put ( ep , range ) ; } } return map ; }
/*
NOTE: this is pretty inefficient. also the inverse (getRangeAddresses) below.
this is fine as long as we don't use this on any critical path.
(fixing this would probably require merging tokenmetadata into replicationstrategy,
so we could cache/invalidate cleanly.)