'Rebuild our view of the topology from fresh rows from the
system topology tables.
For internal use only.'

def rebuild_token_map(self, partitioner, token_map):

    self.partitioner = partitioner
    if partitioner.endswith('RandomPartitioner'):
        token_class = MD5Token
    elif partitioner.endswith('Murmur3Partitioner'):
        token_class = Murmur3Token
    elif partitioner.endswith('ByteOrderedPartitioner'):
        token_class = BytesToken
    else:
        self.token_map = None
        return
    token_to_host_owner = {}
    ring = []
    for (host, token_strings) in six.iteritems(token_map):
        for token_string in token_strings:
            token = token_class.from_string(token_string)
            ring.append(token)
            token_to_host_owner[token] = host
    all_tokens = sorted(ring)
    self.token_map = TokenMap(token_class, token_to_host_owner, all_tokens, self)
