no dht activity for small networks; this is not needed if the network is small

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

@ -3079,6 +3079,9 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser
if (yacyCore.seedDB.mySeed.isVirgin()) {
return "no DHT distribution: status is virgin";
}
if (yacyCore.seedDB.noDHTActivity()) {
return "no DHT distribution: network too small";
}
if (getConfig(INDEX_DIST_ALLOW, "false").equalsIgnoreCase("false")) {
return "no DHT distribution: not enabled";
}

@ -162,13 +162,15 @@ public class yacySearch extends Thread {
//return (yacySeed[]) l.toArray();
}
private static yacySeed[] selectDHTPeers(Set wordhashes, int seedcount) {
private static yacySeed[] selectSearchTargets(Set wordhashes, int seedcount) {
// find out a specific number of seeds, that would be relevant for the given word hash(es)
// the result is ordered by relevance: [0] is most relevant
// the seedcount is the maximum number of wanted results
if (yacyCore.seedDB == null) { return null; }
if (seedcount > yacyCore.seedDB.sizeConnected()) { seedcount = yacyCore.seedDB.sizeConnected(); }
if ((seedcount >= yacyCore.seedDB.sizeConnected()) || (yacyCore.seedDB.noDHTActivity())) {
seedcount = yacyCore.seedDB.sizeConnected();
}
// put in seeds according to dht
final kelondroMScoreCluster ranking = new kelondroMScoreCluster();
final HashMap seeds = new HashMap();
@ -256,7 +258,7 @@ public class yacySearch extends Thread {
if (yacyCore.seedDB.mySeed == null || yacyCore.seedDB.mySeed.getPublicAddress() == null) { return null; }
// prepare seed targets and threads
final yacySeed[] targetPeers = (clusterselection == null) ? selectDHTPeers(plasmaSearchQuery.hashes2Set(wordhashes), targets) : selectClusterPeers(clusterselection);
final yacySeed[] targetPeers = (clusterselection == null) ? selectSearchTargets(plasmaSearchQuery.hashes2Set(wordhashes), targets) : selectClusterPeers(clusterselection);
if (targetPeers == null) return new yacySearch[0];
targets = targetPeers.length;
if (targets == 0) return new yacySearch[0];

@ -91,7 +91,8 @@ public final class yacySeedDB {
* these hashes all shall be generated by base64.enhancedCoder
*/
public static final int commonHashLength = 12;
public static final int dhtActivityMagic = 32;
public static final String[] sortFields = new String[] {yacySeed.LCOUNT, yacySeed.ICOUNT, yacySeed.UPTIME, yacySeed.VERSION, yacySeed.LASTSEEN};
public static final String[] longaccFields = new String[] {yacySeed.LCOUNT, yacySeed.ICOUNT, yacySeed.ISPEED};
public static final String[] doubleaccFields = new String[] {yacySeed.RSPEED};
@ -178,6 +179,11 @@ public final class yacySeedDB {
} catch (IOException e) {}
}
public boolean noDHTActivity() {
// for small networks, we don't perform DHT transmissions, because it is possible to search over all peers
return this.sizeConnected() <= dhtActivityMagic;
}
private synchronized kelondroMapObjects openSeedTable(File seedDBFile) {
final boolean usetree = false;
new File(seedDBFile.getParent()).mkdirs();
@ -800,32 +806,6 @@ public final class yacySeedDB {
if (remote != null) try { httpc.returnInstance(remote); } catch (Exception e) {}
}
}
/**
* @deprecated Function seems to be unused
*/
public String copyCache(File seedFile, URL seedURL) {
if (seedURL == null) return "COPY - Error: URL not given";
try {
// getting the current list
ArrayList uv = storeCache(seedFile, true);
// test download
serverLog.logFine("YACY","Trying to download seed-file '" + seedURL + "'.");
ArrayList check = downloadSeedFile(seedURL);
// Comparing if local copy and uploaded copy are equal
String errorMsg = checkCache(uv, check);
if (errorMsg == null) {
return "COPY CHECK - Success: the result vectors are equal" + serverCore.crlfString;
} else {
return "COPY CHECK - Error: the result vector is different. " + errorMsg + serverCore.crlfString;
}
} catch (IOException e) {
return "COPY CHECK - Error: IO problem " + e.getMessage() + serverCore.crlfString;
}
}
private String checkCache(ArrayList uv, ArrayList check) {
if ((check == null) || (uv == null) || (uv.size() != check.size())) {

Loading…
Cancel
Save