Author: nextgens
Date: 2008-09-01 22:13:22 +0000 (Mon, 01 Sep 2008)
New Revision: 22325
Modified:
trunk/freenet/src/freenet/node/PeerManager.java
trunk/freenet/src/freenet/node/PeerNode.java
Log:
solve issue #2464: Limit any one node to 30% of our total outgoing requests
Modified: trunk/freenet/src/freenet/node/PeerManager.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerManager.java 2008-09-01 22:08:50 UTC
(rev 22324)
+++ trunk/freenet/src/freenet/node/PeerManager.java 2008-09-01 22:13:22 UTC
(rev 22325)
@@ -882,6 +882,7 @@
long now = System.currentTimeMillis();
int count = 0;
+ boolean enableFOAFMitigationHack = peers.length >=
PeerNode.SELECTION_MIN_PEERS;
Long selectionSamplesTimestamp = now -
PeerNode.SELECTION_SAMPLING_PERIOD;
int numberOfSelectionsSamples =
getNumberOfSelectionSamples().tailSet(selectionSamplesTimestamp).size();
for(int i = 0; i < peers.length; i++) {
@@ -908,7 +909,7 @@
}
int selectionSamples =
p.getNumberOfSelections().tailSet(selectionSamplesTimestamp).size();
int selectionSamplesPercentage =
selectionSamples*100/numberOfSelectionsSamples;
- if(PeerNode.SELECTION_PERCENTAGE_WARNING <
selectionSamplesPercentage) {
+ if(enableFOAFMitigationHack &&
(PeerNode.SELECTION_PERCENTAGE_WARNING < selectionSamplesPercentage)) {
if(logMINOR)
Logger.minor(this, "Skipping
over-selectionned peer("+selectionSamplesPercentage+"%): "+p.getPeer());
continue;
Modified: trunk/freenet/src/freenet/node/PeerNode.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerNode.java 2008-09-01 22:08:50 UTC
(rev 22324)
+++ trunk/freenet/src/freenet/node/PeerNode.java 2008-09-01 22:13:22 UTC
(rev 22325)
@@ -163,6 +163,8 @@
public static final int SELECTION_SAMPLING_PERIOD = 5 * 60 * 1000;
// 30%; yes it's alchemy too! and probably *way* too high to serve any
purpose
public static final int SELECTION_PERCENTAGE_WARNING = 30;
+ // Minimum number of routable peers to have for the selection code to
have any effect
+ public static final int SELECTION_MIN_PEERS = 5;
// Should be good enough provided we don't get selected more than 10
times per/sec
// Lower the following value if you want to spare memory... or better
switch from a TreeSet to a bit field.
public static final int SELECTION_MAX_SAMPLES = 10 *
SELECTION_SAMPLING_PERIOD / 1000;