apply load limitation also to dht-in

pull/1/head
orbiter 11 years ago
parent 0343f0668c
commit bf0ad04e1b

@ -837,7 +837,7 @@ indexControl.gzipBody = true
indexControl.timeout = 60000
indexDistribution.timeout = 60000
indexTransfer.timeout = 120000
indexTransfer.maxload = 2.5
indexTransfer.maxload = 2.2
# defining max. allowed amount of open files during index- transfer/distribution
indexDistribution.maxOpenFiles = 800

@ -40,6 +40,7 @@ import net.yacy.cora.protocol.HeaderFramework;
import net.yacy.cora.protocol.RequestHeader;
import net.yacy.cora.storage.HandleSet;
import net.yacy.cora.util.ConcurrentLog;
import net.yacy.cora.util.Memory;
import net.yacy.cora.util.SpaceExceededException;
import net.yacy.kelondro.data.meta.URIMetadataRow;
import net.yacy.kelondro.data.word.WordReferenceRow;
@ -105,7 +106,14 @@ public final class transferRWI {
String result = "ok";
final StringBuilder unknownURLs = new StringBuilder(6000);
if ((youare == null) || (!youare.equals(sb.peers.mySeed().hash))) {
double load = Memory.load();
float maxload = sb.getConfigFloat(SwitchboardConstants.INDEX_TRANSFER_MAXLOAD, 1.5f);
if (load > maxload) {
// too high local load. this is bad but we must reject this to protect ourself!
sb.getLog().info("Rejecting RWIs from peer " + otherPeerName + ", system has too high load = " + load + ", maxload = " + maxload);
result = "not_granted";
pause = (int) (load * 20000);
} else if ((youare == null) || (!youare.equals(sb.peers.mySeed().hash))) {
sb.getLog().info("Rejecting RWIs from peer " + otherPeerName + ". Wrong target. Wanted peer=" + youare + ", iam=" + sb.peers.mySeed().hash);
result = "wrong_target";
pause = 0;

Loading…
Cancel
Save