Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
*) old (lastseen > 7d) peers are now automatically removed from passive and potential seed-dbs
auron_x52cb3208d09a
diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.javaindex 6f35afa3c..3f8a3e047 100644--- a/source/de/anomic/plasma/plasmaSwitchboard.java+++ b/source/de/anomic/plasma/plasmaSwitchboard.java@@ -114,6 +114,7 @@ import java.net.MalformedURLException;import java.text.SimpleDateFormat;import java.util.ArrayList;import java.util.Date;+import java.util.Enumeration;import java.util.HashMap;import java.util.Hashtable;import java.util.Iterator;@@ -254,6 +255,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serpublic int totalPPM = 0;public double totalQPM = 0d;public TreeMap clusterhashes; // map of peerhash(String)/alternative-local-address as ip:port or only ip (String) or null if address in seed should be used+ public long maxLastSeen = 604800000; // maximum time (in ms) a peer may not have been seen before it is removed from passive and potential dbs/** Remote Proxy configuration@@ -1926,6 +1928,40 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serlog.logFine("Cleaning Incoming News, " + yacyCore.newsPool.size(yacyNewsPool.INCOMING_DB) + " entries on stack");if (yacyCore.newsPool.automaticProcess() > 0) hasDoneSomething = true;} catch (IOException e) {}++ // clean up seed-dbs+ if(!getConfigBool("never_delete_old_seeds",false)) {+ Enumeration e = yacyCore.seedDB.seedsSortedDisconnected(true,yacySeed.LASTSEEN);+ yacySeed seed = null;+ ArrayList deleteQueue = new ArrayList();+ checkInterruption();+ //clean passive seeds+ while(e.hasMoreElements()) {+ seed = (yacySeed)e.nextElement();+ if(seed != null) {+ //list is sorted -> break when peers are too young to delete+ if(seed.getLastSeenUTC() > (System.currentTimeMillis()-maxLastSeen))+ break;+ deleteQueue.add(seed.hash);+ }+ }+ for(int i=0;i<deleteQueue.size();++i) yacyCore.seedDB.removeDisconnected((String)deleteQueue.get(i));+ deleteQueue.clear();+ e = yacyCore.seedDB.seedsSortedPotential(true,yacySeed.LASTSEEN);+ checkInterruption();+ //clean potential seeds+ while(e.hasMoreElements()) {+ seed = (yacySeed)e.nextElement();+ if(seed != null) {+ //list is sorted -> break when peers are too young to delete+ if(seed.getLastSeenUTC() > (System.currentTimeMillis()-maxLastSeen))+ break;+ deleteQueue.add(seed.hash);+ }+ }+ for(int i=0;i<deleteQueue.size();++i) yacyCore.seedDB.removePotential((String)deleteQueue.get(i));+ }+// initiate broadcast about peer startup to spread supporter urlif (yacyCore.newsPool.size(yacyNewsPool.OUTGOING_DB) == 0) {diff --git a/source/de/anomic/yacy/yacySeedDB.java b/source/de/anomic/yacy/yacySeedDB.javaindex b662df43d..896db34b5 100644--- a/source/de/anomic/yacy/yacySeedDB.java+++ b/source/de/anomic/yacy/yacySeedDB.java@@ -462,6 +462,20 @@ public final class yacySeedDB {resetPotentialTable();}}++ public synchronized void removeDisconnected(String peerHash) {+ if(peerHash == null) return;+ try {+ seedPassiveDB.remove(peerHash);+ } catch (IOException e) { }+ }++ public synchronized void removePotential(String peerHash) {+ if(peerHash == null) return;+ try {+ seedPotentialDB.remove(peerHash);+ } catch (IOException e) { }+ }public boolean hasConnected(String hash) {try {diff --git a/yacy.init b/yacy.initindex 39aa57860..d28491f4b 100644--- a/yacy.init+++ b/yacy.init@@ -934,3 +934,6 @@ httpd.robots.txt = locked,dirs# class to use for parsing wikicodewikiParser.class = de.anomic.data.wikiCode++# if true the passive and potential Seed-dbs will never be cleaned from old (lastseen > 7 days) peers+never_delete_old_seeds = false\ No newline at end of file