Skip to content

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

fix for last DHT distribution bug-fix

orbitere2ff1767b5ca
diff --git a/build.properties b/build.properties
index 27b3335d7..7855c0838 100644
--- a/build.properties
+++ b/build.properties
@@ -3,7 +3,7 @@ javacSource=1.4
javacTarget=1.4
# Release Configuration
-releaseVersion=0.421
+releaseVersion=0.422
#releaseFile=yacy_dev_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gz
releaseFile=yacy_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gz
#releaseDir=yacy_dev_v${releaseVersion}_${DSTAMP}_${releaseNr}
diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.java
index c122ee1a4..659185d7c 100644
--- a/source/de/anomic/plasma/plasmaSwitchboard.java
+++ b/source/de/anomic/plasma/plasmaSwitchboard.java
@@ -560,7 +560,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
);
indexDistribution.setCounts(150, 1, 3, 10000);
deployThread("20_dhtdistribution", "DHT Distribution", "selection, transfer and deletion of index entries that are not searched on your peer, but on others", null,
- new serverInstantThread(indexDistribution, "job", null), 600000);
+ new serverInstantThread(indexDistribution, "job", null), 60000);
// test routine for snippet fetch
//Set query = new HashSet();
diff --git a/source/de/anomic/plasma/plasmaWordIndexDistribution.java b/source/de/anomic/plasma/plasmaWordIndexDistribution.java
index 2c31359f3..371719f76 100644
--- a/source/de/anomic/plasma/plasmaWordIndexDistribution.java
+++ b/source/de/anomic/plasma/plasmaWordIndexDistribution.java
@@ -219,28 +219,28 @@ public final class plasmaWordIndexDistribution {
String keyhash = indexEntities[indexEntities.length - 1].wordHash(); // DHT targets must have greater hashes
// find a list of DHT-peers
- yacySeed[] seeds = new yacySeed[peerCount];
- int hc = 0;
+ yacySeed[] seeds = new yacySeed[peerCount + 10];
+ int hc0 = 0;
synchronized (yacyCore.dhtAgent) {
double avdist;
Enumeration e = yacyCore.dhtAgent.getAcceptRemoteIndexSeeds(keyhash);
- while ((e.hasMoreElements()) && (hc < peerCount)) {
+ while ((e.hasMoreElements()) && (hc0 < seeds.length)) {
if (closed) {
log.logSevere("Index distribution interrupted by close, nothing deleted locally.");
return -1; // interrupted
}
- seeds[hc] = (yacySeed) e.nextElement();
- if ((seeds[hc] != null) &&
- ((avdist = (yacyDHTAction.dhtDistance(seeds[hc].hash, indexEntities[0].wordHash()) + yacyDHTAction.dhtDistance(seeds[hc].hash, indexEntities[indexEntities.length - 1].wordHash())) / 2.0) < 0.3)) {
- log.logInfo("Selected DHT target peer " + seeds[hc].getName() + ":" + seeds[hc].hash + ", distance = " + avdist);
- hc++;
+ 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++;
}
}
e = null; // finish enumeration
}
- if (hc < peerCount) {
- log.logWarning("found not enough (" + hc + ") peers for distribution");
+ if (hc0 < peerCount) {
+ log.logWarning("found not enough (" + hc0 + ") peers for distribution");
return -1; // failed
}
@@ -248,7 +248,8 @@ public final class plasmaWordIndexDistribution {
String error;
String peerNames = "";
long start;
- for (int i = 0; i < peerCount; i++) {
+ int hc1 = 0;
+ for (int i = 0; i < hc0; i++) {
if (closed) {
log.logSevere("Index distribution interrupted by close, nothing deleted locally.");
return -1; // interrupted
@@ -259,17 +260,17 @@ public final class plasmaWordIndexDistribution {
log.logInfo("Index transfer of " + indexCount + " words [" + indexEntities[0].wordHash() + " .. " + indexEntities[indexEntities.length - 1].wordHash() + "] to peer " + seeds[i].getName() + ":" + seeds[i].hash + " in " + ((System.currentTimeMillis() - start) / 1000)
+ " seconds successfull (" + (1000 * indexCount / (System.currentTimeMillis() - start + 1)) + " words/s)");
peerNames += ", " + seeds[i].getName();
- hc++;
+ hc1++;
} else {
log.logWarning("Index transfer to peer " + seeds[i].getName() + ":" + seeds[i].hash + " failed:'" + error + "', disconnecting peer");
yacyCore.peerActions.peerDeparture(seeds[i]);
}
-
+ if (hc1 >= peerCount) break;
}
if (peerNames.length() > 0) peerNames = peerNames.substring(2); // remove comma
// clean up and finish with deletion of indexes
- if (hc >= peerCount) {
+ if (hc1 >= peerCount) {
// success
if (delete) {
try {
@@ -292,7 +293,7 @@ public final class plasmaWordIndexDistribution {
}
return indexCount;
} else {
- log.logSevere("Index distribution failed. Too few peers (" + hc + ") received the index, not deleted locally.");
+ log.logSevere("Index distribution failed. Too few peers (" + hc1 + ") received the index, not deleted locally.");
// simply close the indexEntities
for (int i = 0; i < indexEntities.length; i++) try {
indexEntities[i].close();