def __get_domain_for_job(self,job_id):
        """
        Computes which domain to run a given job_id on.
        """
        while not self.r.exists('replicated_domains_hash'):
            print "failed to retrieve domain_hashes from redis"
            time.sleep(.1)

        replicated_domains_hash = json.loads(self.r.get('replicated_domains_hash'))

        h = self.hash(job_id)
        # Edge case where we cycle past hash value of 1 and back to 0.
        if h > replicated_domains_hash[-1][1]: return replicated_domains_hash[0][0]
        # Find the index of the worker
        hash_values = map(lambda x: x[1],replicated_domains_hash)
        index = bisect.bisect_left(hash_values,h)
        return replicated_domains_hash[index][0]
dataset/ETHPy150Open nextml/NEXT/next/broker/broker.py/JobBroker.__get_domain_for_job/original