- 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


git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6593 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
orbiter 15 years ago
parent 473b11033d
commit 234f733a3d

@ -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;
}

@ -757,7 +757,6 @@ public final class Switchboard extends serverSwitch {
synchronized (this) {
// shut down
this.crawler.close();
this.peers.close();
this.dhtDispatcher.close();
synchronized (this.indexSegments) {
this.indexSegments.close();
@ -786,11 +785,8 @@ public final class Switchboard extends serverSwitch {
// relocate
this.crawlQueues.relocate(this.queuesRoot); // cannot be closed because the busy threads are working with that object
final 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 names
setDefaultSegments();

@ -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 seed
removeMySeed();
lastSeedUpload_seedDBSize = sizeConnected();
this.lastSeedUpload_seedDBSize = sizeConnected();
// tell the httpdProxy how to find this table as address resolver
HTTPDemon.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;

Loading…
Cancel
Save