#NEWLINE# def get_required_overload( self , weighted = None , wanted = None ) : #NEWLINE# #INDENT# '\n        Returns the minimum overload value required to make the ring maximally\n        dispersed.\n\n        The required overload is the largest percentage change of any single\n        device from its weighted replicanth to its wanted replicanth (note\n        under weighted devices have a negative percentage change) to archive\n        dispersion - that is to say a single device that must be overloaded by\n        5% is worse than 5 devices in a single tier overloaded by 1%.\n        ' #NEWLINE# weighted = ( weighted or self . _build_weighted_replicas_by_tier ( ) ) #NEWLINE# wanted = ( wanted or self . _build_wanted_replicas_by_tier ( ) ) #NEWLINE# max_overload = 0.0 #NEWLINE# for dev in self . _iter_devs ( ) : #NEWLINE# #INDENT# tier = ( dev [ 'region' ] , dev [ 'zone' ] , dev [ 'ip' ] , dev [ 'id' ] ) #NEWLINE# if ( not dev [ 'weight' ] ) : #NEWLINE# #INDENT# if ( ( tier not in wanted ) or ( not wanted [ tier ] ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# raise exceptions . RingValidationError ( ( 'Device %s has zero weight and should not want any replicas' % ( tier , ) ) ) #NEWLINE# #UNINDENT# required = ( ( wanted [ tier ] - weighted [ tier ] ) / weighted [ tier ] ) #NEWLINE# self . logger . debug ( ( '%s wants %s and is weighted for %s so therefore requires %s overload' % ( tier , wanted [ tier ] , weighted [ tier ] , required ) ) ) #NEWLINE# if ( required > max_overload ) : #NEWLINE# #INDENT# max_overload = required #NEWLINE# #UNINDENT# #UNINDENT# return max_overload