another dht selection fix

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3725 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 18 years ago
parent 03c6551b0c
commit b05e2314cf

@ -3186,7 +3186,8 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
try {
// find a list of DHT-peers
ArrayList seeds = yacyCore.dhtAgent.getDHTTargets(log, peerCount, 10, dhtChunk.firstContainer().getWordHash(), dhtChunk.lastContainer().getWordHash(), 0.2);
double maxDist = 0.2;
ArrayList seeds = yacyCore.dhtAgent.getDHTTargets(log, peerCount, Math.min(8, (int) (yacyCore.seedDB.sizeConnected() * maxDist)), dhtChunk.firstContainer().getWordHash(), dhtChunk.lastContainer().getWordHash(), maxDist);
if (seeds.size() < peerCount) {
log.logWarning("found not enough (" + seeds.size() + ") peers for distribution for dhtchunk [" + dhtChunk.firstContainer().getWordHash() + " .. " + dhtChunk.lastContainer().getWordHash() + "]");
return false;

@ -300,8 +300,8 @@ public class yacyDHTAction implements yacyPeerAction {
kelondroBase64Order.enhancedCoder.cardinal(lastKey.getBytes()) > kelondroBase64Order.enhancedCoder.cardinal(yacyCore.seedDB.mySeed.hash.getBytes()));
ArrayList seeds = new ArrayList();
yacySeed seed;
double ownDistance = Math.min(yacyDHTAction.dhtDistance(yacyCore.seedDB.mySeed.hash, firstKey), yacyDHTAction.dhtDistance(yacyCore.seedDB.mySeed.hash, lastKey));
double maxDistance = Math.min(ownDistance, maxDist);
//double ownDistance = Math.min(yacyDHTAction.dhtDistance(yacyCore.seedDB.mySeed.hash, firstKey), yacyDHTAction.dhtDistance(yacyCore.seedDB.mySeed.hash, lastKey));
//double maxDistance = Math.min(ownDistance, maxDist);
double firstdist, lastdist;
Enumeration e = this.getAcceptRemoteIndexSeeds(lastKey);
@ -313,7 +313,7 @@ public class yacyDHTAction implements yacyPeerAction {
if (seeds != null) {
firstdist = yacyDHTAction.dhtDistance(seed.hash, firstKey);
lastdist = yacyDHTAction.dhtDistance(seed.hash, lastKey);
if ((lastdist < maxDistance) && (!(doublecheck.contains(seed.hash)))) {
if ((lastdist < maxDist) && (!(doublecheck.contains(seed.hash)))) {
if (log != null) log.logInfo("Selected " + ((seeds.size() < primaryPeerCount) ? "primary" : "reserve") + " DHT target peer " + seed.getName() + ":" + seed.hash + ", distance2first = " + firstdist + ", distance2last = " + lastdist);
seeds.add(seed);
doublecheck.add(seed.hash);

Loading…
Cancel
Save