Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

better control for target peer selection for RWI transfer see also http://www.yacy-forum.de/viewtopic.php?p=15343#15343

orbiter71d5c2b2caef
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