use the median reliability value of nonfailing peers for the reliabilty threshold, and simplify determining them for the speed and integration
This commit is contained in:
@ -105,6 +105,7 @@ public class ProfileOrganizer {
|
|||||||
throw new ClassCastException("Only profiles can be compared - lhs = " + lhs + " rhs = " + rhs);
|
throw new ClassCastException("Only profiles can be compared - lhs = " + lhs + " rhs = " + rhs);
|
||||||
PeerProfile left = (PeerProfile)lhs;
|
PeerProfile left = (PeerProfile)lhs;
|
||||||
PeerProfile right= (PeerProfile)rhs;
|
PeerProfile right= (PeerProfile)rhs;
|
||||||
|
|
||||||
// note below that yes, we are treating left and right backwards. see: classname
|
// note below that yes, we are treating left and right backwards. see: classname
|
||||||
int diff = (int)(right.getReliabilityValue() - left.getReliabilityValue());
|
int diff = (int)(right.getReliabilityValue() - left.getReliabilityValue());
|
||||||
// we can't just return that, since the set would b0rk on equal values (just because two profiles
|
// we can't just return that, since the set would b0rk on equal values (just because two profiles
|
||||||
@ -317,6 +318,10 @@ public class ProfileOrganizer {
|
|||||||
_notFailingPeers.clear();
|
_notFailingPeers.clear();
|
||||||
_reliablePeers.clear();
|
_reliablePeers.clear();
|
||||||
_fastAndReliablePeers.clear();
|
_fastAndReliablePeers.clear();
|
||||||
|
|
||||||
|
Set reordered = new TreeSet(InverseReliabilityComparator._comparator);
|
||||||
|
reordered.addAll(_strictReliabilityOrder);
|
||||||
|
_strictReliabilityOrder = reordered;
|
||||||
|
|
||||||
calculateThresholds(allPeers);
|
calculateThresholds(allPeers);
|
||||||
|
|
||||||
@ -325,11 +330,6 @@ public class ProfileOrganizer {
|
|||||||
locked_placeProfile(profile);
|
locked_placeProfile(profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
Set reordered = new TreeSet(InverseReliabilityComparator._comparator);
|
|
||||||
reordered.addAll(_strictReliabilityOrder);
|
|
||||||
|
|
||||||
_strictReliabilityOrder = reordered;
|
|
||||||
|
|
||||||
locked_unfailAsNecessary();
|
locked_unfailAsNecessary();
|
||||||
locked_promoteFastAsNecessary();
|
locked_promoteFastAsNecessary();
|
||||||
}
|
}
|
||||||
@ -415,59 +415,58 @@ public class ProfileOrganizer {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the thresholds based on the profiles in this set. currently
|
* Update the thresholds based on the profiles in this set. currently
|
||||||
* implements the thresholds based on a simple average (ignoring failing values),
|
* implements the reliability threshold based on the median reliability (ignoring
|
||||||
* with integration and speed being directly equal to the simple average as
|
* failing peers) with integration and speed thresholds being derived from the average
|
||||||
* calculated over all reliable and active non-failing peers, while the reliability threshold
|
* of the active reliable peers.
|
||||||
* is half the simple average of active non-failing peers. Lots of room to tune this.
|
|
||||||
* should this instead be top 10%? top 90%? top 50? etc
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private void calculateThresholds(Set allPeers) {
|
private void calculateThresholds(Set allPeers) {
|
||||||
double totalReliability = 0;
|
Set reordered = new TreeSet(InverseReliabilityComparator._comparator);
|
||||||
int numActive = 0;
|
|
||||||
|
|
||||||
for (Iterator iter = allPeers.iterator(); iter.hasNext(); ) {
|
for (Iterator iter = allPeers.iterator(); iter.hasNext(); ) {
|
||||||
PeerProfile profile = (PeerProfile)iter.next();
|
PeerProfile profile = (PeerProfile)iter.next();
|
||||||
|
|
||||||
if (_us.equals(profile.getPeer())) continue;
|
if (_us.equals(profile.getPeer())) continue;
|
||||||
|
|
||||||
// only take into account peers that we're talking to within the last
|
// only take into account peers that aren't failing
|
||||||
// few minutes
|
if (profile.getIsFailing())
|
||||||
if ( (!profile.getIsActive()) || (profile.getIsFailing()) )
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
numActive++;
|
|
||||||
|
|
||||||
if (profile.getReliabilityValue() > 0)
|
|
||||||
totalReliability += profile.getReliabilityValue();
|
|
||||||
}
|
|
||||||
_thresholdReliabilityValue = getReliabilityThresholdFactor() * avg(totalReliability, numActive);
|
|
||||||
|
|
||||||
// now derive the integration and speed thresholds based ONLY on the reliable
|
reordered.add(profile);
|
||||||
// and active peers
|
}
|
||||||
numActive = 0;
|
int numNotFailing = reordered.size();
|
||||||
|
// how many are in the "top half" of the reliability peers?
|
||||||
|
int topCount = 0;
|
||||||
|
if (numNotFailing != 0)
|
||||||
|
topCount = (int)(numNotFailing / 2);
|
||||||
|
|
||||||
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
|
_log.debug("top count is " + topCount + " out of " + numNotFailing);
|
||||||
|
|
||||||
|
int numActive = 0;
|
||||||
double totalIntegration = 0;
|
double totalIntegration = 0;
|
||||||
double totalSpeed = 0;
|
double totalSpeed = 0;
|
||||||
|
int i = 0;
|
||||||
for (Iterator iter = allPeers.iterator(); iter.hasNext(); ) {
|
for (Iterator iter = reordered.iterator(); iter.hasNext(); i++) {
|
||||||
PeerProfile profile = (PeerProfile)iter.next();
|
PeerProfile profile = (PeerProfile)iter.next();
|
||||||
|
if (i < topCount) {
|
||||||
if (_us.equals(profile.getPeer())) continue;
|
if (profile.getIsActive()) {
|
||||||
|
numActive++;
|
||||||
// only take into account peers that we're talking to within the last
|
if (profile.getIntegrationValue() > 0)
|
||||||
// few minutes, who are reliable, AND who are not failing
|
totalIntegration += profile.getIntegrationValue();
|
||||||
if ( (!profile.getIsActive()) || (profile.getReliabilityValue() < _thresholdReliabilityValue) || (profile.getIsFailing()) )
|
if (profile.getSpeedValue() > 0)
|
||||||
continue;
|
totalSpeed += profile.getSpeedValue();
|
||||||
|
}
|
||||||
numActive++;
|
} else if (i == topCount) {
|
||||||
|
if (profile.getReliabilityValue() < 0)
|
||||||
if (profile.getIntegrationValue() > 0)
|
_thresholdReliabilityValue = 0;
|
||||||
totalIntegration += profile.getIntegrationValue();
|
else
|
||||||
if (profile.getSpeedValue() > 0)
|
_thresholdReliabilityValue = profile.getReliabilityValue();
|
||||||
totalSpeed += profile.getSpeedValue();
|
break;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_thresholdIntegrationValue = 1.0d * avg(totalIntegration, numActive);
|
_thresholdIntegrationValue = 1.0d * avg(totalIntegration, numActive);
|
||||||
_thresholdSpeedValue = 1.0d * avg(totalSpeed, numActive);
|
_thresholdSpeedValue = 1.0d * avg(totalSpeed, numActive);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user