From 71d5c2b2caef1eb877a1f43e22a2cee8bc75d94c Mon Sep 17 00:00:00 2001 From: orbiter Date: Wed, 18 Jan 2006 00:30:07 +0000 Subject: [PATCH] better control for target peer selection for RWI transfer see also http://www.yacy-forum.de/viewtopic.php?p=15343#15343 git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1370 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- .../anomic/plasma/plasmaWordIndexDistribution.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/source/de/anomic/plasma/plasmaWordIndexDistribution.java b/source/de/anomic/plasma/plasmaWordIndexDistribution.java index 371719f76..366df9c63 100644 --- a/source/de/anomic/plasma/plasmaWordIndexDistribution.java +++ b/source/de/anomic/plasma/plasmaWordIndexDistribution.java @@ -221,6 +221,9 @@ public final class plasmaWordIndexDistribution { // find a list of DHT-peers yacySeed[] seeds = new yacySeed[peerCount + 10]; int hc0 = 0; + double ownDistance = Math.min(yacyDHTAction.dhtDistance(yacyCore.seedDB.mySeed.hash, indexEntities[0].wordHash()), + yacyDHTAction.dhtDistance(yacyCore.seedDB.mySeed.hash, indexEntities[indexEntities.length - 1].wordHash())); + double maxDistance = Math.min(ownDistance, 0.4); synchronized (yacyCore.dhtAgent) { double avdist; Enumeration e = yacyCore.dhtAgent.getAcceptRemoteIndexSeeds(keyhash); @@ -230,10 +233,13 @@ public final class plasmaWordIndexDistribution { return -1; // interrupted } seeds[hc0] = (yacySeed) e.nextElement(); - if ((seeds[hc0] != null) && - ((avdist = (yacyDHTAction.dhtDistance(seeds[hc0].hash, indexEntities[0].wordHash()) + yacyDHTAction.dhtDistance(seeds[hc0].hash, indexEntities[indexEntities.length - 1].wordHash())) / 2.0) < 0.4)) { - log.logInfo("Selected " + ((hc0 < peerCount) ? "primary" : "reserve") + " DHT target peer " + seeds[hc0].getName() + ":" + seeds[hc0].hash + ", distance = " + avdist); - hc0++; + if (seeds[hc0] != null) { + avdist = Math.max(yacyDHTAction.dhtDistance(seeds[hc0].hash, indexEntities[0].wordHash()), + yacyDHTAction.dhtDistance(seeds[hc0].hash, indexEntities[indexEntities.length - 1].wordHash())); + if (avdist < maxDistance) { + log.logInfo("Selected " + ((hc0 < peerCount) ? "primary" : "reserve") + " DHT target peer " + seeds[hc0].getName() + ":" + seeds[hc0].hash + ", distance = " + avdist); + hc0++; + } } } e = null; // finish enumeration