(self)
Creates hash ring.
Creates hash ring.
Creates hash ring .
def _build_circle(self):
        """
            Creates hash ring.
        """
        total_weight = 0
        for node in self._nodes:
            total_weight += self._weights.get(node, 1)

        for node in self._nodes:
            weight = self._weights.get(node, 1)

            ks = math.floor((40 * len(self._nodes) * weight) / total_weight)

            for i in xrange(0, int(ks)):
                b_key = self._md5_digest('%s-%s-salt' % (node, i))

                for l in xrange(0, 4):
                    key = ((b_key[3 + l * 4] << 24)
                           | (b_key[2 + l * 4] << 16)
                           | (b_key[1 + l * 4] << 8)
                           | b_key[l * 4])

                    self._hashring[key] = node
                    self._sorted_keys.append(key)

        self._sorted_keys.sort()
def _build_circle ( self ) : total_weight = 0 for node in self . _nodes : total_weight += self . _weights . get ( node , 1 ) for node in self . _nodes : weight = self . _weights . get ( node , 1 ) ks = math . floor ( ( 40 * len ( self . _nodes ) * weight ) / total_weight ) for i in xrange ( 0 , int ( ks ) ) : b_key = self . _md5_digest ( '%s-%s-salt' % ( node , i ) ) for l in xrange ( 0 , 4 ) : key = ( ( b_key [ 3 + l * 4 ] << 24 ) | ( b_key [ 2 + l * 4 ] << 16 ) | ( b_key [ 1 + l * 4 ] << 8 ) | b_key [ l * 4 ] ) self . _hashring [ key ] = node self . _sorted_keys . append ( key ) self . _sorted_keys . sort ( )