Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
no dht activity for small networks; this is not needed if the network is small
orbiterf81ef40cc436
diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.javaindex ace606179..0518dc95b 100644--- a/source/de/anomic/plasma/plasmaSwitchboard.java+++ b/source/de/anomic/plasma/plasmaSwitchboard.java@@ -3079,6 +3079,9 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serif (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";}diff --git a/source/de/anomic/yacy/yacySearch.java b/source/de/anomic/yacy/yacySearch.javaindex 20a577232..7f2021f13 100644--- a/source/de/anomic/yacy/yacySearch.java+++ b/source/de/anomic/yacy/yacySearch.java@@ -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 resultsif (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 dhtfinal 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];diff --git a/source/de/anomic/yacy/yacySeedDB.java b/source/de/anomic/yacy/yacySeedDB.javaindex 5ee29bb5e..35199a36a 100644--- a/source/de/anomic/yacy/yacySeedDB.java+++ b/source/de/anomic/yacy/yacySeedDB.java@@ -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())) {