Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
- relocation of seed db is better for network switch than re-initialization because of the embedding of the peers object in other objects - small refactoring of blacklist interface code to remove PMD warnings
orbiter234f733a3d35
diff --git a/htroot/Blacklist_p.java b/htroot/Blacklist_p.javaindex 419febf63..e9f73a00d 100644--- a/htroot/Blacklist_p.java+++ b/htroot/Blacklist_p.java@@ -114,8 +114,8 @@ public class Blacklist_p {* Creation of a new blacklist* =========================================================== */- blacklistToUse = post.get("newListName");- if (blacklistToUse.trim().length() == 0) {+ blacklistToUse = post.get("newListName", "").trim();+ if (blacklistToUse.length() == 0) {prop.put("LOCATION","");return prop;}@@ -160,7 +160,7 @@ public class Blacklist_p {* =========================================================== */blacklistToUse = post.get("selectedListName");- if (blacklistToUse == null || blacklistToUse.trim().length() == 0) {+ if (blacklistToUse == null || blacklistToUse.length() == 0) {prop.put("LOCATION","");return prop;}@@ -187,8 +187,8 @@ public class Blacklist_p {* Activate/Deactivate a blacklist* =========================================================== */- blacklistToUse = post.get("selectedListName");- if (blacklistToUse == null || blacklistToUse.trim().length() == 0) {+ blacklistToUse = post.get("selectedListName", "").trim();+ if (blacklistToUse == null || blacklistToUse.length() == 0) {prop.put("LOCATION", "");return prop;}@@ -209,8 +209,8 @@ public class Blacklist_p {* Share a blacklist* =========================================================== */- blacklistToUse = post.get("selectedListName");- if (blacklistToUse == null || blacklistToUse.trim().length() == 0) {+ blacklistToUse = post.get("selectedListName", "").trim();+ if (blacklistToUse == null || blacklistToUse.length() == 0) {prop.put("LOCATION", "");return prop;}@@ -227,7 +227,7 @@ public class Blacklist_p {* Delete an entry from a blacklist* =========================================================== */- blacklistToUse = post.get("currentBlacklist");+ blacklistToUse = post.get("currentBlacklist", "").trim();String temp = null;final String[] selectedBlacklistEntries = post.getAll("selectedEntry.*");@@ -249,9 +249,9 @@ public class Blacklist_p {* Add new entry to blacklist* =========================================================== */- blacklistToUse = post.get("currentBlacklist");+ blacklistToUse = post.get("currentBlacklist", "").trim();- final String temp = addBlacklistEntry(post.get("currentBlacklist"), post.get("newEntry"), header, supportedBlacklistTypes);+ final String temp = addBlacklistEntry(blacklistToUse, post.get("newEntry", "").trim(), header, supportedBlacklistTypes);if (temp != null) {prop.put("LOCATION", temp);return prop;@@ -264,7 +264,7 @@ public class Blacklist_p {* Move an entry from one blacklist to another* =========================================================== */- blacklistToUse = post.get("currentBlacklist");+ blacklistToUse = post.get("currentBlacklist", "").trim();String targetBlacklist = post.get("targetBlacklist");String temp = null;@@ -299,7 +299,7 @@ public class Blacklist_p {* Edit entry of a blacklist* =========================================================== */- blacklistToUse = post.get("currentBlacklist");+ blacklistToUse = post.get("currentBlacklist", "").trim();final String[] editedBlacklistEntries = post.getAll("editedBlacklistEntry.*");@@ -511,11 +511,11 @@ public class Blacklist_p {final RequestHeader header,final String[] supportedBlacklistTypes) {- if (blacklistToUse == null || blacklistToUse.trim().length() == 0) {+ if (blacklistToUse == null || blacklistToUse.length() == 0) {return "";}- if (newEntry == null || newEntry.trim().length() == 0) {+ if (newEntry == null || newEntry.length() == 0) {return header.get("PATH") + "?selectList=&selectedListName=" + blacklistToUse;}@@ -539,11 +539,11 @@ public class Blacklist_p {final RequestHeader header,final String[] supportedBlacklistTypes) {- if (blacklistToUse == null || blacklistToUse.trim().length() == 0) {+ if (blacklistToUse == null || blacklistToUse.length() == 0) {return "";}- if (oldEntry == null || oldEntry.trim().length() == 0) {+ if (oldEntry == null || oldEntry.length() == 0) {return header.get("PATH") + "?selectList=&selectedListName=" + blacklistToUse;}diff --git a/source/de/anomic/search/Switchboard.java b/source/de/anomic/search/Switchboard.javaindex b3f3fdc8e..2e91214d5 100644--- a/source/de/anomic/search/Switchboard.java+++ b/source/de/anomic/search/Switchboard.java@@ -757,7 +757,6 @@ public final class Switchboard extends serverSwitch {synchronized (this) {// shut downthis.crawler.close();- this.peers.close();this.dhtDispatcher.close();synchronized (this.indexSegments) {this.indexSegments.close();@@ -786,11 +785,8 @@ public final class Switchboard extends serverSwitch {// relocatethis.crawlQueues.relocate(this.queuesRoot); // cannot be closed because the busy threads are working with that objectfinal File mySeedFile = new File(this.networkRoot, yacySeedDB.DBFILE_OWN_SEED);- peers = new yacySeedDB(+ peers.relocate(this.networkRoot,- "seed.new.heap",- "seed.old.heap",- "seed.pot.heap",mySeedFile,redundancy,partitionExponent,@@ -802,6 +798,7 @@ public final class Switchboard extends serverSwitch {wordCacheMaxCount,fileSizeMax,this.useTailCache,+this.exceed134217727);// set the default segment namessetDefaultSegments();diff --git a/source/de/anomic/yacy/yacySeedDB.java b/source/de/anomic/yacy/yacySeedDB.javaindex 2456feaba..eda7ca88d 100644--- a/source/de/anomic/yacy/yacySeedDB.java+++ b/source/de/anomic/yacy/yacySeedDB.java@@ -88,7 +88,7 @@ public final class yacySeedDB implements AlternativeDomainNames {public yacyPeerActions peerActions;public yacyNewsPool newsPool;- private final int netRedundancy;+ private int netRedundancy;public PartitionScheme scheme;private yacySeed mySeed; // my own seed@@ -115,20 +115,20 @@ public final class yacySeedDB implements AlternativeDomainNames {this.scheme = new VerticalWordPartitionScheme(partitionExponent);// set up seed database- seedActiveDB = openSeedTable(seedActiveDBFile);- seedPassiveDB = openSeedTable(seedPassiveDBFile);- seedPotentialDB = openSeedTable(seedPotentialDBFile);+ this.seedActiveDB = openSeedTable(seedActiveDBFile);+ this.seedPassiveDB = openSeedTable(seedPassiveDBFile);+ this.seedPotentialDB = openSeedTable(seedPotentialDBFile);// start our virtual DNS service for yacy peers with empty cache- nameLookupCache = new Hashtable<String, String>();+ this.nameLookupCache = new Hashtable<String, String>();// cache for reverse name lookup- ipLookupCache = new Hashtable<InetAddress, SoftReference<yacySeed>>();+ this.ipLookupCache = new Hashtable<InetAddress, SoftReference<yacySeed>>();// check if we are in the seedCaches: this can happen if someone else published our seedremoveMySeed();- lastSeedUpload_seedDBSize = sizeConnected();+ this.lastSeedUpload_seedDBSize = sizeConnected();// tell the httpdProxy how to find this table as address resolverHTTPDemon.setAlternativeResolver(this);@@ -140,6 +140,55 @@ public final class yacySeedDB implements AlternativeDomainNames {this.peerActions = new yacyPeerActions(this, newsPool);}+ public void relocate(+ File newNetworkRoot,+ final File myOwnSeedFile,+ final int redundancy,+ final int partitionExponent,+ final boolean useTailCache,+ final boolean exceed134217727) {+ // close old databases+ this.seedActiveDB.close();+ this.seedPassiveDB.close();+ this.seedPotentialDB.close();+ this.newsPool.close();+ this.peerActions.close();++ // open new according to the newNetworkRoot+ this.seedActiveDBFile = new File(newNetworkRoot, seedActiveDBFile.getName());+ this.seedPassiveDBFile = new File(newNetworkRoot, seedPassiveDBFile.getName());+ this.seedPotentialDBFile = new File(newNetworkRoot, seedPotentialDBFile.getName());+ this.mySeed = null; // my own seed+ this.myOwnSeedFile = myOwnSeedFile;+ this.netRedundancy = redundancy;+ this.scheme = new VerticalWordPartitionScheme(partitionExponent);++ // set up seed database+ this.seedActiveDB = openSeedTable(seedActiveDBFile);+ this.seedPassiveDB = openSeedTable(seedPassiveDBFile);+ this.seedPotentialDB = openSeedTable(seedPotentialDBFile);++ // start our virtual DNS service for yacy peers with empty cache+ this.nameLookupCache.clear();++ // cache for reverse name lookup+ this.ipLookupCache.clear();++ // check if we are in the seedCaches: this can happen if someone else published our seed+ removeMySeed();++ this.lastSeedUpload_seedDBSize = sizeConnected();++ // tell the httpdProxy how to find this table as address resolver+ HTTPDemon.setAlternativeResolver(this);++ // create or init news database+ this.newsPool = new yacyNewsPool(newNetworkRoot, useTailCache, exceed134217727);++ // deploy peer actions+ this.peerActions = new yacyPeerActions(this, newsPool);+ }+private synchronized void initMySeed() {if (this.mySeed != null) return;