Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
*)removed multiple DHT_Distribution_Threads *)boosted DHT_Distribution sending chunk parallel to multiple peers
hydrox8da13088e988
diff --git a/source/de/anomic/plasma/plasmaDHTTransfer.java b/source/de/anomic/plasma/plasmaDHTTransfer.javaindex 97ffe06d0..fd4ddb03f 100644--- a/source/de/anomic/plasma/plasmaDHTTransfer.java+++ b/source/de/anomic/plasma/plasmaDHTTransfer.java@@ -60,6 +60,8 @@ public class plasmaDHTTransfer extends Thread {private String transferStatusMessage = "";// delivery destination+ private static yacySeed [] seeds = null;+ private static int seedcount = 0;yacySeed seed = null;// word chunk@@ -74,13 +76,25 @@ public class plasmaDHTTransfer extends Thread {this.log = log;this.gzipBody4Transfer = gzipBody;this.timeout4Transfer = timeout;- this.seed = seed;this.dhtChunk = dhtChunk;this.maxRetry = retries;+ seeds = new yacySeed[1];+ seeds[0] = seed;+ }++ public plasmaDHTTransfer(serverLog log, yacySeed [] seeds, plasmaDHTChunk dhtChunk, boolean gzipBody, int timeout, int retries) {+ super(new ThreadGroup("TransferIndexThreadGroup"), "TransferIndexWorker_" + seedcount);+ this.log = log;+ this.gzipBody4Transfer = gzipBody;+ this.timeout4Transfer = timeout;+ this.dhtChunk = dhtChunk;+ this.maxRetry = retries;+ setSeeds(seeds);}public void run() {- try {+ while (getStatus() != plasmaDHTChunk.chunkStatus_COMPLETE && seedcount < seeds.length)try {+ seed = seeds[seedcount++];uploadIndex();} catch (InterruptedException e) {// TODO Auto-generated catch block@@ -89,7 +103,7 @@ public class plasmaDHTTransfer extends Thread {}}-+private boolean isAborted() {if (stopped || Thread.currentThread().isInterrupted()) {return true;@@ -185,5 +199,16 @@ public class plasmaDHTTransfer extends Thread {}}}-++ private static void setSeeds(yacySeed [] seeds) {+ plasmaDHTTransfer.seeds = seeds;+ }++ public static void setSeedcount(int seedcount) {+ plasmaDHTTransfer.seedcount = seedcount;+ }++ public static int getSeedcount() {+ return seedcount;+ }}diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.javaindex d5e6c7b64..63b59ba66 100644--- a/source/de/anomic/plasma/plasmaSwitchboard.java+++ b/source/de/anomic/plasma/plasmaSwitchboard.java@@ -586,14 +586,11 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serpeerPing = new serverInstantThread(yc, "peerPing", null), 2000);peerPing.setSyncObject(new Object());- getConfig("20_dhtdistribution_threads","1");- for(int i=0; i<(int)getConfigLong("20_dhtdistribution_threads",1);i++) {- deployThread("20_dhtdistribution_"+i, "DHT Distribution", "selection, transfer and deletion of index entries that are not searched on your peer, but on others", null,- new serverInstantThread(this, "dhtTransferJob", null), 60000 + i*5000,+ 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(this, "dhtTransferJob", null), 60000,Long.parseLong(getConfig("20_dhtdistribution_idlesleep" , "5000")),Long.parseLong(getConfig("20_dhtdistribution_busysleep" , "0")),Long.parseLong(getConfig("20_dhtdistribution_memprereq" , "1000000")));- }// test routine for snippet fetch//Set query = new HashSet();@@ -2131,19 +2128,36 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser// send away the indexes to all these peersString peerNames = "";int hc1 = 0;- plasmaDHTTransfer transfer = null;- for (int i = 0; i < seeds.length; i++) {- transfer = new plasmaDHTTransfer(log, seeds[i], dhtChunk,+ plasmaDHTTransfer.setSeedcount(0);+ plasmaDHTTransfer [] transfer = new plasmaDHTTransfer[peerCount];+ for (int i = 0; i < transfer.length; i++) {+ transfer[i] = new plasmaDHTTransfer(log, seeds, dhtChunk,getConfig("indexDistribution.gzipBody","false").equalsIgnoreCase("true"),(int)getConfigLong("indexDistribution.timeout",60000), 0);- try {transfer.uploadIndex();} catch (InterruptedException e) {}-- if (transfer.getStatus() == plasmaDHTChunk.chunkStatus_COMPLETE) {+ transfer[i].start();+ }++ boolean DHTalive = true;+ while(DHTalive) {+ DHTalive = false;+ try {+ Thread.sleep(100);+ } catch (InterruptedException e) {+ // TODO Auto-generated catch block+ e.printStackTrace();+ }+ for (int i = 0; i < transfer.length; i++) {+ if (transfer[i].isAlive()) DHTalive = true;+ }+ }++ for (int i = 0; i < transfer.length; i++) {+ if (transfer[i].getStatus() == plasmaDHTChunk.chunkStatus_COMPLETE) {peerNames += ", " + seeds[i].getName();hc1++;}- if (hc1 >= peerCount) break;}+if (peerNames.length() > 0) peerNames = peerNames.substring(2); // remove comma// clean up and finish with deletion of indexes@@ -2154,7 +2168,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serthis.log.logSevere("Index distribution failed. Too few peers (" + hc1 + ") received the index, not deleted locally.");return false;}-+public void terminate() {this.terminate = true;this.shutdownSync.V();diff --git a/yacy.init b/yacy.initindex 096d96500..1a727f61a 100644--- a/yacy.init+++ b/yacy.init@@ -409,7 +409,6 @@ xpstopw=true20_dhtdistribution_idlesleep=2000020_dhtdistribution_busysleep=200020_dhtdistribution_memprereq=8388608-20_dhtdistribution_threads=130_peerping_idlesleep=12000030_peerping_busysleep=12000030_peerping_memprereq=1048576