def select_host(self, metric):
        """
        Returns the carbon host that has data for the given metric.
        """
        key = self.keyfunc(metric)
        nodes = []
        servers = set()
        for node in self.hash_ring.get_nodes(key):
            server, instance = node
            if server in servers:
                continue
            servers.add(server)
            nodes.append(node)
            if len(servers) >= self.replication_factor:
                break
        available = [n for n in nodes if self.is_available(n)]
        return random.choice(available or nodes)
def select_host ( self , metric ) : key = self . keyfunc ( metric ) nodes = [ ] servers = set ( ) for node in self . hash_ring . get_nodes ( key ) : server , instance = node if server in servers : continue servers . add ( server ) nodes . append ( node ) if len ( servers ) >= self . replication_factor : break available = [ n for n in nodes if self . is_available ( n ) ] return random . choice ( available or nodes )
Returns the carbon host that has data for the given metric.