Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
* refactoring - moved constants from plasmaSwitchboard to own class (all 232 ;) - moved remoteProxy-Methods to httpRemoteProxyConfig, better names - removed some unnecessary code (else-statements) * formatting (correct indentation) * minor bugfixes (due to findbugs.sf.net) * hopefully fixed "missing quote" (announcing StringParts as UTF-8)
danielr17b7845eb5de
diff --git a/htroot/CacheAdmin_p.java b/htroot/CacheAdmin_p.javaindex fb85d1845..0390cc1d1 100644--- a/htroot/CacheAdmin_p.java+++ b/htroot/CacheAdmin_p.java@@ -47,6 +47,7 @@ import de.anomic.http.httpHeader;import de.anomic.plasma.plasmaHTCache;import de.anomic.plasma.plasmaParserDocument;import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.plasma.plasmaSwitchboardConstants;import de.anomic.plasma.cache.IResourceInfo;import de.anomic.plasma.cache.UnsupportedProtocolException;import de.anomic.server.serverFileUtils;@@ -192,7 +193,7 @@ public class CacheAdmin_p {}// generate sorted dir/file listing- final String[] list = dir.list(new Filter(switchboard.getConfigPath(plasmaSwitchboard.HTCACHE_PATH, plasmaSwitchboard.HTCACHE_PATH_DEFAULT)));+ final String[] list = dir.list(new Filter(switchboard.getConfigPath(plasmaSwitchboardConstants.HTCACHE_PATH, plasmaSwitchboardConstants.HTCACHE_PATH_DEFAULT)));tree.ensureCapacity((list == null) ? 70 : (list.length + 1) * 256);linkPathString(prop, ((pathString.length() == 0) ? ("/") : (pathString)), true);if (list == null) {@@ -202,7 +203,7 @@ public class CacheAdmin_p {final TreeSet<String> dList = new TreeSet<String>();final TreeSet<String> fList = new TreeSet<String>();final int size = list.length - 1;- int i;+ int i;for (i = size; i >= 0 ; i--) { // Rueckwaerts ist schnellerif (new File(dir, list[i]).isDirectory())dList.add(list[i]);diff --git a/htroot/CacheResource_p.java b/htroot/CacheResource_p.javaindex 7e1593f10..3c9cd6522 100644--- a/htroot/CacheResource_p.java+++ b/htroot/CacheResource_p.java@@ -29,6 +29,7 @@ import java.io.IOException;import de.anomic.http.httpHeader;import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.plasma.plasmaSwitchboardConstants;import de.anomic.server.serverFileUtils;import de.anomic.server.serverObjects;import de.anomic.server.serverSwitch;@@ -42,7 +43,7 @@ public class CacheResource_p {final String path = ((post == null) ? "" : post.get("path", ""));// we dont need check the path, because we have do that in plasmaSwitchboard.java - Borg-0300- final File cache = switchboard.getConfigPath(plasmaSwitchboard.HTCACHE_PATH, plasmaSwitchboard.HTCACHE_PATH_DEFAULT);+ final File cache = switchboard.getConfigPath(plasmaSwitchboardConstants.HTCACHE_PATH, plasmaSwitchboardConstants.HTCACHE_PATH_DEFAULT);final File f = new File(cache, path);byte[] resource;diff --git a/htroot/ConfigBasic.java b/htroot/ConfigBasic.javaindex fba9e3cb5..f924b1ebd 100644--- a/htroot/ConfigBasic.java+++ b/htroot/ConfigBasic.java@@ -35,6 +35,7 @@ import de.anomic.http.httpHeader;import de.anomic.http.httpd;import de.anomic.http.httpdFileHandler;import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.plasma.plasmaSwitchboardConstants;import de.anomic.server.serverCore;import de.anomic.server.serverDomains;import de.anomic.server.serverInstantBusyThread;@@ -139,22 +140,22 @@ public class ConfigBasic {// switch to freeworld networksb.switchNetwork("defaults/yacy.network.freeworld.unit");// switch to p2p mode- sb.setConfig(plasmaSwitchboard.INDEX_DIST_ALLOW, true);- sb.setConfig(plasmaSwitchboard.INDEX_RECEIVE_ALLOW, true);+ sb.setConfig(plasmaSwitchboardConstants.INDEX_DIST_ALLOW, true);+ sb.setConfig(plasmaSwitchboardConstants.INDEX_RECEIVE_ALLOW, true);}if (post.get("usecase", "").equals("portal") && !networkName.equals("webportal")) {// switch to webportal networksb.switchNetwork("defaults/yacy.network.webportal.unit");// switch to robinson mode- sb.setConfig(plasmaSwitchboard.INDEX_DIST_ALLOW, false);- sb.setConfig(plasmaSwitchboard.INDEX_RECEIVE_ALLOW, false);+ sb.setConfig(plasmaSwitchboardConstants.INDEX_DIST_ALLOW, false);+ sb.setConfig(plasmaSwitchboardConstants.INDEX_RECEIVE_ALLOW, false);}if (post.get("usecase", "").equals("intranet") && !networkName.equals("intranet")) {// switch to intranet networksb.switchNetwork("defaults/yacy.network.intranet.unit");// switch to p2p mode: enable ad-hoc networks between intranet users- sb.setConfig(plasmaSwitchboard.INDEX_DIST_ALLOW, true);- sb.setConfig(plasmaSwitchboard.INDEX_RECEIVE_ALLOW, true);+ sb.setConfig(plasmaSwitchboardConstants.INDEX_DIST_ALLOW, true);+ sb.setConfig(plasmaSwitchboardConstants.INDEX_RECEIVE_ALLOW, true);}}diff --git a/htroot/ConfigNetwork_p.java b/htroot/ConfigNetwork_p.javaindex 841c67c13..c2f3ab12f 100644--- a/htroot/ConfigNetwork_p.java+++ b/htroot/ConfigNetwork_p.java@@ -31,6 +31,7 @@ import java.util.HashSet;import de.anomic.http.httpHeader;import de.anomic.http.httpd;import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.plasma.plasmaSwitchboardConstants;import de.anomic.server.serverBusyThread;import de.anomic.server.serverCodings;import de.anomic.server.serverFileUtils;@@ -104,28 +105,28 @@ public class ConfigNetwork_p {}if (indexDistribute) {- sb.setConfig(plasmaSwitchboard.INDEX_DIST_ALLOW, true);+ sb.setConfig(plasmaSwitchboardConstants.INDEX_DIST_ALLOW, true);} else {- sb.setConfig(plasmaSwitchboard.INDEX_DIST_ALLOW, false);+ sb.setConfig(plasmaSwitchboardConstants.INDEX_DIST_ALLOW, false);}if (post.get("indexDistributeWhileCrawling","").equals("on")) {- sb.setConfig(plasmaSwitchboard.INDEX_DIST_ALLOW_WHILE_CRAWLING, true);+ sb.setConfig(plasmaSwitchboardConstants.INDEX_DIST_ALLOW_WHILE_CRAWLING, true);} else {- sb.setConfig(plasmaSwitchboard.INDEX_DIST_ALLOW_WHILE_CRAWLING, false);+ sb.setConfig(plasmaSwitchboardConstants.INDEX_DIST_ALLOW_WHILE_CRAWLING, false);}if (post.get("indexDistributeWhileIndexing","").equals("on")) {- sb.setConfig(plasmaSwitchboard.INDEX_DIST_ALLOW_WHILE_INDEXING, true);+ sb.setConfig(plasmaSwitchboardConstants.INDEX_DIST_ALLOW_WHILE_INDEXING, true);} else {- sb.setConfig(plasmaSwitchboard.INDEX_DIST_ALLOW_WHILE_INDEXING, false);+ sb.setConfig(plasmaSwitchboardConstants.INDEX_DIST_ALLOW_WHILE_INDEXING, false);}if (indexReceive) {- sb.setConfig(plasmaSwitchboard.INDEX_RECEIVE_ALLOW, true);+ sb.setConfig(plasmaSwitchboardConstants.INDEX_RECEIVE_ALLOW, true);sb.webIndex.seedDB.mySeed().setFlagAcceptRemoteIndex(true);} else {- sb.setConfig(plasmaSwitchboard.INDEX_RECEIVE_ALLOW, false);+ sb.setConfig(plasmaSwitchboardConstants.INDEX_RECEIVE_ALLOW, false);sb.webIndex.seedDB.mySeed().setFlagAcceptRemoteIndex(false);}@@ -148,9 +149,9 @@ public class ConfigNetwork_p {newppm = Math.max(1, Integer.parseInt(post.get("acceptCrawlLimit", "1")));} catch (final NumberFormatException e) {}final long newBusySleep = Math.max(100, 60000 / newppm);- final serverBusyThread rct = sb.getThread(plasmaSwitchboard.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);+ final serverBusyThread rct = sb.getThread(plasmaSwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);rct.setBusySleep(newBusySleep);- sb.setConfig(plasmaSwitchboard.CRAWLJOB_REMOTE_TRIGGERED_CRAWL_BUSYSLEEP, Long.toString(newBusySleep));+ sb.setConfig(plasmaSwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL_BUSYSLEEP, Long.toString(newBusySleep));sb.setConfig("cluster.peers.ipport", checkIPPortList(post.get("cluster.peers.ipport", "")));sb.setConfig("cluster.peers.yacydomain", checkYaCyDomainList(post.get("cluster.peers.yacydomain", "")));@@ -167,18 +168,18 @@ public class ConfigNetwork_p {prop.put("crawlResponse", sb.getConfigBool("crawlResponse", false) ? "1" : "0");long RTCbusySleep = 100;try {- RTCbusySleep = Math.max(1, Integer.parseInt(env.getConfig(plasmaSwitchboard.CRAWLJOB_REMOTE_TRIGGERED_CRAWL_BUSYSLEEP, "100")));+ RTCbusySleep = Math.max(1, Integer.parseInt(env.getConfig(plasmaSwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL_BUSYSLEEP, "100")));} catch (final NumberFormatException e) {}final int RTCppm = (int) (60000L / RTCbusySleep);prop.put("acceptCrawlLimit", RTCppm);- final boolean indexDistribute = sb.getConfig(plasmaSwitchboard.INDEX_DIST_ALLOW, "true").equals("true");- final boolean indexReceive = sb.getConfig(plasmaSwitchboard.INDEX_RECEIVE_ALLOW, "true").equals("true");+ final boolean indexDistribute = sb.getConfig(plasmaSwitchboardConstants.INDEX_DIST_ALLOW, "true").equals("true");+ final boolean indexReceive = sb.getConfig(plasmaSwitchboardConstants.INDEX_RECEIVE_ALLOW, "true").equals("true");prop.put("indexDistributeChecked", (indexDistribute) ? "1" : "0");- prop.put("indexDistributeWhileCrawling.on", (sb.getConfig(plasmaSwitchboard.INDEX_DIST_ALLOW_WHILE_CRAWLING, "true").equals("true")) ? "1" : "0");- prop.put("indexDistributeWhileCrawling.off", (sb.getConfig(plasmaSwitchboard.INDEX_DIST_ALLOW_WHILE_CRAWLING, "true").equals("true")) ? "0" : "1");- prop.put("indexDistributeWhileIndexing.on", (sb.getConfig(plasmaSwitchboard.INDEX_DIST_ALLOW_WHILE_INDEXING, "true").equals("true")) ? "1" : "0");- prop.put("indexDistributeWhileIndexing.off", (sb.getConfig(plasmaSwitchboard.INDEX_DIST_ALLOW_WHILE_INDEXING, "true").equals("true")) ? "0" : "1");+ prop.put("indexDistributeWhileCrawling.on", (sb.getConfig(plasmaSwitchboardConstants.INDEX_DIST_ALLOW_WHILE_CRAWLING, "true").equals("true")) ? "1" : "0");+ prop.put("indexDistributeWhileCrawling.off", (sb.getConfig(plasmaSwitchboardConstants.INDEX_DIST_ALLOW_WHILE_CRAWLING, "true").equals("true")) ? "0" : "1");+ prop.put("indexDistributeWhileIndexing.on", (sb.getConfig(plasmaSwitchboardConstants.INDEX_DIST_ALLOW_WHILE_INDEXING, "true").equals("true")) ? "1" : "0");+ prop.put("indexDistributeWhileIndexing.off", (sb.getConfig(plasmaSwitchboardConstants.INDEX_DIST_ALLOW_WHILE_INDEXING, "true").equals("true")) ? "0" : "1");prop.put("indexReceiveChecked", (indexReceive) ? "1" : "0");prop.put("indexReceiveBlockBlacklistChecked.on", (sb.getConfig("indexReceiveBlockBlacklist", "true").equals("true")) ? "1" : "0");prop.put("indexReceiveBlockBlacklistChecked.off", (sb.getConfig("indexReceiveBlockBlacklist", "true").equals("true")) ? "0" : "1");@@ -232,7 +233,8 @@ public class ConfigNetwork_p {if ((s[i].endsWith(".yacyh")) || (s[i].endsWith(".yacy")) ||(s[i].indexOf(".yacyh=") > 0) || (s[i].indexOf(".yacy=") > 0)) input += "," + s[i];}- if (input.length() == 0) return input; else return input.substring(1);+ if (input.length() == 0) return input;+ return input.substring(1);}public static String checkIPPortList(String input) {@@ -242,6 +244,7 @@ public class ConfigNetwork_p {for (int i = 0; i < s.length; i++) {if (s[i].indexOf(':') >= 9) input += "," + s[i];}- if (input.length() == 0) return input; else return input.substring(1);+ if (input.length() == 0) return input;+ return input.substring(1);}}diff --git a/htroot/ConfigRobotsTxt_p.java b/htroot/ConfigRobotsTxt_p.javaindex 75b3a225f..3d4f944ae 100644--- a/htroot/ConfigRobotsTxt_p.java+++ b/htroot/ConfigRobotsTxt_p.java@@ -32,6 +32,7 @@import de.anomic.http.httpHeader;import de.anomic.http.httpdRobotsTxtConfig;import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.plasma.plasmaSwitchboardConstants;import de.anomic.server.serverObjects;import de.anomic.server.serverSwitch;import de.anomic.server.servletProperties;@@ -60,7 +61,7 @@ public class ConfigRobotsTxt_p {rbc.setSurftipsDisallowed(post.containsKey(httpdRobotsTxtConfig.SURFTIPS));rbc.setWikiDisallowed(post.containsKey(httpdRobotsTxtConfig.WIKI));rbc.setProfileDisallowed(post.containsKey(httpdRobotsTxtConfig.PROFILE));- env.setConfig(plasmaSwitchboard.ROBOTS_TXT, rbc.toString());+ env.setConfig(plasmaSwitchboardConstants.ROBOTS_TXT, rbc.toString());}}diff --git a/htroot/CrawlResults.java b/htroot/CrawlResults.javaindex a15b80acb..045110773 100644--- a/htroot/CrawlResults.java+++ b/htroot/CrawlResults.java@@ -270,8 +270,7 @@ public class CrawlResults {private static String daydate(final Date date) {if (date == null) {return "";- } else {- return dayFormatter.format(date);}+ return dayFormatter.format(date);}}diff --git a/htroot/CrawlStart_p.java b/htroot/CrawlStart_p.javaindex 49b8d792f..616b6316c 100644--- a/htroot/CrawlStart_p.java+++ b/htroot/CrawlStart_p.java@@ -25,7 +25,7 @@// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USAimport de.anomic.http.httpHeader;-import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.plasma.plasmaSwitchboardConstants;import de.anomic.server.serverObjects;import de.anomic.server.serverSwitch;@@ -74,7 +74,7 @@ public class CrawlStart_p {prop.put("indexingMediaChecked", env.getConfig("indexMedia", "").equals("true") ? "1" : "0");prop.put("crawlOrderChecked", env.getConfig("crawlOrder", "").equals("true") ? "1" : "0");- final long LCbusySleep = Integer.parseInt(env.getConfig(plasmaSwitchboard.CRAWLJOB_LOCAL_CRAWL_BUSYSLEEP, "100"));+ final long LCbusySleep = Integer.parseInt(env.getConfig(plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL_BUSYSLEEP, "100"));final int LCppm = (LCbusySleep == 0) ? 1000 : (int) (60000L / LCbusySleep);prop.put("crawlingSpeedMaxChecked", (LCppm >= 1000) ? "1" : "0");prop.put("crawlingSpeedCustChecked", ((LCppm > 10) && (LCppm < 1000)) ? "1" : "0");diff --git a/htroot/IndexShare_p.java b/htroot/IndexShare_p.javaindex 60d7c9b66..a5851e9a7 100644--- a/htroot/IndexShare_p.java+++ b/htroot/IndexShare_p.java@@ -30,6 +30,7 @@//import de.anomic.tools.*;import de.anomic.http.httpHeader;import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.plasma.plasmaSwitchboardConstants;import de.anomic.server.serverObjects;import de.anomic.server.serverSwitch;@@ -51,7 +52,7 @@ public class IndexShare_p {}if (post.containsKey("indexsharesetting")) {- switchboard.setConfig(plasmaSwitchboard.INDEX_DIST_ALLOW, (post.containsKey("distribute")) ? "true" : "false");+ switchboard.setConfig(plasmaSwitchboardConstants.INDEX_DIST_ALLOW, (post.containsKey("distribute")) ? "true" : "false");switchboard.setConfig("allowReceiveIndex", (post.containsKey("receive")) ? "true" : "false");switchboard.setConfig("defaultLinkReceiveFrequency", post.get("linkfreq", "30"));switchboard.setConfig("defaultWordReceiveFrequency", post.get("wordfreq", "10"));diff --git a/htroot/PeerLoadPicture.java b/htroot/PeerLoadPicture.javaindex 24aae7a90..51b6a3bd3 100644--- a/htroot/PeerLoadPicture.java+++ b/htroot/PeerLoadPicture.java@@ -5,7 +5,7 @@ import java.util.Iterator;import de.anomic.http.httpHeader;import de.anomic.plasma.plasmaGrafics;-import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.plasma.plasmaSwitchboardConstants;import de.anomic.plasma.plasmaGrafics.CircleThreadPiece;import de.anomic.server.serverBusyThread;import de.anomic.server.serverObjects;@@ -29,10 +29,10 @@ public class PeerLoadPicture {final CircleThreadPiece misc = new CircleThreadPiece("Misc.", new Color(190, 50, 180));final HashMap<String, CircleThreadPiece> pieces = new HashMap<String, CircleThreadPiece>();pieces.put(null, idle);- pieces.put(plasmaSwitchboard.CRAWLSTACK, new CircleThreadPiece("Stacking", new Color(115, 200, 210)));- pieces.put(plasmaSwitchboard.INDEXER, new CircleThreadPiece("Parsing/Indexing", new Color(255, 130, 0)));- pieces.put(plasmaSwitchboard.INDEX_DIST, new CircleThreadPiece("DHT-Distribution", new Color(119, 136, 153)));- pieces.put(plasmaSwitchboard.PEER_PING, new CircleThreadPiece("YaCy Core", new Color(255, 230, 160)));+ pieces.put(plasmaSwitchboardConstants.CRAWLSTACK, new CircleThreadPiece("Stacking", new Color(115, 200, 210)));+ pieces.put(plasmaSwitchboardConstants.INDEXER, new CircleThreadPiece("Parsing/Indexing", new Color(255, 130, 0)));+ pieces.put(plasmaSwitchboardConstants.INDEX_DIST, new CircleThreadPiece("DHT-Distribution", new Color(119, 136, 153)));+ pieces.put(plasmaSwitchboardConstants.PEER_PING, new CircleThreadPiece("YaCy Core", new Color(255, 230, 160)));final Iterator<String> threads = env.threadNames();String threadname;diff --git a/htroot/PerformanceQueues_p.java b/htroot/PerformanceQueues_p.javaindex 6120be808..f3d8be840 100644--- a/htroot/PerformanceQueues_p.java+++ b/htroot/PerformanceQueues_p.java@@ -31,6 +31,7 @@ import java.util.Map;import de.anomic.http.httpHeader;import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.plasma.plasmaSwitchboardConstants;import de.anomic.server.serverBusyThread;import de.anomic.server.serverCore;import de.anomic.server.serverFileUtils;@@ -96,7 +97,7 @@ public class PerformanceQueues_p {final boolean setProfile = (post != null && post.containsKey("submitdefault"));final boolean setDelay = (post != null) && (post.containsKey("submitdelay"));// save used settings file to config- if (setProfile) switchboard.setConfig("performanceProfile", post.get("defaultFile", "defaults/yacy.init"));+ if (setProfile && post != null) switchboard.setConfig("performanceProfile", post.get("defaultFile", "defaults/yacy.init"));while (threads.hasNext()) {threadName = threads.next();@@ -141,7 +142,7 @@ public class PerformanceQueues_p {idlesleep = switchboard.getConfigLong(threadName + "_idlesleep" , 1000);busysleep = switchboard.getConfigLong(threadName + "_busysleep", 100);memprereq = switchboard.getConfigLong(threadName + "_memprereq", 0);- if (setDelay) {+ if (setDelay && post != null) {// load with new valuesidlesleep = post.getLong(threadName + "_idlesleep", idlesleep);busysleep = post.getLong(threadName + "_busysleep", busysleep);@@ -192,11 +193,11 @@ public class PerformanceQueues_p {if ((post != null) && (post.containsKey("cacheSizeSubmit"))) {final int wordCacheMaxCount = post.getInt("wordCacheMaxCount", 20000);- switchboard.setConfig(plasmaSwitchboard.WORDCACHE_MAX_COUNT, Integer.toString(wordCacheMaxCount));+ switchboard.setConfig(plasmaSwitchboardConstants.WORDCACHE_MAX_COUNT, Integer.toString(wordCacheMaxCount));switchboard.webIndex.setMaxWordCount(wordCacheMaxCount);- final int wordCacheInitCount = post.getInt(plasmaSwitchboard.WORDCACHE_INIT_COUNT, 30000);- switchboard.setConfig(plasmaSwitchboard.WORDCACHE_INIT_COUNT, Integer.toString(wordCacheInitCount));+ final int wordCacheInitCount = post.getInt(plasmaSwitchboardConstants.WORDCACHE_INIT_COUNT, 30000);+ switchboard.setConfig(plasmaSwitchboardConstants.WORDCACHE_INIT_COUNT, Integer.toString(wordCacheInitCount));}if ((post != null) && (post.containsKey("poolConfig"))) {@@ -208,7 +209,7 @@ public class PerformanceQueues_p {int maxBusy = Integer.parseInt(post.get("Crawler Pool_maxActive","8"));// storing the new values into configfile- switchboard.setConfig(plasmaSwitchboard.CRAWLER_THREADS_ACTIVE_MAX,maxBusy);+ switchboard.setConfig(plasmaSwitchboardConstants.CRAWLER_THREADS_ACTIVE_MAX,maxBusy);//switchboard.setConfig("crawler.MinIdleThreads",minIdle);/*@@ -233,9 +234,9 @@ public class PerformanceQueues_p {}if ((post != null) && (post.containsKey("onlineCautionSubmit"))) {- switchboard.setConfig(plasmaSwitchboard.PROXY_ONLINE_CAUTION_DELAY, Integer.toString(post.getInt("crawlPauseProxy", 30000)));- switchboard.setConfig(plasmaSwitchboard.LOCALSEACH_ONLINE_CAUTION_DELAY, Integer.toString(post.getInt("crawlPauseLocalsearch", 30000)));- switchboard.setConfig(plasmaSwitchboard.REMOTESEARCH_ONLINE_CAUTION_DELAY, Integer.toString(post.getInt("crawlPauseRemotesearch", 30000)));+ switchboard.setConfig(plasmaSwitchboardConstants.PROXY_ONLINE_CAUTION_DELAY, Integer.toString(post.getInt("crawlPauseProxy", 30000)));+ switchboard.setConfig(plasmaSwitchboardConstants.LOCALSEACH_ONLINE_CAUTION_DELAY, Integer.toString(post.getInt("crawlPauseLocalsearch", 30000)));+ switchboard.setConfig(plasmaSwitchboardConstants.REMOTESEARCH_ONLINE_CAUTION_DELAY, Integer.toString(post.getInt("crawlPauseRemotesearch", 30000)));}if ((post != null) && (post.containsKey("minimumDeltaSubmit"))) {@@ -264,11 +265,11 @@ public class PerformanceQueues_p {prop.putNum("minAgeOfWCache", switchboard.webIndex.minAgeOfDHTOutCache() / 1000 / 60); // minutesprop.putNum("minAgeOfKCache", switchboard.webIndex.minAgeOfDHTInCache() / 1000 / 60); // minutesprop.putNum("maxWaitingWordFlush", switchboard.getConfigLong("maxWaitingWordFlush", 180));- prop.put("wordCacheMaxCount", switchboard.getConfigLong(plasmaSwitchboard.WORDCACHE_MAX_COUNT, 20000));- prop.put("wordCacheInitCount", switchboard.getConfigLong(plasmaSwitchboard.WORDCACHE_INIT_COUNT, 30000));- prop.put("crawlPauseProxy", switchboard.getConfigLong(plasmaSwitchboard.PROXY_ONLINE_CAUTION_DELAY, 30000));- prop.put("crawlPauseLocalsearch", switchboard.getConfigLong(plasmaSwitchboard.LOCALSEACH_ONLINE_CAUTION_DELAY, 30000));- prop.put("crawlPauseRemotesearch", switchboard.getConfigLong(plasmaSwitchboard.REMOTESEARCH_ONLINE_CAUTION_DELAY, 30000));+ prop.put("wordCacheMaxCount", switchboard.getConfigLong(plasmaSwitchboardConstants.WORDCACHE_MAX_COUNT, 20000));+ prop.put("wordCacheInitCount", switchboard.getConfigLong(plasmaSwitchboardConstants.WORDCACHE_INIT_COUNT, 30000));+ prop.put("crawlPauseProxy", switchboard.getConfigLong(plasmaSwitchboardConstants.PROXY_ONLINE_CAUTION_DELAY, 30000));+ prop.put("crawlPauseLocalsearch", switchboard.getConfigLong(plasmaSwitchboardConstants.LOCALSEACH_ONLINE_CAUTION_DELAY, 30000));+ prop.put("crawlPauseRemotesearch", switchboard.getConfigLong(plasmaSwitchboardConstants.REMOTESEARCH_ONLINE_CAUTION_DELAY, 30000));prop.putNum("crawlPauseProxyCurrent", (System.currentTimeMillis() - switchboard.proxyLastAccess) / 1000);prop.putNum("crawlPauseLocalsearchCurrent", (System.currentTimeMillis() - switchboard.localSearchLastAccess) / 1000);prop.putNum("crawlPauseRemotesearchCurrent", (System.currentTimeMillis() - switchboard.remoteSearchLastAccess) / 1000);diff --git a/htroot/ProxyIndexingMonitor_p.java b/htroot/ProxyIndexingMonitor_p.javaindex ed9b7633e..30a4515ba 100644--- a/htroot/ProxyIndexingMonitor_p.java+++ b/htroot/ProxyIndexingMonitor_p.java@@ -32,6 +32,7 @@ import java.io.IOException;import de.anomic.http.httpHeader;import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.plasma.plasmaSwitchboardConstants;import de.anomic.server.serverObjects;import de.anomic.server.serverSwitch;import de.anomic.server.logging.serverLog;@@ -76,14 +77,14 @@ public class ProxyIndexingMonitor_p {// added proxyCache, proxyCacheSize - Borg-0300// proxyCache - check and create the directory- oldProxyCachePath = env.getConfig(plasmaSwitchboard.HTCACHE_PATH, plasmaSwitchboard.HTCACHE_PATH_DEFAULT);- newProxyCachePath = post.get("proxyCache", plasmaSwitchboard.HTCACHE_PATH_DEFAULT);+ oldProxyCachePath = env.getConfig(plasmaSwitchboardConstants.HTCACHE_PATH, plasmaSwitchboardConstants.HTCACHE_PATH_DEFAULT);+ newProxyCachePath = post.get("proxyCache", plasmaSwitchboardConstants.HTCACHE_PATH_DEFAULT);newProxyCachePath = newProxyCachePath.replace('\\', '/');if (newProxyCachePath.endsWith("/")) {newProxyCachePath = newProxyCachePath.substring(0, newProxyCachePath.length() - 1);}- env.setConfig(plasmaSwitchboard.HTCACHE_PATH, newProxyCachePath);- final File cache = env.getConfigPath(plasmaSwitchboard.HTCACHE_PATH, oldProxyCachePath);+ env.setConfig(plasmaSwitchboardConstants.HTCACHE_PATH, newProxyCachePath);+ final File cache = env.getConfigPath(plasmaSwitchboardConstants.HTCACHE_PATH, oldProxyCachePath);if (!cache.isDirectory() && !cache.isFile()) cache.mkdirs();// proxyCacheSize@@ -150,7 +151,7 @@ public class ProxyIndexingMonitor_p {prop.put("proxyIndexingRemote", env.getConfig("proxyIndexingRemote", "").equals("true") ? "1" : "0");prop.put("proxyIndexingLocalText", env.getConfig("proxyIndexingLocalText", "").equals("true") ? "1" : "0");prop.put("proxyIndexingLocalMedia", env.getConfig("proxyIndexingLocalMedia", "").equals("true") ? "1" : "0");- prop.put("proxyCache", env.getConfig(plasmaSwitchboard.HTCACHE_PATH, plasmaSwitchboard.HTCACHE_PATH_DEFAULT));+ prop.put("proxyCache", env.getConfig(plasmaSwitchboardConstants.HTCACHE_PATH, plasmaSwitchboardConstants.HTCACHE_PATH_DEFAULT));prop.put("proxyCacheSize", env.getConfig("proxyCacheSize", "64"));// return rewrite propertiesreturn prop;diff --git a/htroot/QuickCrawlLink_p.java b/htroot/QuickCrawlLink_p.javaindex eee6d239c..53befcf75 100644--- a/htroot/QuickCrawlLink_p.java+++ b/htroot/QuickCrawlLink_p.java@@ -65,7 +65,7 @@ public class QuickCrawlLink_p {//String host = hostSocket;int port = 80;- final int pos = hostSocket.indexOf(":");+ final int pos = hostSocket.indexOf(":");if (pos != -1) {port = Integer.parseInt(hostSocket.substring(pos + 1));//host = hostSocket.substring(0, pos);diff --git a/htroot/SettingsAck_p.java b/htroot/SettingsAck_p.javaindex e67994632..822684aa5 100644--- a/htroot/SettingsAck_p.java+++ b/htroot/SettingsAck_p.java@@ -350,22 +350,7 @@ public class SettingsAck_p {/* ====================================================================* Enabling settings* ==================================================================== */- httpdProxyHandler.setRemoteProxyConfig(httpRemoteProxyConfig.init(sb));--// httpdProxyHandler.remoteProxyUse = post.get("remoteProxyUse", "").equals("on");-// httpdProxyHandler.remoteProxyHost = post.get("remoteProxyHost", "");-// try {-// httpdProxyHandler.remoteProxyPort = Integer.parseInt((String) post.get("remoteProxyPort", ""));-// } catch (NumberFormatException e) {-// httpdProxyHandler.remoteProxyPort = 3128;-// }-// httpdProxyHandler.remoteProxyNoProxy = (String) post.get("remoteProxyNoProxy", "");-// httpdProxyHandler.remoteProxyNoProxyPatterns = httpdProxyHandler.remoteProxyNoProxy.split(",");-// env.setConfig("remoteProxyHost", httpdProxyHandler.remoteProxyHost);-// env.setConfig("remoteProxyPort", Integer.toString(httpdProxyHandler.remoteProxyPort));-// env.setConfig("remoteProxyNoProxy", httpdProxyHandler.remoteProxyNoProxy);-// env.setConfig("remoteProxyUse", (httpdProxyHandler.remoteProxyUse) ? "true" : "false");-+ httpRemoteProxyConfig.init(sb);prop.put("info", "15"); // The remote-proxy setting has been changedreturn prop;@@ -439,6 +424,8 @@ public class SettingsAck_p {for (int i=0; i<configOptions.length; i++) {final String newSettings = post.get(configOptions[i],"");final String oldSettings = env.getConfig(configOptions[i],"");+ // FIXME should this be: nC = nC && newSettings.equals()+ // or (current): nC = nC & newSettings.equals()nothingChanged &= newSettings.equals(oldSettings);if (!nothingChanged) {env.setConfig(configOptions[i],newSettings);diff --git a/htroot/Status.java b/htroot/Status.javaindex 4b0769a99..08a7ad25d 100644--- a/htroot/Status.java+++ b/htroot/Status.java@@ -34,6 +34,7 @@ import de.anomic.http.httpd;import de.anomic.http.httpdByteCountInputStream;import de.anomic.http.httpdByteCountOutputStream;import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.plasma.plasmaSwitchboardConstants;import de.anomic.server.serverCore;import de.anomic.server.serverDate;import de.anomic.server.serverDomains;@@ -67,16 +68,16 @@ public class Status {} else if (post.containsKey("pauseCrawlJob")) {final String jobType = post.get("jobType");if (jobType.equals("localCrawl"))- sb.pauseCrawlJob(plasmaSwitchboard.CRAWLJOB_LOCAL_CRAWL);+ sb.pauseCrawlJob(plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL);else if (jobType.equals("remoteTriggeredCrawl"))- sb.pauseCrawlJob(plasmaSwitchboard.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);+ sb.pauseCrawlJob(plasmaSwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);redirect = true;} else if (post.containsKey("continueCrawlJob")) {final String jobType = post.get("jobType");if (jobType.equals("localCrawl"))- sb.continueCrawlJob(plasmaSwitchboard.CRAWLJOB_LOCAL_CRAWL);+ sb.continueCrawlJob(plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL);else if (jobType.equals("remoteTriggeredCrawl"))- sb.continueCrawlJob(plasmaSwitchboard.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);+ sb.continueCrawlJob(plasmaSwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);redirect = true;} else if (post.containsKey("ResetTraffic")) {httpdByteCountInputStream.resetCount();@@ -144,11 +145,11 @@ public class Status {try {thisVersion = Math.round(thisVersion*1000.0)/1000.0;} catch (final NumberFormatException e) {}// place some more hints- if ((adminaccess) && (sb.getThread(plasmaSwitchboard.CRAWLJOB_LOCAL_CRAWL).getJobCount() == 0) && (sb.getThread(plasmaSwitchboard.INDEXER).getJobCount() == 0)) {+ if ((adminaccess) && (sb.getThread(plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL).getJobCount() == 0) && (sb.getThread(plasmaSwitchboardConstants.INDEXER).getJobCount() == 0)) {prop.put("hintCrawlStart", "1");}- if ((adminaccess) && (sb.getThread(plasmaSwitchboard.CRAWLJOB_LOCAL_CRAWL).getJobCount() > 500)) {+ if ((adminaccess) && (sb.getThread(plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL).getJobCount() > 500)) {prop.put("hintCrawlMonitor", "1");}@@ -295,24 +296,24 @@ public class Status {// Queue informationfinal int indexingJobCount = sb.getThread("80_indexing").getJobCount() + sb.webIndex.queuePreStack.getActiveQueueSize();- final int indexingMaxCount = (int) sb.getConfigLong(plasmaSwitchboard.INDEXER_SLOTS, 30);+ final int indexingMaxCount = (int) sb.getConfigLong(plasmaSwitchboardConstants.INDEXER_SLOTS, 30);final int indexingPercent = (indexingMaxCount==0)?0:indexingJobCount*100/indexingMaxCount;prop.putNum("indexingQueueSize", indexingJobCount);prop.putNum("indexingQueueMax", indexingMaxCount);prop.put("indexingQueuePercent",(indexingPercent>100) ? 100 : indexingPercent);final int loaderJobCount = sb.crawlQueues.size();- final int loaderMaxCount = Integer.parseInt(sb.getConfig(plasmaSwitchboard.CRAWLER_THREADS_ACTIVE_MAX, "10"));+ final int loaderMaxCount = Integer.parseInt(sb.getConfig(plasmaSwitchboardConstants.CRAWLER_THREADS_ACTIVE_MAX, "10"));final int loaderPercent = (loaderMaxCount==0)?0:loaderJobCount*100/loaderMaxCount;prop.putNum("loaderQueueSize", loaderJobCount);prop.putNum("loaderQueueMax", loaderMaxCount);prop.put("loaderQueuePercent", (loaderPercent>100) ? 100 : loaderPercent);- prop.putNum("localCrawlQueueSize", sb.getThread(plasmaSwitchboard.CRAWLJOB_LOCAL_CRAWL).getJobCount());- prop.put("localCrawlPaused",sb.crawlJobIsPaused(plasmaSwitchboard.CRAWLJOB_LOCAL_CRAWL) ? "1" : "0");+ prop.putNum("localCrawlQueueSize", sb.getThread(plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL).getJobCount());+ prop.put("localCrawlPaused",sb.crawlJobIsPaused(plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL) ? "1" : "0");- prop.putNum("remoteTriggeredCrawlQueueSize", sb.getThread(plasmaSwitchboard.CRAWLJOB_REMOTE_TRIGGERED_CRAWL).getJobCount());- prop.put("remoteTriggeredCrawlPaused",sb.crawlJobIsPaused(plasmaSwitchboard.CRAWLJOB_REMOTE_TRIGGERED_CRAWL) ? "1" : "0");+ prop.putNum("remoteTriggeredCrawlQueueSize", sb.getThread(plasmaSwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL).getJobCount());+ prop.put("remoteTriggeredCrawlPaused",sb.crawlJobIsPaused(plasmaSwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL) ? "1" : "0");prop.putNum("stackCrawlQueueSize", sb.crawlStacker.size());diff --git a/htroot/WatchCrawler_p.java b/htroot/WatchCrawler_p.javaindex b1920484a..091310d1c 100644--- a/htroot/WatchCrawler_p.java+++ b/htroot/WatchCrawler_p.java@@ -44,6 +44,7 @@ import de.anomic.htmlFilter.htmlFilterContentScraper;import de.anomic.htmlFilter.htmlFilterWriter;import de.anomic.http.httpHeader;import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.plasma.plasmaSwitchboardConstants;import de.anomic.server.serverFileUtils;import de.anomic.server.serverObjects;import de.anomic.server.serverSwitch;@@ -82,9 +83,9 @@ public class WatchCrawler_p {// continue queuefinal String queue = post.get("continue", "");if (queue.equals("localcrawler")) {- sb.continueCrawlJob(plasmaSwitchboard.CRAWLJOB_LOCAL_CRAWL);+ sb.continueCrawlJob(plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL);} else if (queue.equals("remotecrawler")) {- sb.continueCrawlJob(plasmaSwitchboard.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);+ sb.continueCrawlJob(plasmaSwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);}}@@ -92,9 +93,9 @@ public class WatchCrawler_p {// pause queuefinal String queue = post.get("pause", "");if (queue.equals("localcrawler")) {- sb.pauseCrawlJob(plasmaSwitchboard.CRAWLJOB_LOCAL_CRAWL);+ sb.pauseCrawlJob(plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL);} else if (queue.equals("remotecrawler")) {- sb.pauseCrawlJob(plasmaSwitchboard.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);+ sb.pauseCrawlJob(plasmaSwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);}}@@ -293,7 +294,7 @@ public class WatchCrawler_p {final CrawlProfile.entry profile = sb.webIndex.profilesActiveCrawls.newEntry(fileName, crawlURL, newcrawlingfilter, newcrawlingfilter, newcrawlingdepth, newcrawlingdepth, crawlingIfOlder, crawlingDomFilterDepth, crawlingDomMaxPages, crawlingQ, indexText, indexMedia, storeHTCache, true, crawlOrder, xsstopw, xdstopw, xpstopw);// pause local crawl here- sb.pauseCrawlJob(plasmaSwitchboard.CRAWLJOB_LOCAL_CRAWL);+ sb.pauseCrawlJob(plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL);// loop through the contained linksfinal Iterator<Map.Entry<yacyURL, String>> linkiterator = hyperlinks.entrySet().iterator();@@ -326,7 +327,7 @@ public class WatchCrawler_p {prop.putHTML("info_error", e.getMessage());e.printStackTrace();}- sb.continueCrawlJob(plasmaSwitchboard.CRAWLJOB_LOCAL_CRAWL);+ sb.continueCrawlJob(plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL);}} else if (crawlingMode.equals(CRAWLING_MODE_SITEMAP)) {String sitemapURLStr = null;@@ -367,7 +368,7 @@ public class WatchCrawler_p {}// performance settings- final long LCbusySleep = Integer.parseInt(env.getConfig(plasmaSwitchboard.CRAWLJOB_LOCAL_CRAWL_BUSYSLEEP, "100"));+ final long LCbusySleep = Integer.parseInt(env.getConfig(plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL_BUSYSLEEP, "100"));final int LCppm = (int) (60000L / Math.max(1,LCbusySleep));prop.put("crawlingSpeedMaxChecked", (LCppm >= 1000) ? "1" : "0");prop.put("crawlingSpeedCustChecked", ((LCppm > 10) && (LCppm < 1000)) ? "1" : "0");@@ -389,7 +390,7 @@ public class WatchCrawler_p {private static void setPerformance(final plasmaSwitchboard sb, final serverObjects post) {final String crawlingPerformance = post.get("crawlingPerformance","custom");- final long LCbusySleep = Integer.parseInt(sb.getConfig(plasmaSwitchboard.CRAWLJOB_LOCAL_CRAWL_BUSYSLEEP, "100"));+ final long LCbusySleep = Integer.parseInt(sb.getConfig(plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL_BUSYSLEEP, "100"));int wantedPPM = (LCbusySleep == 0) ? 6000 : (int) (60000L / LCbusySleep);try {wantedPPM = Integer.parseInt(post.get("customPPM", Integer.toString(wantedPPM)));diff --git a/htroot/YaCySearchPluginFF.java b/htroot/YaCySearchPluginFF.javaindex df6244bbd..4c62c1063 100644--- a/htroot/YaCySearchPluginFF.java+++ b/htroot/YaCySearchPluginFF.java@@ -46,7 +46,7 @@ public class YaCySearchPluginFF {String host = hostSocket;int port = 80;- final int pos = hostSocket.indexOf(":");+ final int pos = hostSocket.indexOf(":");if (pos != -1) {port = Integer.parseInt(hostSocket.substring(pos + 1));host = hostSocket.substring(0, pos);diff --git a/htroot/autoconfig.java b/htroot/autoconfig.javaindex 42df22e72..bbc25e605 100644--- a/htroot/autoconfig.java+++ b/htroot/autoconfig.java@@ -47,7 +47,7 @@ public class autoconfig {String host = hostSocket;int port = 80;- final int pos = hostSocket.indexOf(":");+ final int pos = hostSocket.indexOf(":");if (pos != -1) {port = Integer.parseInt(hostSocket.substring(pos + 1));host = hostSocket.substring(0, pos);diff --git a/htroot/index.java b/htroot/index.javaindex 7f42d5772..47f97622f 100644--- a/htroot/index.java+++ b/htroot/index.java@@ -32,6 +32,7 @@import de.anomic.http.httpHeader;import de.anomic.plasma.plasmaSearchQuery;import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.plasma.plasmaSwitchboardConstants;import de.anomic.server.serverObjects;import de.anomic.server.serverSwitch;@@ -65,8 +66,8 @@ public class index {final String cat = (post == null) ? "href" : post.get("cat", "href");final int type = (post == null) ? 0 : post.getInt("type", 0);- final boolean indexDistributeGranted = sb.getConfigBool(plasmaSwitchboard.INDEX_DIST_ALLOW, true);- final boolean indexReceiveGranted = sb.getConfigBool(plasmaSwitchboard.INDEX_RECEIVE_ALLOW, true);+ final boolean indexDistributeGranted = sb.getConfigBool(plasmaSwitchboardConstants.INDEX_DIST_ALLOW, true);+ final boolean indexReceiveGranted = sb.getConfigBool(plasmaSwitchboardConstants.INDEX_RECEIVE_ALLOW, true);//global = global && indexDistributeGranted && indexReceiveGranted;// search domaindiff --git a/htroot/robots.java b/htroot/robots.javaindex 899d4165f..8385ee190 100644--- a/htroot/robots.java+++ b/htroot/robots.java@@ -6,6 +6,7 @@ import java.util.ArrayList;import de.anomic.http.httpHeader;import de.anomic.http.httpdRobotsTxtConfig;import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.plasma.plasmaSwitchboardConstants;import de.anomic.server.serverObjects;import de.anomic.server.serverSwitch;import de.anomic.server.servletProperties;@@ -31,7 +32,7 @@ public class robots {if (rbc.isProfileDisallowed()) prop.put(httpdRobotsTxtConfig.ALL + "_" + httpdRobotsTxtConfig.PROFILE, "1");if (rbc.isLockedDisallowed() || rbc.isDirsDisallowed()) {- final ArrayList<String>[] p = getFiles(env.getConfig(plasmaSwitchboard.HTROOT_PATH, plasmaSwitchboard.HTROOT_PATH_DEFAULT));+ final ArrayList<String>[] p = getFiles(env.getConfig(plasmaSwitchboardConstants.HTROOT_PATH, plasmaSwitchboardConstants.HTROOT_PATH_DEFAULT));if (rbc.isLockedDisallowed()) {prop.put(httpdRobotsTxtConfig.ALL + "_" + httpdRobotsTxtConfig.LOCKED, p[0].size());for (int i=0; i<p[0].size(); i++)diff --git a/htroot/xml/queues_p.java b/htroot/xml/queues_p.javaindex b3ea43836..cabd2bf9f 100644--- a/htroot/xml/queues_p.java+++ b/htroot/xml/queues_p.java@@ -39,6 +39,7 @@ import de.anomic.crawler.IndexingStack;import de.anomic.crawler.NoticedURL;import de.anomic.http.httpHeader;import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.plasma.plasmaSwitchboardConstants;import de.anomic.server.serverObjects;import de.anomic.server.serverSwitch;import de.anomic.yacy.yacySeed;@@ -67,8 +68,8 @@ public class queues_p {yacySeed initiator;//indexing queue- prop.putNum("indexingSize", sb.getThread(plasmaSwitchboard.INDEXER).getJobCount() + sb.webIndex.queuePreStack.getActiveQueueSize());- prop.putNum("indexingMax", (int) sb.getConfigLong(plasmaSwitchboard.INDEXER_SLOTS, 30));+ prop.putNum("indexingSize", sb.getThread(plasmaSwitchboardConstants.INDEXER).getJobCount() + sb.webIndex.queuePreStack.getActiveQueueSize());+ prop.putNum("indexingMax", (int) sb.getConfigLong(plasmaSwitchboardConstants.INDEXER_SLOTS, 30));prop.putNum("urlpublictextSize", sb.webIndex.countURL());prop.putNum("rwipublictextSize", sb.webIndex.size());if ((sb.webIndex.queuePreStack.size() == 0) && (sb.webIndex.queuePreStack.getActiveQueueSize() == 0)) {@@ -117,7 +118,7 @@ public class queues_p {//loader queueprop.put("loaderSize", Integer.toString(sb.crawlQueues.size()));- prop.put("loaderMax", sb.getConfig(plasmaSwitchboard.CRAWLER_THREADS_ACTIVE_MAX, "10"));+ prop.put("loaderMax", sb.getConfig(plasmaSwitchboardConstants.CRAWLER_THREADS_ACTIVE_MAX, "10"));if (sb.crawlQueues.size() == 0) {prop.put("list-loader", "0");} else {@@ -136,8 +137,8 @@ public class queues_p {}//local crawl queue- prop.putNum("localCrawlSize", Integer.toString(sb.getThread(plasmaSwitchboard.CRAWLJOB_LOCAL_CRAWL).getJobCount()));- prop.put("localCrawlState", sb.crawlJobIsPaused(plasmaSwitchboard.CRAWLJOB_LOCAL_CRAWL) ? STATE_PAUSED : STATE_RUNNING);+ prop.putNum("localCrawlSize", Integer.toString(sb.getThread(plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL).getJobCount()));+ prop.put("localCrawlState", sb.crawlJobIsPaused(plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL) ? STATE_PAUSED : STATE_RUNNING);int stackSize = sb.crawlQueues.noticeURL.stackSize(NoticedURL.STACK_TYPE_CORE);addNTable(sb, prop, "list-local", sb.crawlQueues.noticeURL.top(NoticedURL.STACK_TYPE_CORE, Math.min(10, stackSize)));@@ -147,8 +148,8 @@ public class queues_p {stackSize = sb.crawlQueues.noticeURL.stackSize(NoticedURL.STACK_TYPE_LIMIT);//global crawl queue- prop.putNum("remoteCrawlSize", Integer.toString(sb.getThread(plasmaSwitchboard.CRAWLJOB_REMOTE_TRIGGERED_CRAWL).getJobCount()));- prop.put("remoteCrawlState", sb.crawlJobIsPaused(plasmaSwitchboard.CRAWLJOB_REMOTE_TRIGGERED_CRAWL) ? STATE_PAUSED : STATE_RUNNING);+ prop.putNum("remoteCrawlSize", Integer.toString(sb.getThread(plasmaSwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL).getJobCount()));+ prop.put("remoteCrawlState", sb.crawlJobIsPaused(plasmaSwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL) ? STATE_PAUSED : STATE_RUNNING);stackSize = sb.crawlQueues.noticeURL.stackSize(NoticedURL.STACK_TYPE_LIMIT);if (stackSize == 0) {diff --git a/htroot/xml/status_p.java b/htroot/xml/status_p.javaindex 7cd377580..43dbd3f11 100644--- a/htroot/xml/status_p.java+++ b/htroot/xml/status_p.java@@ -24,6 +24,7 @@ import de.anomic.http.httpHeader;import de.anomic.http.httpdByteCountInputStream;import de.anomic.http.httpdByteCountOutputStream;import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.plasma.plasmaSwitchboardConstants;import de.anomic.server.serverMemory;import de.anomic.server.serverObjects;import de.anomic.server.serverProcessor;@@ -41,7 +42,7 @@ public class status_p {prop.put("rejected", "0");sb.updateMySeed();final int cacheOutSize = sb.webIndex.dhtOutCacheSize();- final long cacheMaxSize = sb.getConfigLong(plasmaSwitchboard.WORDCACHE_MAX_COUNT, 10000);+ final long cacheMaxSize = sb.getConfigLong(plasmaSwitchboardConstants.WORDCACHE_MAX_COUNT, 10000);prop.putNum("ppm", sb.webIndex.seedDB.mySeed().getPPM());prop.putNum("qpm", sb.webIndex.seedDB.mySeed().getQPM());prop.putNum("wordCacheSize", sb.webIndex.dhtOutCacheSize() + sb.webIndex.dhtInCacheSize());diff --git a/htroot/yacy/list.java b/htroot/yacy/list.javaindex efa35370b..e1ccdb6d4 100644--- a/htroot/yacy/list.java+++ b/htroot/yacy/list.java@@ -31,6 +31,7 @@ import java.io.File;import de.anomic.data.listManager;import de.anomic.http.httpHeader;import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.plasma.plasmaSwitchboardConstants;import de.anomic.server.serverCore;import de.anomic.server.serverObjects;import de.anomic.server.serverSwitch;@@ -50,7 +51,7 @@ public final class list {if (!yacyNetwork.authentifyRequest(post, env)) return prop;final String col = post.get("col", "");- final File listsPath = env.getConfigPath(plasmaSwitchboard.LISTS_PATH, plasmaSwitchboard.LISTS_PATH_DEFAULT);+ final File listsPath = env.getConfigPath(plasmaSwitchboardConstants.LISTS_PATH, plasmaSwitchboardConstants.LISTS_PATH_DEFAULT);String otherPeerName = null;if (post.containsKey("iam")) {diff --git a/htroot/yacy/user/ysearch.java b/htroot/yacy/user/ysearch.javaindex d5ee8b5de..daf381cf8 100644--- a/htroot/yacy/user/ysearch.java+++ b/htroot/yacy/user/ysearch.java@@ -35,6 +35,7 @@ import de.anomic.plasma.plasmaSearchEvent;import de.anomic.plasma.plasmaSearchQuery;import de.anomic.plasma.plasmaSearchRankingProfile;import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.plasma.plasmaSwitchboardConstants;import de.anomic.server.serverCore;import de.anomic.server.serverObjects;import de.anomic.server.serverSwitch;@@ -185,7 +186,7 @@ public class ysearch {// prepare search propertiesfinal boolean yacyonline = ((sb.webIndex.seedDB != null) && (sb.webIndex.seedDB.mySeed() != null) && (sb.webIndex.seedDB.mySeed().getPublicAddress() != null));- final boolean globalsearch = (global) && (yacyonline) && (sb.getConfigBool(plasmaSwitchboard.INDEX_RECEIVE_ALLOW, false));+ final boolean globalsearch = (global) && (yacyonline) && (sb.getConfigBool(plasmaSwitchboardConstants.INDEX_RECEIVE_ALLOW, false));// do the searchfinal TreeSet<String> queryHashes = indexWord.words2hashes(query[0]);diff --git a/htroot/yacysearch.java b/htroot/yacysearch.javaindex 66526e7e1..21c5f25c0 100644--- a/htroot/yacysearch.java+++ b/htroot/yacysearch.java@@ -43,6 +43,7 @@ import de.anomic.plasma.plasmaSearchQuery;import de.anomic.plasma.plasmaSearchRankingProfile;import de.anomic.plasma.plasmaSnippetCache;import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.plasma.plasmaSwitchboardConstants;import de.anomic.server.serverCore;import de.anomic.server.serverMemory;import de.anomic.server.serverObjects;@@ -250,7 +251,7 @@ public class yacysearch {// prepare search properties//final boolean yacyonline = ((sb.webIndex.seedDB != null) && (sb.webIndex.seedDB.mySeed() != null) && (sb.webIndex.seedDB.mySeed().getPublicAddress() != null));- final boolean globalsearch = (global) /* && (yacyonline)*/ && (sb.getConfigBool(plasmaSwitchboard.INDEX_RECEIVE_ALLOW, false));+ final boolean globalsearch = (global) /* && (yacyonline)*/ && (sb.getConfigBool(plasmaSwitchboardConstants.INDEX_RECEIVE_ALLOW, false));// do the searchfinal TreeSet<String> queryHashes = indexWord.words2hashes(query[0]);diff --git a/source/dbtest.java b/source/dbtest.javaindex 827edc2bd..a6e6b844a 100644--- a/source/dbtest.java+++ b/source/dbtest.java@@ -458,7 +458,7 @@ public class dbtest {}if ((ra.size() > 0) && (random.nextLong() % 7 == 0)) {rc++;- p = Math.abs(random.nextInt()) % ra.size();+ p = Math.abs(random.nextInt() % ra.size());R = ra.get(p);jcontrol.remove(R);kcontrol.removeb((int) R.longValue());@@ -499,7 +499,7 @@ public class dbtest {}if ((ra.size() > 0) && (random.nextLong() % 7 == 0)) {rc++;- p = Math.abs(random.nextInt()) % ra.size();+ p = Math.abs(random.nextInt() % ra.size());R = ra.get(p);jcontrol.remove(R);kcontrol.removeb((int) R.longValue());diff --git a/source/de/anomic/crawler/Balancer.java b/source/de/anomic/crawler/Balancer.javaindex 1ff7427b7..788a3d518 100644--- a/source/de/anomic/crawler/Balancer.java+++ b/source/de/anomic/crawler/Balancer.java@@ -333,7 +333,7 @@ public class Balancer {pushHash(entry.url().hash());}- private void pushHash(final String hash) throws IOException {+ private void pushHash(final String hash) {// extend domain stackfinal String dom = hash.substring(6);LinkedList<String> domainList = domainStacks.get(dom);@@ -485,9 +485,9 @@ public class Balancer {if (rowEntry == null) {serverLog.logSevere("PLASMA BALANCER", "get() found a valid urlhash, but failed to fetch the corresponding url entry - total size = " + size() + ", fileStack.size() = " + urlFileStack.size() + ", ramStack.size() = " + urlRAMStack.size() + ", domainStacks.size() = " + domainStacks.size());return null;- } else {- assert urlFileIndex.size() + 1 == s : "urlFileIndex.size() = " + urlFileIndex.size() + ", s = " + s + ", result = " + result;}+ assert urlFileIndex.size() + 1 == s : "urlFileIndex.size() = " + urlFileIndex.size() + ", s = " + s + ", result = " + result;+final CrawlEntry crawlEntry = new CrawlEntry(rowEntry);final long genericDelta = Math.min(15000,diff --git a/source/de/anomic/crawler/CrawlProfile.java b/source/de/anomic/crawler/CrawlProfile.javaindex b11988367..acfa31b34 100644--- a/source/de/anomic/crawler/CrawlProfile.java+++ b/source/de/anomic/crawler/CrawlProfile.java@@ -297,27 +297,32 @@ public class CrawlProfile {}public String handle() {final String r = mem.get(HANDLE);- if (r == null) return null; else return r;+ //if (r == null) return null;+ return r;}public String name() {final String r = mem.get(NAME);- if (r == null) return ""; else return r;+ if (r == null) return "";+ return r;}public String startURL() {final String r = mem.get(START_URL);- if (r == null) return null; else return r;+ return r;}public String generalFilter() {final String r = mem.get(GENERAL_FILTER);- if (r == null) return ".*"; else return r;+ if (r == null) return ".*";+ return r;}public String specificFilter() {final String r = mem.get(SPECIFIC_FILTER);- if (r == null) return ".*"; else return r;+ if (r == null) return ".*";+ return r;}public int generalDepth() {final String r = mem.get(GENERAL_DEPTH);- if (r == null) return 0; else try {+ if (r == null) return 0;+ try {return Integer.parseInt(r);} catch (final NumberFormatException e) {return 0;@@ -325,7 +330,8 @@ public class CrawlProfile {}public int specificDepth() {final String r = mem.get(SPECIFIC_DEPTH);- if (r == null) return 0; else try {+ if (r == null) return 0;+ try {return Integer.parseInt(r);} catch (final NumberFormatException e) {return 0;@@ -335,7 +341,8 @@ public class CrawlProfile {// returns a long (millis) that is the minimum age that// an antry must have to be re-crawledfinal String r = mem.get(RECRAWL_IF_OLDER);- if (r == null) return Long.MAX_VALUE; else try {+ if (r == null) return Long.MAX_VALUE;+ try {final long l = Long.parseLong(r) * 60000L;return (l < 0) ? Long.MAX_VALUE : l;} catch (final NumberFormatException e) {@@ -347,7 +354,8 @@ public class CrawlProfile {// then the current url feeds with its domain the crawl filter// if this is -1, all domains are feededfinal String r = mem.get(DOM_FILTER_DEPTH);- if (r == null) return Integer.MAX_VALUE; else try {+ if (r == null) return Integer.MAX_VALUE;+ try {final int i = Integer.parseInt(r);if (i < 0) return Integer.MAX_VALUE;return i;@@ -359,7 +367,8 @@ public class CrawlProfile {// this is the maximum number of pages that are crawled for a single domain// if -1, this means no limitfinal String r = mem.get(DOM_MAX_PAGES);- if (r == null) return Integer.MAX_VALUE; else try {+ if (r == null) return Integer.MAX_VALUE;+ try {final int i = Integer.parseInt(r);if (i < 0) return Integer.MAX_VALUE;return i;@@ -369,39 +378,48 @@ public class CrawlProfile {}public boolean crawlingQ() {final String r = mem.get(CRAWLING_Q);- if (r == null) return false; else return (r.equals(Boolean.TRUE.toString()));+ if (r == null) return false;+ return (r.equals(Boolean.TRUE.toString()));}public boolean indexText() {final String r = mem.get(INDEX_TEXT);- if (r == null) return true; else return (r.equals(Boolean.TRUE.toString()));+ if (r == null) return true;+ return (r.equals(Boolean.TRUE.toString()));}public boolean indexMedia() {final String r = mem.get(INDEX_MEDIA);- if (r == null) return true; else return (r.equals(Boolean.TRUE.toString()));+ if (r == null) return true;+ return (r.equals(Boolean.TRUE.toString()));}public boolean storeHTCache() {final String r = mem.get(STORE_HTCACHE);- if (r == null) return false; else return (r.equals(Boolean.TRUE.toString()));+ if (r == null) return false;+ return (r.equals(Boolean.TRUE.toString()));}public boolean storeTXCache() {final String r = mem.get(STORE_TXCACHE);- if (r == null) return false; else return (r.equals(Boolean.TRUE.toString()));+ if (r == null) return false;+ return (r.equals(Boolean.TRUE.toString()));}public boolean remoteIndexing() {final String r = mem.get(REMOTE_INDEXING);- if (r == null) return false; else return (r.equals(Boolean.TRUE.toString()));+ if (r == null) return false;+ return (r.equals(Boolean.TRUE.toString()));}public boolean excludeStaticStopwords() {final String r = mem.get(XSSTOPW);- if (r == null) return false; else return (r.equals(Boolean.TRUE.toString()));+ if (r == null) return false;+ return (r.equals(Boolean.TRUE.toString()));}public boolean excludeDynamicStopwords() {final String r = mem.get(XDSTOPW);- if (r == null) return false; else return (r.equals(Boolean.TRUE.toString()));+ if (r == null) return false;+ return (r.equals(Boolean.TRUE.toString()));}public boolean excludeParentStopwords() {final String r = mem.get(XPSTOPW);- if (r == null) return false; else return (r.equals(Boolean.TRUE.toString()));+ if (r == null) return false;+ return (r.equals(Boolean.TRUE.toString()));}public void domInc(final String domain, final String referrer, final int depth) {synchronized (domain.intern()) {@@ -424,9 +442,8 @@ public class CrawlProfile {final DomProfile dp = doms.get(domain);if (dp == null) {return 0 < max;- } else {- return dp.depth <= max;}+ return dp.depth <= max;}}@@ -437,9 +454,8 @@ public class CrawlProfile {final DomProfile dp = doms.get(domain);if (dp == null) {return 0 < max;- } else {- return dp.count <= max;}+ return dp.count <= max;}}public int domSize() {diff --git a/source/de/anomic/crawler/CrawlQueues.java b/source/de/anomic/crawler/CrawlQueues.javaindex 721a7965b..cd0101506 100644--- a/source/de/anomic/crawler/CrawlQueues.java+++ b/source/de/anomic/crawler/CrawlQueues.java@@ -40,6 +40,7 @@ import de.anomic.kelondro.kelondroFlexWidthArray;import de.anomic.plasma.plasmaHTCache;import de.anomic.plasma.plasmaParser;import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.plasma.plasmaSwitchboardConstants;import de.anomic.server.serverDate;import de.anomic.server.logging.serverLog;import de.anomic.xml.RSSFeed;@@ -166,8 +167,8 @@ public class CrawlQueues {public boolean coreCrawlJob() {final boolean robinsonPrivateCase = ((sb.isRobinsonMode()) &&- (!sb.getConfig(plasmaSwitchboard.CLUSTER_MODE, "").equals(plasmaSwitchboard.CLUSTER_MODE_PUBLIC_CLUSTER)) &&- (!sb.getConfig(plasmaSwitchboard.CLUSTER_MODE, "").equals(plasmaSwitchboard.CLUSTER_MODE_PRIVATE_CLUSTER)));+ (!sb.getConfig(plasmaSwitchboardConstants.CLUSTER_MODE, "").equals(plasmaSwitchboardConstants.CLUSTER_MODE_PUBLIC_CLUSTER)) &&+ (!sb.getConfig(plasmaSwitchboardConstants.CLUSTER_MODE, "").equals(plasmaSwitchboardConstants.CLUSTER_MODE_PRIVATE_CLUSTER)));if (((robinsonPrivateCase) || (coreCrawlJobSize() <= 20)) && (limitCrawlJobSize() > 0)) {// move some tasks to the core crawl job so we have something to do@@ -176,7 +177,7 @@ public class CrawlQueues {noticeURL.shift(NoticedURL.STACK_TYPE_LIMIT, NoticedURL.STACK_TYPE_CORE);}log.logInfo("shifted " + toshift + " jobs from global crawl to local crawl (coreCrawlJobSize()=" + coreCrawlJobSize() +- ", limitCrawlJobSize()=" + limitCrawlJobSize() + ", cluster.mode=" + sb.getConfig(plasmaSwitchboard.CLUSTER_MODE, "") ++ ", limitCrawlJobSize()=" + limitCrawlJobSize() + ", cluster.mode=" + sb.getConfig(plasmaSwitchboardConstants.CLUSTER_MODE, "") +", robinsonMode=" + ((sb.isRobinsonMode()) ? "on" : "off"));}@@ -184,11 +185,11 @@ public class CrawlQueues {//log.logDebug("CoreCrawl: queue is empty");return false;}- if (sb.webIndex.queuePreStack.size() >= (int) sb.getConfigLong(plasmaSwitchboard.INDEXER_SLOTS, 30)) {+ if (sb.webIndex.queuePreStack.size() >= (int) sb.getConfigLong(plasmaSwitchboardConstants.INDEXER_SLOTS, 30)) {if (this.log.isFine()) log.logFine("CoreCrawl: too many processes in indexing queue, dismissed (" + "sbQueueSize=" + sb.webIndex.queuePreStack.size() + ")");return false;}- if (this.size() >= sb.getConfigLong(plasmaSwitchboard.CRAWLER_THREADS_ACTIVE_MAX, 10)) {+ if (this.size() >= sb.getConfigLong(plasmaSwitchboardConstants.CRAWLER_THREADS_ACTIVE_MAX, 10)) {if (this.log.isFine()) log.logFine("CoreCrawl: too many processes in loader queue, dismissed (" + "cacheLoader=" + this.size() + ")");return false;}@@ -198,11 +199,11 @@ public class CrawlQueues {}// if crawling was paused we have to wait until we wer notified to continue- final Object[] status = sb.crawlJobsStatus.get(plasmaSwitchboard.CRAWLJOB_LOCAL_CRAWL);- synchronized(status[plasmaSwitchboard.CRAWLJOB_SYNC]) {- if (((Boolean)status[plasmaSwitchboard.CRAWLJOB_STATUS]).booleanValue()) {+ final Object[] status = sb.crawlJobsStatus.get(plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL);+ synchronized(status[plasmaSwitchboardConstants.CRAWLJOB_SYNC]) {+ if (((Boolean)status[plasmaSwitchboardConstants.CRAWLJOB_STATUS]).booleanValue()) {try {- status[plasmaSwitchboard.CRAWLJOB_SYNC].wait();+ status[plasmaSwitchboardConstants.CRAWLJOB_SYNC].wait();}catch (final InterruptedException e) {return false;}}@@ -261,12 +262,12 @@ public class CrawlQueues {return false;}- if (sb.webIndex.queuePreStack.size() >= (int) sb.getConfigLong(plasmaSwitchboard.INDEXER_SLOTS, 30) / 2) {+ if (sb.webIndex.queuePreStack.size() >= (int) sb.getConfigLong(plasmaSwitchboardConstants.INDEXER_SLOTS, 30) / 2) {if (this.log.isFine()) log.logFine("remoteCrawlLoaderJob: too many processes in indexing queue, dismissed (" + "sbQueueSize=" + sb.webIndex.queuePreStack.size() + ")");return false;}- if (this.size() >= sb.getConfigLong(plasmaSwitchboard.CRAWLER_THREADS_ACTIVE_MAX, 10)) {+ if (this.size() >= sb.getConfigLong(plasmaSwitchboardConstants.CRAWLER_THREADS_ACTIVE_MAX, 10)) {if (this.log.isFine()) log.logFine("remoteCrawlLoaderJob: too many processes in loader queue, dismissed (" + "cacheLoader=" + this.size() + ")");return false;}@@ -392,11 +393,11 @@ public class CrawlQueues {//log.logDebug("GlobalCrawl: queue is empty");return false;}- if (sb.webIndex.queuePreStack.size() >= (int) sb.getConfigLong(plasmaSwitchboard.INDEXER_SLOTS, 30)) {+ if (sb.webIndex.queuePreStack.size() >= (int) sb.getConfigLong(plasmaSwitchboardConstants.INDEXER_SLOTS, 30)) {if (this.log.isFine()) log.logFine("GlobalCrawl: too many processes in indexing queue, dismissed (" + "sbQueueSize=" + sb.webIndex.queuePreStack.size() + ")");return false;}- if (this.size() >= sb.getConfigLong(plasmaSwitchboard.CRAWLER_THREADS_ACTIVE_MAX, 10)) {+ if (this.size() >= sb.getConfigLong(plasmaSwitchboardConstants.CRAWLER_THREADS_ACTIVE_MAX, 10)) {if (this.log.isFine()) log.logFine("GlobalCrawl: too many processes in loader queue, dismissed (" + "cacheLoader=" + this.size() + ")");return false;}@@ -406,11 +407,11 @@ public class CrawlQueues {}// if crawling was paused we have to wait until we wer notified to continue- final Object[] status = sb.crawlJobsStatus.get(plasmaSwitchboard.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);- synchronized(status[plasmaSwitchboard.CRAWLJOB_SYNC]) {- if (((Boolean)status[plasmaSwitchboard.CRAWLJOB_STATUS]).booleanValue()) {+ final Object[] status = sb.crawlJobsStatus.get(plasmaSwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);+ synchronized(status[plasmaSwitchboardConstants.CRAWLJOB_SYNC]) {+ if (((Boolean)status[plasmaSwitchboardConstants.CRAWLJOB_STATUS]).booleanValue()) {try {- status[plasmaSwitchboard.CRAWLJOB_SYNC].wait();+ status[plasmaSwitchboardConstants.CRAWLJOB_SYNC].wait();}catch (final InterruptedException e){ return false;}}diff --git a/source/de/anomic/crawler/CrawlStacker.java b/source/de/anomic/crawler/CrawlStacker.javaindex c5abf5f0e..74ce2184e 100644--- a/source/de/anomic/crawler/CrawlStacker.java+++ b/source/de/anomic/crawler/CrawlStacker.java@@ -397,7 +397,7 @@ public final class CrawlStacker extends Thread {final String errorMsg = "LOST PROFILE HANDLE '" + entry.profileHandle() + "' for URL " + entry.url();log.logWarning(errorMsg);return errorMsg;- } else {+ }// filter denyif ((entry.depth() > 0) && (!(entry.url().toString().matches(profile.generalFilter())))) {@@ -492,7 +492,6 @@ public final class CrawlStacker extends Thread {((local) ? NoticedURL.STACK_TYPE_CORE : NoticedURL.STACK_TYPE_REMOTE)) /*local/remote stack*/,entry);return null;- }}}diff --git a/source/de/anomic/crawler/HTTPLoader.java b/source/de/anomic/crawler/HTTPLoader.javaindex e5babd5c5..603345ae3 100644--- a/source/de/anomic/crawler/HTTPLoader.java+++ b/source/de/anomic/crawler/HTTPLoader.java@@ -46,6 +46,7 @@ import de.anomic.index.indexReferenceBlacklist;import de.anomic.plasma.plasmaHTCache;import de.anomic.plasma.plasmaParser;import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.plasma.plasmaSwitchboardConstants;import de.anomic.plasma.cache.IResourceInfo;import de.anomic.plasma.cache.http.ResourceInfo;import de.anomic.server.serverSystem;@@ -226,13 +227,13 @@ public final class HTTPLoader {if (fos!=null)try{fos.close();}catch(final Exception e){/* ignore this */}}- return htCache;} else {// if the response has not the right file type then reject filethis.log.logInfo("REJECTED WRONG MIME/EXT TYPE " + res.getResponseHeader().mime() + " for URL " + entry.url().toString());sb.crawlQueues.errorURL.newEntry(entry, sb.webIndex.seedDB.mySeed().hash, new Date(), 1, ErrorURL.DENIED_WRONG_MIMETYPE_OR_EXT);- return null;+ htCache = null;}+ return htCache;} catch (final SocketException e) {// this may happen if the client suddenly closes its connection// maybe the user has stopped loading@@ -364,8 +365,8 @@ public final class HTTPLoader {} else if ((errorMsg != null) && (errorMsg.indexOf("There is not enough space on the disk") >= 0)) {this.log.logSevere("CRAWLER Not enough space on the disk detected while crawling '" + entry.url().toString() + "'. " +"Pausing crawlers. ");- sb.pauseCrawlJob(plasmaSwitchboard.CRAWLJOB_LOCAL_CRAWL);- sb.pauseCrawlJob(plasmaSwitchboard.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);+ sb.pauseCrawlJob(plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL);+ sb.pauseCrawlJob(plasmaSwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);failreason = ErrorURL.DENIED_OUT_OF_DISK_SPACE;} else if ((errorMsg != null) && (errorMsg.indexOf("Network is unreachable") >=0)) {this.log.logSevere("CRAWLER Network is unreachable while trying to crawl URL '" + entry.url().toString() + "'. ");diff --git a/source/de/anomic/crawler/IndexingStack.java b/source/de/anomic/crawler/IndexingStack.javaindex 83302459b..f34501ff7 100644--- a/source/de/anomic/crawler/IndexingStack.java+++ b/source/de/anomic/crawler/IndexingStack.java@@ -40,7 +40,7 @@ import de.anomic.kelondro.kelondroNaturalOrder;import de.anomic.kelondro.kelondroRow;import de.anomic.kelondro.kelondroStack;import de.anomic.plasma.plasmaHTCache;-import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.plasma.plasmaSwitchboardConstants;import de.anomic.plasma.plasmaWordIndex;import de.anomic.plasma.cache.IResourceInfo;import de.anomic.server.logging.serverLog;@@ -312,6 +312,7 @@ public class IndexingStack {}public boolean proxy() {+ // FIXME the equals seems to be incorrect: String.equals(boolean)return (initiator == null) || (initiator.equals(initiator.length() == 0));}@@ -324,10 +325,9 @@ public class IndexingStack {if (initiator.equals(wordIndex.seedDB.mySeed().hash)) {// normal crawlingreturn null;- } else {- // this was done for remote peer (a global crawl)- return wordIndex.seedDB.getConnected(initiator);}+ // this was done for remote peer (a global crawl)+ return wordIndex.seedDB.getConnected(initiator);}public int depth() {@@ -335,7 +335,8 @@ public class IndexingStack {}public long size() {- if (cacheFile().exists()) return cacheFile().length(); else return 0;+ if (cacheFile().exists()) return cacheFile().length();+ return 0;}public CrawlProfile.entry profile() {@@ -370,6 +371,7 @@ public class IndexingStack {public yacyURL referrerURL() {if (referrerURL == null) {+ // FIXME the equals seems to be incorrect: String.equals(boolean)if ((referrerHash == null) || ((initiator != null) && (referrerHash.equals(initiator.length() == 0)))) return null;final indexURLReference entry = wordIndex.getURL(referrerHash, null, 0);if (entry == null) referrerURL = null; else referrerURL = entry.comp().url();@@ -393,16 +395,17 @@ public class IndexingStack {// 4) proxy-load (initiator is "------------")// 5) local prefetch/crawling (initiator is own seedHash)// 6) local fetching for global crawling (other known or unknwon initiator)- int processCase = plasmaSwitchboard.PROCESSCASE_0_UNKNOWN;+ int processCase = plasmaSwitchboardConstants.PROCESSCASE_0_UNKNOWN;+ // FIXME the equals seems to be incorrect: String.equals(boolean)if ((initiator == null) || (initiator.equals(initiator.length() == 0))) {// proxy-load- processCase = plasmaSwitchboard.PROCESSCASE_4_PROXY_LOAD;+ processCase = plasmaSwitchboardConstants.PROCESSCASE_4_PROXY_LOAD;} else if ((initiator != null) && (initiator.equals(wordIndex.seedDB.mySeed().hash))) {// normal crawling- processCase = plasmaSwitchboard.PROCESSCASE_5_LOCAL_CRAWLING;+ processCase = plasmaSwitchboardConstants.PROCESSCASE_5_LOCAL_CRAWLING;} else {// this was done for remote peer (a global crawl)- processCase = plasmaSwitchboard.PROCESSCASE_6_GLOBAL_CRAWLING;+ processCase = plasmaSwitchboardConstants.PROCESSCASE_6_GLOBAL_CRAWLING;}return processCase;}diff --git a/source/de/anomic/crawler/ResourceObserver.java b/source/de/anomic/crawler/ResourceObserver.javaindex 9c9a75f8d..8ef7f0d7f 100644--- a/source/de/anomic/crawler/ResourceObserver.java+++ b/source/de/anomic/crawler/ResourceObserver.java@@ -27,6 +27,7 @@ import java.util.HashMap;import java.util.Map;import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.plasma.plasmaSwitchboardConstants;import de.anomic.server.logging.serverLog;import de.anomic.tools.diskUsage;@@ -57,12 +58,12 @@ public final class ResourceObserver {final ArrayList<String> pathsToCheck = new ArrayList<String>();// FIXME whats about the secondary path???// = (getConfig(plasmaSwitchboard.INDEX_SECONDARY_PATH, "");- final String[] pathes = {plasmaSwitchboard.HTDOCS_PATH,- plasmaSwitchboard.INDEX_PRIMARY_PATH,- plasmaSwitchboard.LISTS_PATH,- plasmaSwitchboard.PLASMA_PATH,- plasmaSwitchboard.RANKING_PATH,- plasmaSwitchboard.WORK_PATH};+ final String[] pathes = {plasmaSwitchboardConstants.HTDOCS_PATH,+ plasmaSwitchboardConstants.INDEX_PRIMARY_PATH,+ plasmaSwitchboardConstants.LISTS_PATH,+ plasmaSwitchboardConstants.PLASMA_PATH,+ plasmaSwitchboardConstants.RANKING_PATH,+ plasmaSwitchboardConstants.WORK_PATH};String path;for (final String element : pathes) {try {@@ -99,13 +100,13 @@ public final class ResourceObserver {}if (!tmpDisksOK || !tmpMemoryOK) {- if (!sb.crawlJobIsPaused(plasmaSwitchboard.CRAWLJOB_LOCAL_CRAWL)) {+ if (!sb.crawlJobIsPaused(plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL)) {this.log.logInfo("disabling local crawls");- sb.pauseCrawlJob(plasmaSwitchboard.CRAWLJOB_LOCAL_CRAWL);+ sb.pauseCrawlJob(plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL);}- if (!sb.crawlJobIsPaused(plasmaSwitchboard.CRAWLJOB_REMOTE_TRIGGERED_CRAWL)) {+ if (!sb.crawlJobIsPaused(plasmaSwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL)) {this.log.logInfo("disabling remote triggered crawls");- sb.pauseCrawlJob(plasmaSwitchboard.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);+ sb.pauseCrawlJob(plasmaSwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);}}else {diff --git a/source/de/anomic/crawler/ResultImages.java b/source/de/anomic/crawler/ResultImages.javaindex dff202d46..fed45b8ad 100755--- a/source/de/anomic/crawler/ResultImages.java+++ b/source/de/anomic/crawler/ResultImages.java@@ -109,12 +109,11 @@ public class ResultImages {}public static int queueSize(final boolean privateEntryOnly) {- if (privateEntryOnly) {- return privateImageQueueHigh.size() + privateImageQueueLow.size();- } else {- return privateImageQueueHigh.size() + privateImageQueueLow.size() +- publicImageQueueHigh.size() + publicImageQueueLow.size();+ int publicSize = 0;+ if (!privateEntryOnly) {+ publicSize = publicImageQueueHigh.size() + publicImageQueueLow.size();}+ return privateImageQueueHigh.size() + privateImageQueueLow.size() + publicSize;}public static int privateQueueHighSize() {diff --git a/source/de/anomic/crawler/ResultURLs.java b/source/de/anomic/crawler/ResultURLs.javaindex eb3acc3b4..f30332fd0 100644--- a/source/de/anomic/crawler/ResultURLs.java+++ b/source/de/anomic/crawler/ResultURLs.java@@ -88,11 +88,10 @@ public final class ResultURLs {public synchronized int getStackSize(final int stack) {final List<String> resultStack = getStack(stack);- if(resultStack != null) {- return resultStack.size();- } else {+ if(resultStack == null) {return -1;}+ return resultStack.size();}public synchronized String getUrlHash(final int stack, final int pos) {@@ -128,21 +127,19 @@ public final class ResultURLs {public synchronized String getHashNo(final int stack, final int pos, final int index) {final String result = getResultStackAt(stack, pos);if(result != null) {- if(yacySeedDB.commonHashLength * 3 <= result.length()) {- return result.substring(yacySeedDB.commonHashLength * index, yacySeedDB.commonHashLength * (index + 1));- } else {+ if(result.length() < yacySeedDB.commonHashLength * 3) {serverLog.logSevere("ResultURLs", "unexpected error: result of stack is too short: "+ result.length());- if(yacySeedDB.commonHashLength * 2 < result.length()) {- // return what is there- return result.substring(yacySeedDB.commonHashLength * 2);- } else {+ if(result.length() <= yacySeedDB.commonHashLength * 2) {return null;}+ // return what is there+ return result.substring(yacySeedDB.commonHashLength * 2);}+ return result.substring(yacySeedDB.commonHashLength * index, yacySeedDB.commonHashLength * (index + 1));} else if(isValidStack(stack)) {serverLog.logSevere("ResultURLs", "unexpected error: result of stack is null: "+ stack +","+ pos);}- return null;+ return result;}/**@@ -156,15 +153,17 @@ public final class ResultURLs {assert pos >= 0 : "precondition violated: " + pos + " >= 0";final List<String> resultStack = getStack(stack);- if(resultStack != null) {- assert pos < resultStack.size() : "pos = " + pos + ", resultStack.size() = " + resultStack.size();- if(pos < resultStack.size()) {- return resultStack.get(pos);- } else {- serverLog.logSevere("ResultURLs", "unexpected error: Index out of Bounds "+ pos +" of "+ resultStack.size());- }++ if(resultStack == null) {+ return null;}- return null;+ assert pos < resultStack.size() : "pos = " + pos + ", resultStack.size() = " + resultStack.size();+ if(pos >= resultStack.size()) {+ serverLog.logSevere("ResultURLs", "unexpected error: Index out of Bounds "+ pos +" of "+ resultStack.size());+ return null;+ }++ return resultStack.get(pos);}/**@@ -208,11 +207,10 @@ public final class ResultURLs {// }// return prevElement != null;final List<String> resultStack = getStack(stack);- if(resultStack != null) {- return resultStack.remove(pos) != null;- } else {+ if(resultStack == null) {return false;}+ return resultStack.remove(pos) != null;}public synchronized void clearStack(final int stack) {diff --git a/source/de/anomic/crawler/RobotsTxt.java b/source/de/anomic/crawler/RobotsTxt.javaindex ca9918e3b..7b3effc6c 100644--- a/source/de/anomic/crawler/RobotsTxt.java+++ b/source/de/anomic/crawler/RobotsTxt.java@@ -100,7 +100,6 @@ public class RobotsTxt {return this.robotsTable.size();}- @SuppressWarnings("unchecked")private Entry getEntry(final String urlHostPort, final boolean fetchOnlineIfNotAvailableOrNotFresh) {// this method will always return a non-null valueEntry robotsTxt4Host = null;diff --git a/source/de/anomic/data/SitemapParser.java b/source/de/anomic/data/SitemapParser.javaindex 68189464b..8c2ea27bd 100644--- a/source/de/anomic/data/SitemapParser.java+++ b/source/de/anomic/data/SitemapParser.java@@ -34,7 +34,6 @@ import java.util.zip.GZIPInputStream;import javax.xml.parsers.SAXParser;import javax.xml.parsers.SAXParserFactory;-import org.apache.commons.httpclient.protocol.Protocol;import org.xml.sax.Attributes;import org.xml.sax.SAXException;import org.xml.sax.helpers.DefaultHandler;diff --git a/source/de/anomic/data/bookmarksDB.java b/source/de/anomic/data/bookmarksDB.javaindex a5cb169da..cdcb17f55 100644--- a/source/de/anomic/data/bookmarksDB.java+++ b/source/de/anomic/data/bookmarksDB.java@@ -945,7 +945,7 @@ public class bookmarksDB {this((new yacyURL(map.get(BOOKMARK_URL), null)).hash(), map);}- private Map<String, String> toMap() {+ Map<String, String> toMap() {entry.put(BOOKMARK_TAGS, listManager.collection2string(tags));entry.put(BOOKMARK_TIMESTAMP, String.valueOf(this.timestamp));return entry;diff --git a/source/de/anomic/data/userDB.java b/source/de/anomic/data/userDB.javaindex e903abbd8..562cb9616 100644--- a/source/de/anomic/data/userDB.java+++ b/source/de/anomic/data/userDB.java@@ -489,42 +489,49 @@ public final class userDB {/*** @deprecated use hasRight(UPLOAD_RIGHT) instead*/+ @Deprecatedpublic boolean hasUploadRight() {return this.hasRight(UPLOAD_RIGHT);}/*** @deprecated use hasRight(DOWNLOAD_RIGHT) instead*/+ @Deprecatedpublic boolean hasDownloadRight() {return this.hasRight(DOWNLOAD_RIGHT);}/*** @deprecated use hasRight(PROXY_RIGHT) instead*/+ @Deprecatedpublic boolean hasProxyRight() {return this.hasRight(PROXY_RIGHT);}/*** @deprecated use hasRight(ADMIN_RIGHT) instead*/+ @Deprecatedpublic boolean hasAdminRight() {return this.hasRight(ADMIN_RIGHT);}/*** @deprecated use hasRight(BLOG_RIGHT) instead*/+ @Deprecatedpublic boolean hasBlogRight() {return this.hasRight(BLOG_RIGHT);}/*** @deprecated use hasRight(WIKIADMIN_RIGHT) instead*/+ @Deprecatedpublic boolean hasWikiAdminRight() {return this.hasRight(WIKIADMIN_RIGHT);}/*** @deprecated use hasRight(BOOKMARK_RIGHT) instead*/+ @Deprecatedpublic boolean hasBookmarkRight() {return this.hasRight(BOOKMARK_RIGHT);}diff --git a/source/de/anomic/data/wiki/knwikiParser.java b/source/de/anomic/data/wiki/knwikiParser.javaindex 16affe353..5517ae585 100644--- a/source/de/anomic/data/wiki/knwikiParser.java+++ b/source/de/anomic/data/wiki/knwikiParser.java@@ -231,8 +231,7 @@ public class knwikiParser implements wikiParser {public String getText() {if (this.nl)return escapeNewLine + this.text;- else- return this.text;+ return this.text;}public String toString() { return this.text; }diff --git a/source/de/anomic/data/wiki/tokens/LinkToken.java b/source/de/anomic/data/wiki/tokens/LinkToken.javaindex 8e77919a8..7e763cfbe 100644--- a/source/de/anomic/data/wiki/tokens/LinkToken.java+++ b/source/de/anomic/data/wiki/tokens/LinkToken.java@@ -135,9 +135,8 @@ public class LinkToken extends AbstractToken {private String formatHref(final String link) {if (link.indexOf("://") == -1) { // DATA/HTDOCS-linkreturn "http://" + this.localhost + "/share/" + link;- } else { // 'normal' link- return link;}+ return link;}private StringBuffer appendLinks(final Link[] links, final StringBuffer sb) {diff --git a/source/de/anomic/data/wiki/tokens/SimpleToken.java b/source/de/anomic/data/wiki/tokens/SimpleToken.javaindex 0b3b8ccce..9c6b8cd4a 100644--- a/source/de/anomic/data/wiki/tokens/SimpleToken.java+++ b/source/de/anomic/data/wiki/tokens/SimpleToken.java@@ -73,9 +73,8 @@ public class SimpleToken extends AbstractToken {if (this.content == null) {if (this.text == null) {throw new IllegalArgumentException();- } else {- setText(this.text, 0);}+ setText(this.text, 0);}if (!this.parsed) parse();return this.markup;diff --git a/source/de/anomic/data/wiki/tokens/TableToken.java b/source/de/anomic/data/wiki/tokens/TableToken.javaindex 460f5ca23..2aa52f360 100644--- a/source/de/anomic/data/wiki/tokens/TableToken.java+++ b/source/de/anomic/data/wiki/tokens/TableToken.java@@ -53,8 +53,8 @@ public class TableToken extends AbstractToken {for (int i=1, j, a; i<t.length-1; i++) {if (t[i].startsWith("|-")) {if (trOpen) sb.append("\t</tr>\n");- // TODO is this assignment correct? (please comment) Or should it be a comparison? (please correct)- if (trOpen = (i < t.length - 2)) sb.append("\t<tr>\n");+ trOpen = (i < t.length - 2);+ if (trOpen) sb.append("\t<tr>\n");} else if (t[i].startsWith("||")) {tds = t[i].split("\\|\\|");for (j=0; j<tds.length; j++) {diff --git a/source/de/anomic/htmlFilter/htmlFilterAbstractScraper.java b/source/de/anomic/htmlFilter/htmlFilterAbstractScraper.javaindex 4f907646c..61630cb54 100644--- a/source/de/anomic/htmlFilter/htmlFilterAbstractScraper.java+++ b/source/de/anomic/htmlFilter/htmlFilterAbstractScraper.java@@ -414,14 +414,12 @@ public abstract class htmlFilterAbstractScraper implements htmlFilterScraper {if (code[1] == '#') {if (code[2] == 'x' || code[2] == 'X') {return new char[] {(char) Integer.parseInt((new String(code)).substring(3, code.length - 1), 16)};- } else {- return new char[] {(char) Integer.parseInt((new String(code)).substring(2, code.length - 1))};}- } else {- final String t = trans.get(new String(code));- if (t == null) return new char[0];- return t.toCharArray();+ return new char[] {(char) Integer.parseInt((new String(code)).substring(2, code.length - 1))};}+ final String t = trans.get(new String(code));+ if (t == null) return new char[0];+ return t.toCharArray();}protected static serverCharBuffer transscriptAll(serverCharBuffer bb) {diff --git a/source/de/anomic/htmlFilter/htmlFilterContentScraper.java b/source/de/anomic/htmlFilter/htmlFilterContentScraper.javaindex 3ec4df99b..b04b5a5d3 100644--- a/source/de/anomic/htmlFilter/htmlFilterContentScraper.java+++ b/source/de/anomic/htmlFilter/htmlFilterContentScraper.java@@ -286,13 +286,12 @@ public class htmlFilterContentScraper extends htmlFilterAbstractScraper implemenif (title.length() > 0) {if (s == null) {return title;- } else {- if ((title.compareToIgnoreCase(s) == 0) || (title.indexOf(s) >= 0)) return s; else return title + ": " + s;- }- } else {- if (s != null) {- return s;}+ if ((title.compareToIgnoreCase(s) == 0) || (title.indexOf(s) >= 0)) return s;+ return title + ": " + s;+ }+ if (s != null) {+ return s;}// otherwise take any headline@@ -363,12 +362,14 @@ public class htmlFilterContentScraper extends htmlFilterAbstractScraper implemenpublic String getDescription() {String s = metas.get("description");if (s == null) s = metas.get("dc.description");- if (s == null) return ""; else return s;+ if (s == null) return "";+ return s;}public String getContentType() {final String s = metas.get("content-type");- if (s == null) return ""; else return s;+ if (s == null) return "";+ return s;}public String getAuthor() {@@ -392,14 +393,14 @@ public class htmlFilterContentScraper extends htmlFilterAbstractScraper implemenif (s == null) s = "";if (s.length() == 0) {return getTitle().toLowerCase().split(splitrex);- } else {- return s.split(" |,");}+ return s.split(" |,");}public int getRefreshSeconds() {final String s = metas.get("refresh");- if (s == null) return 9999; else try {+ if (s == null) return 9999;+ try {final int pos = s.indexOf(';');if (pos < 0) return 9999;final int i = Integer.parseInt(s.substring(0, pos));@@ -411,12 +412,13 @@ public class htmlFilterContentScraper extends htmlFilterAbstractScraper implemenpublic String getRefreshPath() {String s = metas.get("refresh");- if (s == null) return ""; else {- final int pos = s.indexOf(';');- if (pos < 0) return "";- s = s.substring(pos + 1);- if (s.toLowerCase().startsWith("url=")) return s.substring(4).trim(); else return "";- }+ if (s == null) return "";++ final int pos = s.indexOf(';');+ if (pos < 0) return "";+ s = s.substring(pos + 1);+ if (s.toLowerCase().startsWith("url=")) return s.substring(4).trim();+ return "";}/*diff --git a/source/de/anomic/htmlFilter/htmlFilterImageEntry.java b/source/de/anomic/htmlFilter/htmlFilterImageEntry.javaindex de495fb96..9029005d9 100644--- a/source/de/anomic/htmlFilter/htmlFilterImageEntry.java+++ b/source/de/anomic/htmlFilter/htmlFilterImageEntry.java@@ -61,10 +61,9 @@ public class htmlFilterImageEntry implements Comparable<htmlFilterImageEntry> {// this hash method therefore tries to compute a 'perfect hash' based on the size of the images// unfortunately it can not be ensured that all images get different hashes, but this should appear// only in very rare cases- if ((width >= 0) && (height >= 0))- return ((0x7FFF - (((width * height) >> 9) & 0x7FFF)) << 16) | (url.hashCode() & 0xFFFF);- else+ if (width < 0 || height < 0)return 0x7FFF0000 | (url.hashCode() & 0xFFFF);+ return ((0x7FFF - (((width * height) >> 9) & 0x7FFF)) << 16) | (url.hashCode() & 0xFFFF);}public int compareTo(final htmlFilterImageEntry h) {@@ -81,7 +80,10 @@ public class htmlFilterImageEntry implements Comparable<htmlFilterImageEntry> {return this.url.toString().compareTo((h).url.toString());}- public boolean equals(final htmlFilterImageEntry o) {- return compareTo(o) == 0;+ public boolean equals(final Object o) {+ if(o != null && o instanceof htmlFilterImageEntry) {+ return compareTo((htmlFilterImageEntry) o) == 0;+ }+ return super.equals(o);}}diff --git a/source/de/anomic/htmlFilter/htmlFilterWriter.java b/source/de/anomic/htmlFilter/htmlFilterWriter.javaindex 9d0c17c01..866f61604 100644--- a/source/de/anomic/htmlFilter/htmlFilterWriter.java+++ b/source/de/anomic/htmlFilter/htmlFilterWriter.java@@ -494,12 +494,13 @@ public final class htmlFilterWriter extends Writer {public static void main(final String[] args) {// takes one argument: a file nameif (args.length != 1) return;+ // TODO: this does not work at the moment+ System.out.println("this does not work at the moment");+ System.exit(0);final char[] buffer = new char[512];try {final htmlFilterContentScraper scraper = new htmlFilterContentScraper(new yacyURL("http://localhost:8080", null));final htmlFilterTransformer transformer = new htmlFilterContentTransformer();- // TODO: this does not work at the moment- System.exit(0);final Reader is = new FileReader(args[0]);final FileOutputStream fos = new FileOutputStream(new File(args[0] + ".out"));final Writer os = new htmlFilterWriter(fos, "UTF-8",scraper, transformer, false);diff --git a/source/de/anomic/http/DefaultCharsetFilePart.java b/source/de/anomic/http/DefaultCharsetFilePart.javanew file mode 100644index 000000000..3c329e19f--- /dev/null+++ b/source/de/anomic/http/DefaultCharsetFilePart.java@@ -0,0 +1,49 @@+// DefaultCharsetFilePart.java+// (C) 2008 by Daniel Raap; [email protected]+// first published 02.08.2008 on http://yacy.net+//+// This is a part of YaCy, a peer-to-peer based web search engine+//+// $LastChangedDate: 2008-03-14 01:16:04 +0100 (Fr, 14 Mrz 2008) $+// $LastChangedRevision: 4558 $+// $LastChangedBy: orbiter $+//+// LICENSE+//+// This program is free software; you can redistribute it and/or modify+// it under the terms of the GNU General Public License as published by+// the Free Software Foundation; either version 2 of the License, or+// (at your option) any later version.+//+// This program is distributed in the hope that it will be useful,+// but WITHOUT ANY WARRANTY; without even the implied warranty of+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+// GNU General Public License for more details.+//+// You should have received a copy of the GNU General Public License+// along with this program; if not, write to the Free Software+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA++package de.anomic.http;++import java.nio.charset.Charset;++import org.apache.commons.httpclient.methods.multipart.FilePart;+import org.apache.commons.httpclient.methods.multipart.PartSource;++/**+ * @author daniel+ *+ */+public class DefaultCharsetFilePart extends FilePart {++ /**+ * Konstruktor+ * @param name+ * @param partSource+ */+ public DefaultCharsetFilePart(String name, PartSource partSource) {+ super(name, partSource, null, Charset.defaultCharset().name());+ }++}diff --git a/source/de/anomic/http/DefaultCharsetStringPart.java b/source/de/anomic/http/DefaultCharsetStringPart.javanew file mode 100644index 000000000..e7b205394--- /dev/null+++ b/source/de/anomic/http/DefaultCharsetStringPart.java@@ -0,0 +1,50 @@+// DefaultCharsetStringPart.java+// (C) 2008 by Daniel Raap; [email protected]+// first published 02.08.2008 on http://yacy.net+//+// This is a part of YaCy, a peer-to-peer based web search engine+//+// $LastChangedDate: 2008-03-14 01:16:04 +0100 (Fr, 14 Mrz 2008) $+// $LastChangedRevision: 4558 $+// $LastChangedBy: orbiter $+//+// LICENSE+//+// This program is free software; you can redistribute it and/or modify+// it under the terms of the GNU General Public License as published by+// the Free Software Foundation; either version 2 of the License, or+// (at your option) any later version.+//+// This program is distributed in the hope that it will be useful,+// but WITHOUT ANY WARRANTY; without even the implied warranty of+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+// GNU General Public License for more details.+//+// You should have received a copy of the GNU General Public License+// along with this program; if not, write to the Free Software+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA++package de.anomic.http;++import java.nio.charset.Charset;++import org.apache.commons.httpclient.methods.multipart.StringPart;++/**+ * @author daniel+ *+ */+public class DefaultCharsetStringPart extends StringPart {++ /**+ * constructs a StringPart with the defaultCharset (instead of US-ASCII)+ *+ * @see Charset#defaultCharset()+ * @param name+ * @param value+ */+ public DefaultCharsetStringPart(String name, String value) {+ super(name, value, Charset.defaultCharset().name());+ }++}diff --git a/source/de/anomic/http/EasySSLProtocolSocketFactory.java b/source/de/anomic/http/EasySSLProtocolSocketFactory.javaindex 533b42c09..7baf70de3 100644--- a/source/de/anomic/http/EasySSLProtocolSocketFactory.java+++ b/source/de/anomic/http/EasySSLProtocolSocketFactory.java@@ -183,16 +183,17 @@ public class EasySSLProtocolSocketFactory implements SecureProtocolSocketFactory}final int timeout = params.getConnectionTimeout();final SocketFactory socketfactory = getSSLContext().getSocketFactory();+ final Socket socket;if (timeout == 0) {- return socketfactory.createSocket(host, port, localAddress, localPort);+ socket = socketfactory.createSocket(host, port, localAddress, localPort);} else {- final Socket socket = socketfactory.createSocket();+ socket = socketfactory.createSocket();final SocketAddress localaddr = new InetSocketAddress(localAddress, localPort);final SocketAddress remoteaddr = new InetSocketAddress(host, port);socket.bind(localaddr);socket.connect(remoteaddr, timeout);- return socket;}+ return socket;}/**diff --git a/source/de/anomic/http/HttpClient.java b/source/de/anomic/http/HttpClient.javaindex afd665ff6..9781b2221 100644--- a/source/de/anomic/http/HttpClient.java+++ b/source/de/anomic/http/HttpClient.java@@ -138,7 +138,7 @@ public abstract class HttpClient {** @param uri* @param header request header- * @return+ * @return null on error*/public static httpHeader whead(final String uri, final httpHeader header) {final JakartaCommonsHttpClient client = new JakartaCommonsHttpClient(10000, header, null);@@ -148,11 +148,11 @@ public abstract class HttpClient {return response.getResponseHeader();} catch (final IOException e) {serverLog.logWarning("HTTPC", "whead(" + uri + ") failed: " + e.getMessage());+ return null;} finally {if (response != null) {response.closeStream();}}- return null;}}diff --git a/source/de/anomic/http/JakartaCommonsHttpClient.java b/source/de/anomic/http/JakartaCommonsHttpClient.javaindex 590353279..bee8b8e60 100644--- a/source/de/anomic/http/JakartaCommonsHttpClient.java+++ b/source/de/anomic/http/JakartaCommonsHttpClient.java@@ -39,7 +39,6 @@ import org.apache.commons.httpclient.DefaultHttpMethodRetryHandler;import org.apache.commons.httpclient.Header;import org.apache.commons.httpclient.HostConfiguration;import org.apache.commons.httpclient.HttpClient;-import org.apache.commons.httpclient.HttpException;import org.apache.commons.httpclient.HttpMethod;import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;import org.apache.commons.httpclient.URIException;@@ -289,21 +288,14 @@ public class JakartaCommonsHttpClient {final Part[] parts;if (multiparts != null) {- parts = multiparts.toArray(new Part[0]);+ parts = multiparts.toArray(new Part[multiparts.size()]);} else {// nothing to POSTparts = new Part[0];}RequestEntity data = new MultipartRequestEntity(parts, post.getParams());if (gzipBody) {- // cache data and gzip it- final ByteArrayOutputStream zippedBytes = new ByteArrayOutputStream();- final GZIPOutputStream toZip = new GZIPOutputStream(zippedBytes);- data.writeRequest(toZip);- toZip.finish();- toZip.flush();- // use compressed data as body (not setting content length according to RFC 2616 HTTP/1.1, section 4.4)- data = new ByteArrayRequestEntity(zippedBytes.toByteArray(), data.getContentType());+ data = zipRequest(data);post.setRequestHeader(httpHeader.CONTENT_ENCODING, httpHeader.CONTENT_ENCODING_GZIP);}@@ -314,6 +306,26 @@ public class JakartaCommonsHttpClient {return execute(post);}+ /**+ * <p>stores the data of the request in a new ByteArrayRequestEntity</p>+ *+ * <p>when the request is send make sure to set content-encoding-header to gzip!</p>+ *+ * @param data+ * @return a ByteArrayRequestEntitiy with gzipped data+ * @throws IOException+ */+ private RequestEntity zipRequest(final RequestEntity data) throws IOException {+ // cache data and gzip it+ final ByteArrayOutputStream zippedBytes = new ByteArrayOutputStream();+ final GZIPOutputStream toZip = new GZIPOutputStream(zippedBytes);+ data.writeRequest(toZip);+ toZip.finish();+ toZip.flush();+ // use compressed data as body (not setting content length according to RFC 2616 HTTP/1.1, section 4.4)+ return new ByteArrayRequestEntity(zippedBytes.toByteArray(), data.getContentType());+ }+/** (non-Javadoc)* @see de.anomic.http.HttpClient#CONNECT(java.lang.String, int, de.anomic.http.httpHeader)@@ -383,22 +395,13 @@ public class JakartaCommonsHttpClient {* @param method* @return* @throws IOException- * @throws HttpException*/- private JakartaCommonsHttpResponse execute(final HttpMethod method) throws IOException, HttpException {+ private JakartaCommonsHttpResponse execute(final HttpMethod method) throws IOException {assert method != null : "precondition violated: method != null";- // ignore cookies- if(ignoreCookies) {- method.getParams().setCookiePolicy(CookiePolicy.IGNORE_COOKIES);- }- // set header- for (final Header header : headers) {- method.setRequestHeader(header);- }+ checkIgnoreCookies(method);+ setHeader(method);- // set proxy- final httpRemoteProxyConfig hostProxyConfig = getProxyConfig(method.getURI().getHost());- addProxyAuth(method, hostProxyConfig);+ final httpRemoteProxyConfig hostProxyConfig = setProxy(method);final HostConfiguration hostConfig = getProxyHostConfig(hostProxyConfig);// statistics@@ -426,6 +429,50 @@ public class JakartaCommonsHttpClient {return new JakartaCommonsHttpResponse(method);}+ /**+ * @param method+ * @return+ * @throws URIException+ */+ private httpRemoteProxyConfig setProxy(final HttpMethod method) throws URIException {+ String host = null;+ // set proxy+ try {+ host = method.getURI().getHost();+ } catch (final URIException e) {+ serverLog.logWarning("HTTPC", "could not extract host of uri: "+ e.getMessage());+ throw e;+ }+ final httpRemoteProxyConfig hostProxyConfig = getProxyConfig(host);+ final String scheme = method.getURI().getScheme();+ if(scheme != null && scheme.toLowerCase().startsWith("https") && !hostProxyConfig.useProxy4SSL()) {+ // do not use proxy for HTTPS+ return null;+ }+ addProxyAuth(method, hostProxyConfig);+ return hostProxyConfig;+ }++ /**+ * @param method+ */+ private void setHeader(final HttpMethod method) {+ // set header+ for (final Header header : headers) {+ method.setRequestHeader(header);+ }+ }++ /**+ * @param method+ */+ private void checkIgnoreCookies(final HttpMethod method) {+ // ignore cookies+ if(ignoreCookies) {+ method.getParams().setCookiePolicy(CookiePolicy.IGNORE_COOKIES);+ }+ }+/*** @param method* @return@@ -477,10 +524,10 @@ public class JakartaCommonsHttpClient {final httpRemoteProxyConfig hostProxyConfig;if (proxyConfig != null) {// client specific- hostProxyConfig = httpdProxyHandler.getProxyConfig(hostname, proxyConfig);+ hostProxyConfig = proxyConfig.useForHost(hostname) ? proxyConfig : null;} else {// default settings- hostProxyConfig = httpdProxyHandler.getProxyConfig(hostname, 0);+ hostProxyConfig = httpRemoteProxyConfig.getProxyConfigForHost(hostname);}return hostProxyConfig;}@@ -490,16 +537,17 @@ public class JakartaCommonsHttpClient {* @return current host-config with additional proxy set or null if no proxy should be used*/private HostConfiguration getProxyHostConfig(final httpRemoteProxyConfig hostProxyConfig) {+ final HostConfiguration hostConfig;// generate http-configurationif (hostProxyConfig != null && hostProxyConfig.useProxy()) {// new config based on client (default)- final HostConfiguration hostConfig = new HostConfiguration(apacheHttpClient.getHostConfiguration());+ hostConfig = new HostConfiguration(apacheHttpClient.getHostConfiguration());// add proxyhostConfig.setProxy(hostProxyConfig.getProxyHost(), hostProxyConfig.getProxyPort());- return hostConfig;} else {- return null;+ hostConfig = null;}+ return hostConfig;}/**@@ -548,7 +596,7 @@ public class JakartaCommonsHttpClient {if (args.length > 1 && "post".equals(args[1])) {// POSTfinal ArrayList<Part> files = new ArrayList<Part>();- files.add(new FilePart("myfile.txt", new ByteArrayPartSource("myfile.txt", "this is not a file ;)"+ files.add(new DefaultCharsetFilePart("myfile.txt", new ByteArrayPartSource("myfile.txt", "this is not a file ;)".getBytes())));files.add(new FilePart("anotherfile.raw", new ByteArrayPartSource("anotherfile.raw","this is not a binary file ;)".getBytes())));diff --git a/source/de/anomic/http/JakartaCommonsHttpResponse.java b/source/de/anomic/http/JakartaCommonsHttpResponse.javaindex e0050ab4d..c9f31d783 100644--- a/source/de/anomic/http/JakartaCommonsHttpResponse.java+++ b/source/de/anomic/http/JakartaCommonsHttpResponse.java@@ -26,7 +26,6 @@package de.anomic.http;-import java.io.ByteArrayOutputStream;import java.io.IOException;import java.io.InputStream;import java.util.zip.GZIPInputStream;@@ -34,6 +33,8 @@ import java.util.zip.GZIPInputStream;import org.apache.commons.httpclient.Header;import org.apache.commons.httpclient.HttpMethod;+import de.anomic.server.serverFileUtils;+/*** container for http-response data*@@ -93,14 +94,7 @@ public class JakartaCommonsHttpResponse {try {instream = getDataAsStream();if (instream != null) {- final ByteArrayOutputStream outstream = new ByteArrayOutputStream();- final byte[] buffer = new byte[4096];- int len;- while ((len = instream.read(buffer)) > 0) {- outstream.write(buffer, 0, len);- }- outstream.close();- responseBody = outstream.toByteArray();+ responseBody = serverFileUtils.read(instream);}} finally {if (instream != null) {@@ -118,15 +112,15 @@ public class JakartaCommonsHttpResponse {*/public InputStream getDataAsStream() throws IOException {InputStream inStream = method.getResponseBodyAsStream();- if(inStream != null) {- if (getResponseHeader().gzip()) {- inStream = new GZIPInputStream(inStream);- }- // count bytes for overall http-statistics- return new httpdByteCountInputStream(inStream, incomingAccountingName);- } else {+ if(inStream == null) {return null;}++ if (getResponseHeader().gzip()) {+ inStream = new GZIPInputStream(inStream);+ }+ // count bytes for overall http-statistics+ return new httpdByteCountInputStream(inStream, incomingAccountingName);}/*diff --git a/source/de/anomic/http/httpRemoteProxyConfig.java b/source/de/anomic/http/httpRemoteProxyConfig.javaindex a75f62a30..5dcd58366 100644--- a/source/de/anomic/http/httpRemoteProxyConfig.java+++ b/source/de/anomic/http/httpRemoteProxyConfig.java@@ -32,6 +32,7 @@ package de.anomic.http;import java.util.Arrays;import java.util.HashSet;+import java.util.Set;import de.anomic.plasma.plasmaSwitchboard;@@ -51,8 +52,97 @@ public final class httpRemoteProxyConfig {private String[] remoteProxyNoProxyPatterns = null;- public final HashSet<String> remoteProxyAllowProxySet = new HashSet<String>();- public final HashSet<String> remoteProxyDisallowProxySet = new HashSet<String>();+ private final Set<String> remoteProxyAllowProxySet = new HashSet<String>();+ private final Set<String> remoteProxyDisallowProxySet = new HashSet<String>();++ /**+ * *The* remote Proxy configuration+ */+ private static httpRemoteProxyConfig remoteProxyConfig = null;++ /**+ * @param remoteProxyConfig the remoteProxyConfig to set+ */+ public static synchronized void setRemoteProxyConfig(final httpRemoteProxyConfig remoteProxyConfig) {+ httpRemoteProxyConfig.remoteProxyConfig = remoteProxyConfig;+ }++ /**+ * @return the remoteProxyConfig+ */+ public static httpRemoteProxyConfig getRemoteProxyConfig() {+ return remoteProxyConfig;+ }++ /**+ * creates a new remoteProxyConfig for given proxy+ *+ * @param proxyHostName+ * @param proxyHostPort+ * @return+ */+ public static httpRemoteProxyConfig createRemoteProxyConfig(+ final String proxyHostName,+ final int proxyHostPort+ ) {+ final httpRemoteProxyConfig newConfig = new httpRemoteProxyConfig();++ newConfig.remoteProxyUse = true;+ newConfig.remoteProxyUse4SSL = true;+ newConfig.remoteProxyUse4Yacy = true;+ newConfig.remoteProxyPort = proxyHostPort;+ newConfig.remoteProxyHost = proxyHostName;+ if ((newConfig.remoteProxyHost == null) || (newConfig.remoteProxyHost.length() == 0)) {+ newConfig.remoteProxyUse = false;+ }++ return newConfig;+ }++ /**+ * initializes the global remoteProxyConfig with values from plasmaSwitchboard (config)+ *+ * @param sb+ * @return+ */+ public static void init(final plasmaSwitchboard sb) {+ // reading the proxy host name+ final String proxyHostName = sb.getConfig("remoteProxyHost", "").trim();+ // reading the proxy host port+ int proxyHostPort;+ try {+ proxyHostPort = Integer.parseInt(sb.getConfig("remoteProxyPort", "3128"));+ } catch (final NumberFormatException e) {+ proxyHostPort = 3128;+ }+ // create new config+ final httpRemoteProxyConfig newConfig = createRemoteProxyConfig(proxyHostName, proxyHostPort);++ // determining if remote proxy usage is enabled+ newConfig.remoteProxyUse = newConfig.remoteProxyUse && sb.getConfigBool("remoteProxyUse", false);++ // determining if remote proxy should be used for yacy -> yacy communication+ newConfig.remoteProxyUse4Yacy = sb.getConfig("remoteProxyUse4Yacy", "true").equalsIgnoreCase("true");++ // determining if remote proxy should be used for ssl connections+ newConfig.remoteProxyUse4SSL = sb.getConfig("remoteProxyUse4SSL", "true").equalsIgnoreCase("true");++ newConfig.remoteProxyUser = sb.getConfig("remoteProxyUser", "").trim();+ newConfig.remoteProxyPwd = sb.getConfig("remoteProxyPwd", "").trim();++ // determining addresses for which the remote proxy should not be used+ final String remoteProxyNoProxy = sb.getConfig("remoteProxyNoProxy","").trim();+ newConfig.remoteProxyNoProxyPatterns = remoteProxyNoProxy.split(",");+ // trim split entries+ int i = 0;+ for(final String pattern: newConfig.remoteProxyNoProxyPatterns) {+ newConfig.remoteProxyNoProxyPatterns[i] = pattern.trim();+ i++;+ }++ setRemoteProxyConfig(newConfig);+ sb.getLog().logConfig("Remote proxy configuration:\n" + getRemoteProxyConfig().toString());+ }public boolean useProxy() {return this.remoteProxyUse;@@ -82,8 +172,27 @@ public final class httpRemoteProxyConfig {return this.remoteProxyPwd;}- public String[] getProxyNoProxyPatterns() {- return this.remoteProxyNoProxyPatterns;+ /**+ * checks if server matches the noProxyPattern and caches result as (Dis-)AllowedHost+ *+ * @param server+ * @return+ */+ public boolean matchesProxyNoProxyPatterns(final String server) {+ boolean noProxy = false;+ for (final String pattern :remoteProxyNoProxyPatterns) {+ if (server.matches(pattern)) {+ noProxy = true;+ break;+ }+ }+ // set either remoteProxyAllowProxySet or remoteProxyDisallowProxySet accordingly+ if(noProxy) {+ addDisallowedHost(server);+ } else {+ addAllowedHost(server);+ }+ return noProxy;}public String toString() {@@ -108,63 +217,101 @@ public final class httpRemoteProxyConfig {return toStrBuf.toString();}++ /**+ * @param host+ * @return+ */+ public boolean isHostAllowedToUseProxy(final String host) {+ return remoteProxyAllowProxySet.contains(host);+ }++ /**+ * @param host+ * @return+ */+ public boolean isHostNotAllowedToUseProxy(final String host) {+ return remoteProxyDisallowProxySet.contains(host);+ }- public static httpRemoteProxyConfig init(- final String proxyHostName,- final int proxyHostPort- ) {- final httpRemoteProxyConfig newConfig = new httpRemoteProxyConfig();-- newConfig.remoteProxyUse = true;- newConfig.remoteProxyUse4SSL = true;- newConfig.remoteProxyUse4Yacy = true;- newConfig.remoteProxyPort = proxyHostPort;- newConfig.remoteProxyHost = proxyHostName;- if ((newConfig.remoteProxyHost == null) || (newConfig.remoteProxyHost.length() == 0)) {- newConfig.remoteProxyUse = false;- }-- return newConfig;+ /**+ * @param host+ */+ public void addAllowedHost(final String host) {+ remoteProxyAllowProxySet.add(host);}- public static httpRemoteProxyConfig init(final plasmaSwitchboard sb) {- final httpRemoteProxyConfig newConfig = new httpRemoteProxyConfig();-- // determining if remote proxy usage is enabled- newConfig.remoteProxyUse = sb.getConfig("remoteProxyUse", "false").equalsIgnoreCase("true");-- // determining if remote proxy should be used for yacy -> yacy communication- newConfig.remoteProxyUse4Yacy = sb.getConfig("remoteProxyUse4Yacy", "true").equalsIgnoreCase("true");-- // determining if remote proxy should be used for ssl connections- newConfig.remoteProxyUse4SSL = sb.getConfig("remoteProxyUse4SSL", "true").equalsIgnoreCase("true");-- // reading the proxy host name- newConfig.remoteProxyHost = sb.getConfig("remoteProxyHost", "").trim();- if ((newConfig.remoteProxyHost == null) || (newConfig.remoteProxyHost.length() == 0)) {- newConfig.remoteProxyUse = false;+ /**+ * @param host+ */+ public void addDisallowedHost(final String host) {+ remoteProxyDisallowProxySet.add(host);+ }++ /**+ * checks if proxy-config is allowed and not denied+ *+ * @param server+ * @param remProxyConfig+ * @return proxy which should be used or null if no proxy should be used for server+ */+ public boolean useForHost(final String server) {+ // possible remote proxy+ // check no-proxy rule+ boolean useProxy;+ if (useProxy()) {+ useProxy = true;+ if (!isHostAllowedToUseProxy(server)) {+ if (isHostNotAllowedToUseProxy(server)) {+ useProxy = false;+ } else {+ // analyse remoteProxyNoProxy;+ if(matchesProxyNoProxyPatterns(server)) {+ useProxy = false;+ }+ }+ }+ } else {+ // not enabled+ useProxy = false;}-- // reading the proxy host port- try {- newConfig.remoteProxyPort = Integer.parseInt(sb.getConfig("remoteProxyPort", "3128"));- } catch (final NumberFormatException e) {- newConfig.remoteProxyPort = 3128;++ return useProxy;+ }++ /**+ * checks if proxy-config exists for server (is allowed and not denied)+ *+ * @param server+ * @return proxy which should be used or null if no proxy should be used+ */+ public static httpRemoteProxyConfig getProxyConfigForHost(final String server) {+ final httpRemoteProxyConfig proxyConfig = getRemoteProxyConfig();+ if(proxyConfig == null || !proxyConfig.useForHost(server)) {+ return null;}-- newConfig.remoteProxyUser = sb.getConfig("remoteProxyUser", "").trim();- newConfig.remoteProxyPwd = sb.getConfig("remoteProxyPwd", "").trim();-- // determining addresses for which the remote proxy should not be used- final String remoteProxyNoProxy = sb.getConfig("remoteProxyNoProxy","").trim();- newConfig.remoteProxyNoProxyPatterns = remoteProxyNoProxy.split(",");- // trim split entries- int i = 0;- for(final String pattern: newConfig.remoteProxyNoProxyPatterns) {- newConfig.remoteProxyNoProxyPatterns[i] = pattern.trim();- i++;+ return proxyConfig;+ }++ /**+ * gets proxy config for full adress (without protocol) ie. "localhost:8080/path/file.html"+ *+ * @param address full address with host and optionally port or path <host>:<port>/<path>+ * @return null if no proxy should be used+ */+ public static httpRemoteProxyConfig getProxyConfigForURI(final String address) {+ // host goes to port+ int p = address.indexOf(":");+ if (p < 0) {+ // no port, so host goes to path+ p = address.indexOf("/");}-- return newConfig;+ // host should have minimum 1 character ;)+ if(p > 0) {+ final String server = address.substring(0, p);+ return getProxyConfigForHost(server);+ }+ // check if full address is in allow/deny-list+ return getProxyConfigForHost(address);}}diff --git a/source/de/anomic/http/httpTemplate.java b/source/de/anomic/http/httpTemplate.javaindex aa1548b2e..ea12f6b2d 100644--- a/source/de/anomic/http/httpTemplate.java+++ b/source/de/anomic/http/httpTemplate.java@@ -378,11 +378,10 @@ public final class httpTemplate {}keyStream = new ByteArrayOutputStream(); //reset streamcontinue;- }else{ //is not #(- pis.unread(bb);//is processed in next loop- bb = (hash);//will be added to text this loop- //text += "#";- }+ } //is not #(+ pis.unread(bb);//is processed in next loop+ bb = (hash);//will be added to text this loop+ //text += "#";}else if( (bb & 0xFF) == ':' && others==0){//ignore :: in nested Expressionsbb=pis.read();if( (bb & 0xFF) == ':'){@@ -399,9 +398,8 @@ public final class httpTemplate {currentPattern++;text.clear();continue;- }else{- text.append(":".getBytes("UTF-8"));}+ text.append(":".getBytes("UTF-8"));}if(!found){text.append((byte)bb);diff --git a/source/de/anomic/http/httpd.java b/source/de/anomic/http/httpd.javaindex 0902716bd..115458201 100644--- a/source/de/anomic/http/httpd.java+++ b/source/de/anomic/http/httpd.java@@ -35,7 +35,6 @@ import java.io.PrintStream;import java.io.UnsupportedEncodingException;import java.net.InetAddress;import java.net.MalformedURLException;-import java.net.URLDecoder;import java.net.URLEncoder;import java.util.Arrays;import java.util.Date;@@ -70,7 +69,7 @@ import de.anomic.yacy.yacyURL;* these methods parse the command line and decide wether to call* a proxy servlet or a file server servlet*/-public final class httpd implements serverHandler {+public final class httpd implements serverHandler, Cloneable {/*** <p><code>public static final String <strong>ADMIN_ACCOUNT_B64MD5</strong> = "adminAccountBase64MD5"</code></p>@@ -99,8 +98,8 @@ public final class httpd implements serverHandler {public static final String copyright = "[ HTTP SERVER: AnomicHTTPD v" + vDATE + " by Michael Christen / www.anomic.de ]";public static final String hline = "-------------------------------------------------------------------------------";- public static HashMap<String, String> reverseMappingCache = new HashMap<String, String>();- private static plasmaSwitchboard switchboard = null;+ public static final HashMap<String, String> reverseMappingCache = new HashMap<String, String>();+ private static volatile plasmaSwitchboard switchboard = null;private static String virtualHost = null;public static boolean keepAliveSupport = false;@@ -331,9 +330,8 @@ public final class httpd implements serverHandler {if ((pos = host.indexOf(":")) < 0) {// default port 80return false; // not allowed- } else {- if (Integer.parseInt(host.substring(pos + 1)) == 80) return false;}+ if (Integer.parseInt(host.substring(pos + 1)) == 80) return false;// the access path must be into the yacy protocol path; it must start with 'yacy'if (!(this.prop.getProperty(httpHeader.CONNECTION_PROP_PATH, "").startsWith("/yacy/"))) return false;@@ -440,12 +438,12 @@ public final class httpd implements serverHandler {return serverCore.RESUME_CONNECTION;}- public Boolean TRACE(final String arg) throws IOException {+ public Boolean TRACE() throws IOException {sendRespondError(this.prop,this.session.out,0,501,null,"TRACE method not implemented",null);return serverCore.TERMINATE_CONNECTION;}- public Boolean OPTIONS(final String arg) throws IOException {+ public Boolean OPTIONS() throws IOException {sendRespondError(this.prop,this.session.out,0,501,null,"OPTIONS method not implemented",null);return serverCore.TERMINATE_CONNECTION;}@@ -661,7 +659,7 @@ public final class httpd implements serverHandler {int port = 443;if (pos >= 0) {port = Integer.parseInt(arg.substring(pos + 1));- arg = arg.substring(0, pos);+ //the offcut: arg = arg.substring(0, pos);}// setting other connection properties@@ -1047,7 +1045,6 @@ public final class httpd implements serverHandler {}public static final void sendRespondBody(- final Properties conProp,final OutputStream respond,final byte[] body) throws IOException {@@ -1135,7 +1132,7 @@ public final class httpd implements serverHandler {final String method = conProp.getProperty(httpHeader.CONNECTION_PROP_METHOD);int port = 80;- final int pos = host.indexOf(":");+ final int pos = host.indexOf(":");if (pos != -1) {port = Integer.parseInt(host.substring(pos + 1));host = host.substring(0, pos);diff --git a/source/de/anomic/http/httpdFileHandler.java b/source/de/anomic/http/httpdFileHandler.javaindex 9e2669c16..e4fdc72ad 100644--- a/source/de/anomic/http/httpdFileHandler.java+++ b/source/de/anomic/http/httpdFileHandler.java@@ -80,6 +80,7 @@ import java.util.zip.GZIPOutputStream;import de.anomic.htmlFilter.htmlFilterContentScraper;import de.anomic.plasma.plasmaParser;import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.plasma.plasmaSwitchboardConstants;import de.anomic.server.serverByteBuffer;import de.anomic.server.serverClassLoader;import de.anomic.server.serverCore;@@ -153,7 +154,7 @@ public final class httpdFileHandler {// create a htDocsPath: user defined pagesif (htDocsPath == null) {- htDocsPath = theSwitchboard.getConfigPath(plasmaSwitchboard.HTDOCS_PATH, plasmaSwitchboard.HTDOCS_PATH_DEFAULT);+ htDocsPath = theSwitchboard.getConfigPath(plasmaSwitchboardConstants.HTDOCS_PATH, plasmaSwitchboardConstants.HTDOCS_PATH_DEFAULT);if (!(htDocsPath.exists())) htDocsPath.mkdirs();}@@ -1014,8 +1015,8 @@ public final class httpdFileHandler {return result;}- public void doConnect(final Properties conProp, final httpHeader requestHeader, final InputStream clientIn, final OutputStream clientOut) {- throw new UnsupportedOperationException();- }+// public void doConnect(Properties conProp, httpHeader requestHeader, InputStream clientIn, OutputStream clientOut) {+// throw new UnsupportedOperationException();+// }}diff --git a/source/de/anomic/http/httpdProxyHandler.java b/source/de/anomic/http/httpdProxyHandler.javaindex 729aeeccd..cf0577bab 100644--- a/source/de/anomic/http/httpdProxyHandler.java+++ b/source/de/anomic/http/httpdProxyHandler.java@@ -84,6 +84,7 @@ import de.anomic.index.indexReferenceBlacklist;import de.anomic.plasma.plasmaHTCache;import de.anomic.plasma.plasmaParser;import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.plasma.plasmaSwitchboardConstants;import de.anomic.plasma.cache.IResourceInfo;import de.anomic.plasma.cache.http.ResourceInfo;import de.anomic.server.serverCore;@@ -110,10 +111,6 @@ public final class httpdProxyHandler {private static BufferedReader redirectorReader = null;private static htmlFilterTransformer transformer = null;- /**- * *The* remote Proxy configuration- */- private static httpRemoteProxyConfig remoteProxyConfig = null;private static File htRootPath = null;//private Properties connectionProperties = null;@@ -184,11 +181,10 @@ public final class httpdProxyHandler {// load a transformertransformer = new htmlFilterContentTransformer();- transformer.init(new File(switchboard.getRootPath(), switchboard.getConfig(plasmaSwitchboard.LIST_BLUE, "")).toString());+ transformer.init(new File(switchboard.getRootPath(), switchboard.getConfig(plasmaSwitchboardConstants.LIST_BLUE, "")).toString());- String f;// load the yellow-list- f = switchboard.getConfig("proxyYellowList", null);+ final String f = switchboard.getConfig("proxyYellowList", null);if (f != null) {yellowList = serverFileUtils.loadList(new File(f));theLogger.logConfig("loaded yellow-list from file " + f + ", " + yellowList.size() + " entries");@@ -1117,6 +1113,7 @@ public final class httpdProxyHandler {* creates a new HttpClient and sets parameters according to proxy needs** @param requestHeader+ * @param connectHost may be 'host:port' or 'host:port/path'* @return*/private static JakartaCommonsHttpClient setupHttpClient(final httpHeader requestHeader, final String connectHost) {@@ -1125,7 +1122,7 @@ public final class httpdProxyHandler {client.setFollowRedirects(false);// cookies are handled by the user's browserclient.setIgnoreCookies(true);- client.setProxy(getProxyConfig(connectHost));+ client.setProxy(httpRemoteProxyConfig.getProxyConfigForURI(connectHost));return client;}@@ -1294,7 +1291,7 @@ public final class httpdProxyHandler {}// possibly branch into PROXY-PROXY connection- final httpRemoteProxyConfig proxyConfig = getRemoteProxyConfig();+ final httpRemoteProxyConfig proxyConfig = httpRemoteProxyConfig.getRemoteProxyConfig();if ((proxyConfig != null) &&(proxyConfig.useProxy()) &&@@ -1405,82 +1402,6 @@ public final class httpdProxyHandler {}}- /**- * checks if proxy-config exists for server (is allowed and not denied)- *- * @param server- * @param port not used (only to indicate that server is plain address)- * @return proxy which should be used or null if no proxy should be used- */- public static httpRemoteProxyConfig getProxyConfig(final String server, final int port) {- return getProxyConfig(server, getRemoteProxyConfig());- }-- /**- * checks if proxy-config is allowed and not denied- *- * @param server- * @param remProxyConfig- * @return proxy which should be used or null if no proxy should be used- */- public static httpRemoteProxyConfig getProxyConfig(final String server, httpRemoteProxyConfig remProxyConfig) {- // possible remote proxy- // check no-proxy rule- if (remProxyConfig != null) {- if (remProxyConfig.useProxy()) {- if (!(remProxyConfig.remoteProxyAllowProxySet.contains(server))) {- if (remProxyConfig.remoteProxyDisallowProxySet.contains(server)) {- remProxyConfig = null;- } else {- // analyse remoteProxyNoProxy;- // set either remoteProxyAllowProxySet or remoteProxyDisallowProxySet accordingly- synchronized (remProxyConfig) {- for (final String pattern :remProxyConfig.getProxyNoProxyPatterns()) {- if (server.matches(pattern)) {- // disallow proxy for this server- remProxyConfig.remoteProxyDisallowProxySet.add(server);- remProxyConfig = null;- break;- }- }- if (remProxyConfig != null) {- // no pattern matches: allow server- remProxyConfig.remoteProxyAllowProxySet.add(server);- }- }- }- }- } else {- // not enabled- remProxyConfig = null;- }- }-- return remProxyConfig;- }-- /**- * gets proxy config for full adress (without protocol (ie. "http://"))- * @param address full address with host and optionally port or path <host>:<port>/<path>- * @return null if no proxy should be used- */- public static httpRemoteProxyConfig getProxyConfig(final String address) {- // host goes to port- int p = address.indexOf(":");- if (p < 0) {- // no port, so host goes to path- p = address.indexOf("/");- }- // host should have minimum 1 character ;)- if(p > 0) {- final String server = address.substring(0, p);- return getProxyConfig(server, 0);- } else {- // check if full address is in allow/deny-list- return getProxyConfig(address, 0);- }- }-private static void handleProxyException(final Exception e, final Properties conProp, final OutputStream respond, final yacyURL url) {// this may happen if// - the targeted host does not exist@@ -1788,20 +1709,6 @@ public final class httpdProxyHandler {// sending the logging message to the loggerproxyLog.logFine(logMessage.toString());}-- /**- * @param remoteProxyConfig the remoteProxyConfig to set- */- public static synchronized void setRemoteProxyConfig(final httpRemoteProxyConfig remoteProxyConfig) {- httpdProxyHandler.remoteProxyConfig = remoteProxyConfig;- }-- /**- * @return the remoteProxyConfig- */- public static httpRemoteProxyConfig getRemoteProxyConfig() {- return remoteProxyConfig;- }}diff --git a/source/de/anomic/http/httpdRobotsTxtConfig.java b/source/de/anomic/http/httpdRobotsTxtConfig.javaindex e58c288db..147313d15 100644--- a/source/de/anomic/http/httpdRobotsTxtConfig.java+++ b/source/de/anomic/http/httpdRobotsTxtConfig.java@@ -28,7 +28,7 @@package de.anomic.http;-import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.plasma.plasmaSwitchboardConstants;import de.anomic.server.serverSwitch;public final class httpdRobotsTxtConfig {@@ -84,7 +84,7 @@ public final class httpdRobotsTxtConfig {}public static httpdRobotsTxtConfig init(final serverSwitch<?> env) {- final String cfg = env.getConfig(plasmaSwitchboard.ROBOTS_TXT, plasmaSwitchboard.ROBOTS_TXT_DEFAULT);+ final String cfg = env.getConfig(plasmaSwitchboardConstants.ROBOTS_TXT, plasmaSwitchboardConstants.ROBOTS_TXT_DEFAULT);if (cfg == null) return new httpdRobotsTxtConfig();return new httpdRobotsTxtConfig(cfg.split(","));}diff --git a/source/de/anomic/icap/icapd.java b/source/de/anomic/icap/icapd.javaindex 1724334d4..e0153e3d6 100644--- a/source/de/anomic/icap/icapd.java+++ b/source/de/anomic/icap/icapd.java@@ -55,7 +55,7 @@ import de.anomic.yacy.yacyURL;/*** @author theli*/-public class icapd implements serverHandler {+public class icapd implements serverHandler, Cloneable {private serverCore.Session session; // holds the session object of the calling class@@ -178,7 +178,7 @@ public class icapd implements serverHandler {return this.prop.getProperty(icapHeader.CONNECTION_PROP_PERSISTENT).equals("keep-alive") ? serverCore.RESUME_CONNECTION : serverCore.TERMINATE_CONNECTION;}- public Boolean REQMOD(final String arg) {+ public Boolean REQMOD() {return serverCore.TERMINATE_CONNECTION;}diff --git a/source/de/anomic/index/indexCollectionRI.java b/source/de/anomic/index/indexCollectionRI.javaindex 48aff91ad..13468a686 100644--- a/source/de/anomic/index/indexCollectionRI.java+++ b/source/de/anomic/index/indexCollectionRI.java@@ -129,11 +129,7 @@ public class indexCollectionRI implements indexRI {}public boolean hasContainer(final String wordHash) {- try {- return collectionIndex.has(wordHash.getBytes());- } catch (final IOException e) {- return false;- }+ return collectionIndex.has(wordHash.getBytes());}public indexContainer getContainer(final String wordHash, final Set<String> urlselection) {diff --git a/source/de/anomic/index/indexContainer.java b/source/de/anomic/index/indexContainer.javaindex a5200b840..d0f185a4e 100644--- a/source/de/anomic/index/indexContainer.java+++ b/source/de/anomic/index/indexContainer.java@@ -118,15 +118,13 @@ public class indexContainer extends kelondroRowSet {final kelondroRow.Entry oldEntryRow = this.put(entry.toKelondroEntry());if (oldEntryRow == null) {return true;- } else {- final indexRWIRowEntry oldEntry = new indexRWIRowEntry(oldEntryRow);- if (entry.isOlder(oldEntry)) { // A more recent Entry is already in this container- this.put(oldEntry.toKelondroEntry()); // put it back- return false;- } else {- return true;- }}+ final indexRWIRowEntry oldEntry = new indexRWIRowEntry(oldEntryRow);+ if (entry.isOlder(oldEntry)) { // A more recent Entry is already in this container+ this.put(oldEntry.toKelondroEntry()); // put it back+ return false;+ }+ return true;}public int putAllRecent(final indexContainer c) {@@ -196,21 +194,23 @@ public class indexContainer extends kelondroRowSet {}- public static Method containerMergeMethod = null;+ public static final Method containerMergeMethod;static {+ Method meth = null;try {final Class<?> c = Class.forName("de.anomic.index.indexContainer");- containerMergeMethod = c.getMethod("mergeUnique", new Class[]{Object.class, Object.class});+ meth = c.getMethod("mergeUnique", new Class[]{Object.class, Object.class});} catch (final SecurityException e) {System.out.println("Error while initializing containerMerge.SecurityException: " + e.getMessage());- containerMergeMethod = null;+ meth = null;} catch (final ClassNotFoundException e) {System.out.println("Error while initializing containerMerge.ClassNotFoundException: " + e.getMessage());- containerMergeMethod = null;+ meth = null;} catch (final NoSuchMethodException e) {System.out.println("Error while initializing containerMerge.NoSuchMethodException: " + e.getMessage());- containerMergeMethod = null;+ meth = null;}+ containerMergeMethod = meth;}public static indexContainer joinExcludeContainers(@@ -309,9 +309,8 @@ public class indexContainer extends kelondroRowSet {return joinConstructiveByTest(i1, i2, maxDistance);elsereturn joinConstructiveByTest(i2, i1, maxDistance);- } else {- return joinConstructiveByEnumeration(i1, i2, maxDistance);}+ return joinConstructiveByEnumeration(i1, i2, maxDistance);}private static indexContainer joinConstructiveByTest(final indexContainer small, final indexContainer large, final int maxDistance) {@@ -390,9 +389,8 @@ public class indexContainer extends kelondroRowSet {// start most efficient methodif (stepsEnum > stepsTest) {return excludeDestructiveByTest(pivot, excl);- } else {- return excludeDestructiveByEnumeration(pivot, excl);}+ return excludeDestructiveByEnumeration(pivot, excl);}private static indexContainer excludeDestructiveByTest(final indexContainer pivot, final indexContainer excl) {diff --git a/source/de/anomic/index/indexContainerHeap.java b/source/de/anomic/index/indexContainerHeap.javaindex 531bf7bad..db720c438 100755--- a/source/de/anomic/index/indexContainerHeap.java+++ b/source/de/anomic/index/indexContainerHeap.java@@ -317,15 +317,13 @@ public final class indexContainerHeap {public indexContainer next() {if (iterator.hasNext()) {return (iterator.next()).topLevelClone();- } else {- // rotation iteration- if (rot) {- iterator = cache.values().iterator();- return (iterator.next()).topLevelClone();- } else {- return null;- }}+ // rotation iteration+ if (!rot) {+ return null;+ }+ iterator = cache.values().iterator();+ return (iterator.next()).topLevelClone();}public void remove() {@@ -356,9 +354,8 @@ public final class indexContainerHeap {e.printStackTrace();return false;}- } else {- return this.cache.containsKey(key);}+ return this.cache.containsKey(key);}/**@@ -390,9 +387,9 @@ public final class indexContainerHeap {} catch (final IOException e) {log.logSevere("error accessing entry in heap file " + this.backupFile + ": " + e.getMessage());return null;- } else {- return this.cache.get(key);}++ return this.cache.get(key);}/**diff --git a/source/de/anomic/index/indexContainerOrder.java b/source/de/anomic/index/indexContainerOrder.javaindex 25e212753..3eadf5233 100644--- a/source/de/anomic/index/indexContainerOrder.java+++ b/source/de/anomic/index/indexContainerOrder.java@@ -29,7 +29,7 @@ package de.anomic.index;import de.anomic.kelondro.kelondroAbstractOrder;import de.anomic.kelondro.kelondroOrder;-public class indexContainerOrder extends kelondroAbstractOrder<indexContainer> implements kelondroOrder<indexContainer> {+public class indexContainerOrder extends kelondroAbstractOrder<indexContainer> implements kelondroOrder<indexContainer>, Cloneable {private final kelondroOrder<byte[]> embeddedOrder;diff --git a/source/de/anomic/index/indexRAMRI.java b/source/de/anomic/index/indexRAMRI.javaindex c89808d69..aecc5beb1 100644--- a/source/de/anomic/index/indexRAMRI.java+++ b/source/de/anomic/index/indexRAMRI.java@@ -51,7 +51,7 @@ public final class indexRAMRI implements indexRI, indexRIReader {private indexContainerHeap heap;@SuppressWarnings("unchecked")- public indexRAMRI(final File databaseRoot, final kelondroRow payloadrow, final int entityCacheMaxSize, final int wCacheReferenceCountLimitInit, final long wCacheReferenceAgeLimitInit, final String oldArrayName, final String newHeapName, final serverLog log) {+ public indexRAMRI(final File databaseRoot, final kelondroRow payloadrow, final int entityCacheMaxSize, final int wCacheReferenceCountLimitInit, final long wCacheReferenceAgeLimitInit, final String newHeapName, final serverLog log) {// creates a new index cache// the cache has a back-end where indexes that do not fit in the cache are flusheddiff --git a/source/de/anomic/index/indexRWIRowEntry.java b/source/de/anomic/index/indexRWIRowEntry.javaindex 77b7250cd..d3df34790 100644--- a/source/de/anomic/index/indexRWIRowEntry.java+++ b/source/de/anomic/index/indexRWIRowEntry.java@@ -34,11 +34,11 @@ import de.anomic.kelondro.kelondroRow;import de.anomic.kelondro.kelondroRow.Entry;import de.anomic.yacy.yacySeedDB;-public final class indexRWIRowEntry implements indexRWIEntry {+public final class indexRWIRowEntry implements indexRWIEntry, Cloneable {// this object stores attributes to URL references inside RWI collections- public static kelondroRow urlEntryRow = new kelondroRow(new kelondroColumn[]{+ public static final kelondroRow urlEntryRow = new kelondroRow(new kelondroColumn[]{new kelondroColumn("h", kelondroColumn.celltype_string, kelondroColumn.encoder_bytes, yacySeedDB.commonHashLength, "urlhash"),new kelondroColumn("a", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 2, "lastModified"),new kelondroColumn("s", kelondroColumn.celltype_cardinal, kelondroColumn.encoder_b256, 2, "freshUntil"),diff --git a/source/de/anomic/index/indexRWIVarEntry.java b/source/de/anomic/index/indexRWIVarEntry.javaindex df533ada9..05355d4fe 100644--- a/source/de/anomic/index/indexRWIVarEntry.java+++ b/source/de/anomic/index/indexRWIVarEntry.java@@ -29,7 +29,7 @@ package de.anomic.index;import de.anomic.kelondro.kelondroBitfield;import de.anomic.kelondro.kelondroMicroDate;-public class indexRWIVarEntry implements indexRWIEntry {+public class indexRWIVarEntry implements indexRWIEntry, Cloneable {public kelondroBitfield flags;public long freshUntil, lastModified;diff --git a/source/de/anomic/index/indexRepositoryReference.java b/source/de/anomic/index/indexRepositoryReference.javaindex ace200e55..71bf9e526 100644--- a/source/de/anomic/index/indexRepositoryReference.java+++ b/source/de/anomic/index/indexRepositoryReference.java@@ -104,7 +104,7 @@ public final class indexRepositoryReference {}}- public synchronized void store(indexURLReference entry) throws IOException {+ public synchronized void store(final indexURLReference entry) throws IOException {// Check if there is a more recent Entry already in the DBindexURLReference oldEntry;try {@@ -121,7 +121,8 @@ public final class indexRepositoryReference {// the fetched oldEntry is better, so return its properties instead of the new ones// this.urlHash = oldEntry.urlHash; // unnecessary, should be the same// this.url = oldEntry.url; // unnecessary, should be the same- entry = oldEntry;+ // doesn't make sense, since no return value:+ //entry = oldEntry;return; // this did not need to be stored, but is updated}@@ -129,13 +130,14 @@ public final class indexRepositoryReference {}public synchronized indexURLReference newEntry(final String propStr) {- if (propStr != null && propStr.startsWith("{") && propStr.endsWith("}")) try {+ if (propStr == null || !propStr.startsWith("{") || !propStr.endsWith("}")) {+ return null;+ }+ try {return new indexURLReference(serverCodings.s2p(propStr.substring(1, propStr.length() - 1)));} catch (final kelondroException e) {// wrong formatreturn null;- } else {- return null;}}diff --git a/source/de/anomic/index/indexURLReference.java b/source/de/anomic/index/indexURLReference.javaindex 75f908337..3f52f8f34 100644--- a/source/de/anomic/index/indexURLReference.java+++ b/source/de/anomic/index/indexURLReference.java@@ -248,13 +248,14 @@ public class indexURLReference {}public static indexURLReference importEntry(final String propStr) {- if (propStr != null && propStr.startsWith("{") && propStr.endsWith("}")) try {+ if (propStr == null || !propStr.startsWith("{") || !propStr.endsWith("}")) {+ return null;+ }+ try {return new indexURLReference(serverCodings.s2p(propStr.substring(1, propStr.length() - 1)));} catch (final kelondroException e) {// wrong formatreturn null;- } else {- return null;}}diff --git a/source/de/anomic/kelondro/kelondroAbstractRecords.java b/source/de/anomic/kelondro/kelondroAbstractRecords.javaindex 9143cf696..9a766e013 100644--- a/source/de/anomic/kelondro/kelondroAbstractRecords.java+++ b/source/de/anomic/kelondro/kelondroAbstractRecords.java@@ -221,40 +221,39 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {USAGE.USEDC++;writeused(false);return index;+ }+ // re-use record from free-list+ USAGE.USEDC++;+ USAGE.FREEC--;+ // take link+ int index = USAGE.FREEH.index;+ if (index == kelondroHandle.NUL) {+ serverLog.logSevere("kelondroTray/" + filename, "INTERNAL ERROR (DATA INCONSISTENCY): re-use of records failed, lost " + (USAGE.FREEC + 1) + " records.");+ // try to heal..+ USAGE.USEDC = USAGE.allCount() + 1;+ USAGE.FREEC = 0;+ index = USAGE.USEDC - 1;} else {- // re-use record from free-list- USAGE.USEDC++;- USAGE.FREEC--;- // take link- int index = USAGE.FREEH.index;- if (index == kelondroHandle.NUL) {- serverLog.logSevere("kelondroTray/" + filename, "INTERNAL ERROR (DATA INCONSISTENCY): re-use of records failed, lost " + (USAGE.FREEC + 1) + " records.");- // try to heal..- USAGE.USEDC = USAGE.allCount() + 1;- USAGE.FREEC = 0;- index = USAGE.USEDC - 1;+ //System.out.println("*DEBUG* ALLOCATED DELETED INDEX " + index);+ // check for valid seek position+ final long seekp = seekpos(USAGE.FREEH);+ if (seekp >= entryFile.length()) {+ // this is a severe inconsistency. try to heal..+ serverLog.logSevere("kelondroTray/" + filename, "new Handle: lost " + USAGE.FREEC + " marked nodes; seek position " + seekp + "/" + USAGE.FREEH.index + " out of file size " + entryFile.length() + "/" + ((entryFile.length() - POS_NODES) / recordsize));+ index = USAGE.allCount(); // a place at the end of the file+ USAGE.USEDC += USAGE.FREEC; // to avoid that non-empty records at the end are overwritten+ USAGE.FREEC = 0; // discard all possible empty nodes+ USAGE.FREEH.index = kelondroHandle.NUL;} else {- //System.out.println("*DEBUG* ALLOCATED DELETED INDEX " + index);- // check for valid seek position- final long seekp = seekpos(USAGE.FREEH);- if (seekp >= entryFile.length()) {- // this is a severe inconsistency. try to heal..- serverLog.logSevere("kelondroTray/" + filename, "new Handle: lost " + USAGE.FREEC + " marked nodes; seek position " + seekp + "/" + USAGE.FREEH.index + " out of file size " + entryFile.length() + "/" + ((entryFile.length() - POS_NODES) / recordsize));- index = USAGE.allCount(); // a place at the end of the file- USAGE.USEDC += USAGE.FREEC; // to avoid that non-empty records at the end are overwritten- USAGE.FREEC = 0; // discard all possible empty nodes- USAGE.FREEH.index = kelondroHandle.NUL;- } else {- // read link to next element of FREEH chain- USAGE.FREEH.index = entryFile.readInt(seekp);- assert ((USAGE.FREEH.index == kelondroHandle.NUL) && (USAGE.FREEC == 0)) || seekpos(USAGE.FREEH) < entryFile.length() : "allocatePayload: USAGE.FREEH.index = " + USAGE.FREEH.index + ", seekp = " + seekp;- }+ // read link to next element of FREEH chain+ USAGE.FREEH.index = entryFile.readInt(seekp);+ assert ((USAGE.FREEH.index == kelondroHandle.NUL) && (USAGE.FREEC == 0)) || seekpos(USAGE.FREEH) < entryFile.length() : "allocatePayload: USAGE.FREEH.index = " + USAGE.FREEH.index + ", seekp = " + seekp;}- USAGE.writeused(false);- USAGE.writefree();- entryFile.write(seekpos(index) + overhead, chunk, 0, ROW.objectsize); // overwrite space- return index;}+ USAGE.writeused(false);+ USAGE.writefree();+ entryFile.write(seekpos(index) + overhead, chunk, 0, ROW.objectsize); // overwrite space+ return index;}//}}@@ -673,8 +672,8 @@ public abstract class kelondroAbstractRecords implements kelondroRecords {// custom textspublic final void setText(final int pos, byte[] text) throws IOException {if (pos >= TXTPROPS.length) throw new IllegalArgumentException("setText: text array exceeded");- if (text.length > TXTPROPW) throw new IllegalArgumentException("setText: text lemgth exceeded");if (text == null) text = new byte[0];+ if (text.length > TXTPROPW) throw new IllegalArgumentException("setText: text lemgth exceeded");TXTPROPS[pos] = text;entryFile.write(POS_TXTPROPS + TXTPROPW * pos, text);}diff --git a/source/de/anomic/kelondro/kelondroBLOBTree.java b/source/de/anomic/kelondro/kelondroBLOBTree.javaindex d947478a5..9581f52d3 100644--- a/source/de/anomic/kelondro/kelondroBLOBTree.java+++ b/source/de/anomic/kelondro/kelondroBLOBTree.java@@ -197,7 +197,8 @@ public class kelondroBLOBTree implements kelondroBLOB {// iterates only the keys of the Nodes// enumerated objects are of type Stringfinal keyIterator i = new keyIterator(index.rows(up, null));- if (rotating) return new kelondroRotateIterator<byte[]>(i, null, index.size()); else return i;+ if (rotating) return new kelondroRotateIterator<byte[]>(i, null, index.size());+ return i;}public synchronized kelondroCloneableIterator<byte[]> keys(final boolean up, final byte[] firstKey) throws IOException {@@ -226,7 +227,7 @@ public class kelondroBLOBTree implements kelondroBLOB {}}- private synchronized int get(final String key, final int pos) throws IOException {+ synchronized int get(final String key, final int pos) throws IOException {final int reccnt = pos / reclen;// read within a single recordfinal byte[] buf = getValueCached(elementKey(key, reccnt));@@ -242,7 +243,7 @@ public class kelondroBLOBTree implements kelondroBLOB {return ra.readFully();}- private synchronized byte[] get(final String key, final int pos, final int len) throws IOException {+ synchronized byte[] get(final String key, final int pos, final int len) throws IOException {final int recpos = pos % reclen;final int reccnt = pos / reclen;byte[] segment1;@@ -290,7 +291,7 @@ public class kelondroBLOBTree implements kelondroBLOB {put(new String(key), 0, b, 0, b.length);}- private synchronized void put(final String key, final int pos, final byte[] b, final int off, final int len) throws IOException {+ synchronized void put(final String key, final int pos, final byte[] b, final int off, final int len) throws IOException {final int recpos = pos % reclen;final int reccnt = pos / reclen;byte[] buf;@@ -327,7 +328,7 @@ public class kelondroBLOBTree implements kelondroBLOB {}}- private synchronized void put(final String key, final int pos, final int b) throws IOException {+ synchronized void put(final String key, final int pos, final int b) throws IOException {final int recpos = pos % reclen;final int reccnt = pos / reclen;byte[] buf;diff --git a/source/de/anomic/kelondro/kelondroBufferedIOChunks.java b/source/de/anomic/kelondro/kelondroBufferedIOChunks.javaindex 7f3b4d73b..3e24c6139 100644--- a/source/de/anomic/kelondro/kelondroBufferedIOChunks.java+++ b/source/de/anomic/kelondro/kelondroBufferedIOChunks.java@@ -34,7 +34,7 @@ public final class kelondroBufferedIOChunks extends kelondroAbstractIOChunks impprotected kelondroRA ra;private final long bufferMaxSize;- private long bufferCurrSize;+ private long bufferCurrSize;private final long commitTimeout;private final TreeMap<Long, byte[]> buffer;private long lastCommit = 0;diff --git a/source/de/anomic/kelondro/kelondroCache.java b/source/de/anomic/kelondro/kelondroCache.javaindex 647dd58dc..b00e00354 100644--- a/source/de/anomic/kelondro/kelondroCache.java+++ b/source/de/anomic/kelondro/kelondroCache.java@@ -194,11 +194,11 @@ public class kelondroCache implements kelondroIndex {public boolean has(final byte[] key) {// first look into the miss cacheif (readMissCache != null) {- if (readMissCache.get(key) != null) {+ if (readMissCache.get(key) == null) {+ this.hasnotMiss++;+ } else {this.hasnotHit++;return false;- } else {- this.hasnotMiss++;}}@@ -218,11 +218,11 @@ public class kelondroCache implements kelondroIndex {public synchronized Entry get(final byte[] key) throws IOException {// first look into the miss cacheif (readMissCache != null) {- if (readMissCache.get(key) != null) {+ if (readMissCache.get(key) == null) {+ this.hasnotMiss++;+ } else {this.hasnotHit++;return null;- } else {- this.hasnotMiss++;}}@@ -247,13 +247,13 @@ public class kelondroCache implements kelondroIndex {if (dummy == null) this.hasnotUnique++; else this.hasnotDouble++;}return null;- } else {- if ((checkHitSpace()) && (readHitCache != null)) {- final kelondroRow.Entry dummy = readHitCache.put(entry);- if (dummy == null) this.writeUnique++; else this.writeDouble++;- }- return entry;}++ if ((checkHitSpace()) && (readHitCache != null)) {+ final kelondroRow.Entry dummy = readHitCache.put(entry);+ if (dummy == null) this.writeUnique++; else this.writeDouble++;+ }+ return entry;}public synchronized void putMultiple(final List<Entry> rows) throws IOException {diff --git a/source/de/anomic/kelondro/kelondroCollectionIndex.java b/source/de/anomic/kelondro/kelondroCollectionIndex.javaindex 2ebe66515..3c9261e0b 100644--- a/source/de/anomic/kelondro/kelondroCollectionIndex.java+++ b/source/de/anomic/kelondro/kelondroCollectionIndex.java@@ -705,7 +705,7 @@ public class kelondroCollectionIndex {return (int) indexrow.getColLong(idx_col_chunkcount);}- public synchronized boolean has(final byte[] key) throws IOException {+ public synchronized boolean has(final byte[] key) {return index.has(key);}diff --git a/source/de/anomic/kelondro/kelondroEcoFS.java b/source/de/anomic/kelondro/kelondroEcoFS.javaindex c20dc1d32..387a4c9d7 100644--- a/source/de/anomic/kelondro/kelondroEcoFS.java+++ b/source/de/anomic/kelondro/kelondroEcoFS.java@@ -64,7 +64,7 @@ public class kelondroEcoFS {*/private int cachecount, buffercount;private byte[] cache, buffer;- final byte[] zero;+ final byte[] zero;/*** stay below hard disc cache (is that necessary?)diff --git a/source/de/anomic/kelondro/kelondroFlexTable.java b/source/de/anomic/kelondro/kelondroFlexTable.javaindex 26ba9a4af..b8f4a2e2d 100644--- a/source/de/anomic/kelondro/kelondroFlexTable.java+++ b/source/de/anomic/kelondro/kelondroFlexTable.java@@ -186,7 +186,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondrkelondroNode node;kelondroRow.Entry indexentry;int i, c = 0;- final int all = super.col[0].size();+ final int all = super.col[0].size();final long start = System.currentTimeMillis();long last = start;while (content.hasNext()) {@@ -283,7 +283,7 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondrfinal kelondroRow.Entry oldentry = super.get(pos);assert this.size() == index.size() : "content.size() = " + this.size() + ", index.size() = " + index.size();if (oldentry == null) {- serverLog.logSevere("kelondroFlexTable", "put(): index failure; the index pointed to a cell which is empty. content.size() = " + this.size() + ", index.size() = " + ((index == null) ? 0 : index.size()));+ serverLog.logSevere("kelondroFlexTable", "put(): index failure; the index pointed to a cell which is empty. content.size() = " + this.size() + ", index.size() = " + index.size());// patch bug ***** FIND CAUSE! (see also: remove)final int oldindex = index.removei(key);assert oldindex >= 0;diff --git a/source/de/anomic/kelondro/kelondroIntBytesMap.java b/source/de/anomic/kelondro/kelondroIntBytesMap.javaindex c5ae1d6dc..02e900069 100644--- a/source/de/anomic/kelondro/kelondroIntBytesMap.java+++ b/source/de/anomic/kelondro/kelondroIntBytesMap.java@@ -40,7 +40,7 @@ public class kelondroIntBytesMap {private final kelondroRow rowdef;private final kelondroRowSet index0;- private kelondroRowSet index1;+ private kelondroRowSet index1;private final kelondroOrder<kelondroRow.Entry> entryOrder;public kelondroIntBytesMap(final int payloadSize, final int initSize) {@@ -53,8 +53,7 @@ public class kelondroIntBytesMap {public long memoryNeededForGrow() {if (index1 == null)return index0.memoryNeededForGrow();- else- return index1.memoryNeededForGrow();+ return index1.memoryNeededForGrow();}public kelondroRow row() {@@ -239,7 +238,7 @@ public class kelondroIntBytesMap {if (random.nextLong() % 5 == 0) ra.add(new Long(r));if ((ra.size() > 0) && (random.nextLong() % 7 == 0)) {rc++;- p = Math.abs(random.nextInt()) % ra.size();+ p = Math.abs(random.nextInt() % ra.size());R = ra.get(p);//System.out.println("remove " + R.longValue());jcontrol.remove(R);diff --git a/source/de/anomic/kelondro/kelondroMap.java b/source/de/anomic/kelondro/kelondroMap.javaindex 47ee01a3d..7ea7805fe 100644--- a/source/de/anomic/kelondro/kelondroMap.java+++ b/source/de/anomic/kelondro/kelondroMap.java@@ -71,7 +71,7 @@ public class kelondroMap {this.cacheScore = new kelondroMScoreCluster<String>();}- private static String map2string(final Map<String, String> map, final String comment) throws IOException {+ private static String map2string(final Map<String, String> map, final String comment) {final Iterator<Map.Entry<String, String>> iter = map.entrySet().iterator();Map.Entry<String, String> entry;final StringBuffer bb = new StringBuffer(map.size() * 40);@@ -234,7 +234,8 @@ public class kelondroMap {public synchronized kelondroCloneableIterator<byte[]> keys(final boolean up, final boolean rotating, final byte[] firstKey, final byte[] secondKey) throws IOException {// simple enumeration of key names without special orderingfinal kelondroCloneableIterator<byte[]> i = blob.keys(up, firstKey);- if (rotating) return new kelondroRotateIterator<byte[]>(i, secondKey, blob.size()); else return i;+ if (rotating) return new kelondroRotateIterator<byte[]>(i, secondKey, blob.size());+ return i;}diff --git a/source/de/anomic/kelondro/kelondroMergeIterator.java b/source/de/anomic/kelondro/kelondroMergeIterator.javaindex 4b6513bf2..a09bd86ae 100644--- a/source/de/anomic/kelondro/kelondroMergeIterator.java+++ b/source/de/anomic/kelondro/kelondroMergeIterator.java@@ -52,15 +52,6 @@ public class kelondroMergeIterator<E> implements kelondroCloneableIterator<E> {return new kelondroMergeIterator<E>(a.clone(modifier), b.clone(modifier), comp, merger, up);}- public void finalize() {- // call finalizer of embedded objects- a = null;- b = null;- na = null;- nb = null;- comp = null;- }-private void nexta() {try {if ((a != null) && (a.hasNext())) na = a.next(); else na = null;@@ -144,25 +135,23 @@ public class kelondroMergeIterator<E> implements kelondroCloneableIterator<E> {return new kelondroMergeIterator<A>(one, cascade(iiterators, c, merger, up), c, merger, up);}- public static Method simpleMerge = null;+ public static final Method simpleMerge;static {+ Method meth = null;try {final Class<?> c = Class.forName("de.anomic.kelondro.kelondroMergeIterator");- simpleMerge = c.getMethod("mergeEqualByReplace", new Class[]{Object.class, Object.class});+ meth = c.getMethod("mergeEqualByReplace", new Class[]{Object.class, Object.class});} catch (final SecurityException e) {System.out.println("Error while initializing simpleMerge: " + e.getMessage());- simpleMerge = null;+ meth = null;} catch (final ClassNotFoundException e) {System.out.println("Error while initializing simpleMerge: " + e.getMessage());- simpleMerge = null;+ meth = null;} catch (final NoSuchMethodException e) {System.out.println("Error while initializing simpleMerge: " + e.getMessage());- simpleMerge = null;+ meth = null;}- }-- public static Object mergeEqualByReplace(final Object a, final Object b) {- return a;+ simpleMerge = meth;}}diff --git a/source/de/anomic/kelondro/kelondroNIOFileRA.java b/source/de/anomic/kelondro/kelondroNIOFileRA.javaindex 235249352..078e62299 100644--- a/source/de/anomic/kelondro/kelondroNIOFileRA.java+++ b/source/de/anomic/kelondro/kelondroNIOFileRA.java@@ -122,12 +122,11 @@ public class kelondroNIOFileRA extends kelondroAbstractRA implements kelondroRAwhile (growTail(seekPos)) {if (seekPos < (tailOffset + tailCurrSize)) {r = 0xFF & (bufferTail.get((int) (seekPos - tailOffset)));- break;} else {RAFile.seek(seekPos);r = RAFile.read();- break;}+ break;}}seekPos++;@@ -155,12 +154,11 @@ public class kelondroNIOFileRA extends kelondroAbstractRA implements kelondroRAif (seekPos < (tailOffset + tailCurrSize)) {bufferTail.put((int) (seekPos - tailOffset), (byte) (b & 0xff));wroteTail = true;- break;} else {RAFile.seek(seekPos);RAFile.write(b);- break;}+ break;}}seekPos++;diff --git a/source/de/anomic/kelondro/kelondroObjectSpace.java b/source/de/anomic/kelondro/kelondroObjectSpace.javaindex c21cb9380..d00443c92 100644--- a/source/de/anomic/kelondro/kelondroObjectSpace.java+++ b/source/de/anomic/kelondro/kelondroObjectSpace.java@@ -63,9 +63,8 @@ public class kelondroObjectSpace {}}- public static void recycle(byte[] b) {+ public static void recycle(final byte[] b) {if ((b.length < minSize) || (b.length > maxSize)) {- b = null;return;}decAlive(b.length);@@ -80,7 +79,6 @@ public class kelondroObjectSpace {buf.add(b);}}- b = null;}public static TreeMap<Integer, Integer> statAlive() {diff --git a/source/de/anomic/kelondro/kelondroRAMIndex.java b/source/de/anomic/kelondro/kelondroRAMIndex.javaindex d6ecdd2df..c905d01cb 100644--- a/source/de/anomic/kelondro/kelondroRAMIndex.java+++ b/source/de/anomic/kelondro/kelondroRAMIndex.java@@ -110,10 +110,9 @@ public class kelondroRAMIndex implements kelondroIndex {if (index1 == null) {// we are in the initialization phasereturn index0.addUnique(entry);- } else {- // initialization is over, add to secondary index- return index1.addUnique(entry);}+ // initialization is over, add to secondary index+ return index1.addUnique(entry);}public int addUniqueMultiple(final List<Entry> rows) {diff --git a/source/de/anomic/kelondro/kelondroRelations.java b/source/de/anomic/kelondro/kelondroRelations.javaindex 9fccf4184..1ddf7ca40 100755--- a/source/de/anomic/kelondro/kelondroRelations.java+++ b/source/de/anomic/kelondro/kelondroRelations.java@@ -139,7 +139,7 @@ public class kelondroRelations {return entry.getColBytes(3);}- public boolean hasRelation(final String name, final byte[] key) throws IOException {+ public boolean hasRelation(final String name, final byte[] key) {final kelondroIndex table = getRelation(name);if (table == null) return false;return table.has(key);diff --git a/source/de/anomic/kelondro/kelondroRow.java b/source/de/anomic/kelondro/kelondroRow.javaindex c1531c746..9ae003db4 100644--- a/source/de/anomic/kelondro/kelondroRow.java+++ b/source/de/anomic/kelondro/kelondroRow.java@@ -61,7 +61,7 @@ public final class kelondroRow {this.primaryKeyLength = (primaryKey < 0) ? this.objectsize : row[primaryKeyIndex].cellwidth;}- public kelondroRow(final String structure, final kelondroByteOrder objectOrder, final int primaryKey) {+ public kelondroRow(String structure, final kelondroByteOrder objectOrder, final int primaryKey) {assert (objectOrder != null);this.objectOrder = objectOrder;// define row with row syntax@@ -340,11 +340,10 @@ public final class kelondroRow {public final byte[] bytes() {if ((offset == 0) && (rowinstance.length == objectsize)) {return rowinstance;- } else {- final byte[] tmp = new byte[objectsize];- System.arraycopy(rowinstance, offset, tmp, 0, objectsize);- return tmp;}+ final byte[] tmp = new byte[objectsize];+ System.arraycopy(rowinstance, offset, tmp, 0, objectsize);+ return tmp;}public final void writeToArray(final byte[] target, final int targetOffset) {@@ -488,8 +487,7 @@ public final class kelondroRow {try {if ((encoding == null) || (encoding.length() == 0))return new String(rowinstance, offset + clstrt, length);- else- return new String(rowinstance, offset + clstrt, length, encoding);+ return new String(rowinstance, offset + clstrt, length, encoding);} catch (final UnsupportedEncodingException e) {return "";}diff --git a/source/de/anomic/kelondro/kelondroRowCollection.java b/source/de/anomic/kelondro/kelondroRowCollection.javaindex cc446c70e..48ff0dad2 100644--- a/source/de/anomic/kelondro/kelondroRowCollection.java+++ b/source/de/anomic/kelondro/kelondroRowCollection.java@@ -51,18 +51,8 @@ public class kelondroRowCollection {private static final int isortlimit = 20;static final Integer dummy = new Integer(0);- public static ExecutorService sortingthreadexecutor = null;- public static ExecutorService partitionthreadexecutor = null;-- static {- if (serverProcessor.useCPU > 1) {- sortingthreadexecutor = Executors.newCachedThreadPool(new NamePrefixThreadFactory("sorting"));- partitionthreadexecutor = Executors.newCachedThreadPool(new NamePrefixThreadFactory("partition"));- } else {- sortingthreadexecutor = null;- partitionthreadexecutor = null;- }- }+ public static final ExecutorService sortingthreadexecutor = (serverProcessor.useCPU > 1) ? Executors.newCachedThreadPool(new NamePrefixThreadFactory("sorting")) : null;+ public static final ExecutorService partitionthreadexecutor = (serverProcessor.useCPU > 1) ? Executors.newCachedThreadPool(new NamePrefixThreadFactory("partition")) : null;protected byte[] chunkcache;protected int chunkcount;@@ -923,7 +913,8 @@ public class kelondroRowCollection {}private static long d(final long a, final long b) {- if (b == 0) return a; else return a / b;+ if (b == 0) return a;+ return a / b;}private static Random random = null;diff --git a/source/de/anomic/kelondro/kelondroRowSet.java b/source/de/anomic/kelondro/kelondroRowSet.javaindex e4ea4b1b4..aa3a1fbcb 100644--- a/source/de/anomic/kelondro/kelondroRowSet.java+++ b/source/de/anomic/kelondro/kelondroRowSet.java@@ -210,13 +210,12 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroIndif (match(key, astart, alength, i)) return i;}return -1;- } else {- // we dont do a special handling of kelondroBase64Order here, because tests showed that this produces too much overhead- for (int i = leftBorder; i < rightBound; i++) {- if (compare(key, astart, alength, i) == 0) return i;- }- return -1;}+ // we dont do a special handling of kelondroBase64Order here, because tests showed that this produces too much overhead+ for (int i = leftBorder; i < rightBound; i++) {+ if (compare(key, astart, alength, i) == 0) return i;+ }+ return -1;}private int iterativeSearchCompiledPivot(final byte[] compiledPivot, final int leftBorder, final int rightBound) {@@ -300,7 +299,7 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroIndprivate final boolean up;private final byte[] first;private int p;- final int bound;+ final int bound;public keyIterator(final boolean up, final byte[] firstKey) {// see that all elements are sorted@@ -356,7 +355,7 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroIndprivate final boolean up;private final byte[] first;private int p;- final int bound;+ final int bound;public rowIterator(final boolean up, final byte[] firstKey) {// see that all elements are sorteddiff --git a/source/de/anomic/kelondro/kelondroSplitTable.java b/source/de/anomic/kelondro/kelondroSplitTable.javaindex bb009697e..7d7a11490 100644--- a/source/de/anomic/kelondro/kelondroSplitTable.java+++ b/source/de/anomic/kelondro/kelondroSplitTable.java@@ -276,7 +276,8 @@ public class kelondroSplitTable implements kelondroIndex {try {cs.submit(new Callable<kelondroIndex>() {public kelondroIndex call() {- if (table.has(key)) return table; else return dummyIndex;+ if (table.has(key)) return table;+ return dummyIndex;}});} catch (final RejectedExecutionException e) {@@ -374,9 +375,8 @@ public class kelondroSplitTable implements kelondroIndex {}if (maxtable == null) {return null;- } else {- return maxtable.removeOne();}+ return maxtable.removeOne();}public synchronized kelondroCloneableIterator<byte[]> keys(final boolean up, final byte[] firstKey) throws IOException {diff --git a/source/de/anomic/kelondro/kelondroStack.java b/source/de/anomic/kelondro/kelondroStack.javaindex 34875933f..8dc4f2960 100644--- a/source/de/anomic/kelondro/kelondroStack.java+++ b/source/de/anomic/kelondro/kelondroStack.java@@ -281,8 +281,7 @@ public final class kelondroStack extends kelondroFullRecords {public String hp(final kelondroHandle h) {if (h == null)return "NULL";- else- return h.toString();+ return h.toString();}public void print() throws IOException {diff --git a/source/de/anomic/kelondro/kelondroTree.java b/source/de/anomic/kelondro/kelondroTree.javaindex f34407029..9db2079b6 100644--- a/source/de/anomic/kelondro/kelondroTree.java+++ b/source/de/anomic/kelondro/kelondroTree.java@@ -609,7 +609,8 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndexpublic byte[] put(final byte[] key, final byte[] value) throws IOException {final kelondroRow.Entry row = row().newEntry(new byte[][]{key, value});final kelondroRow.Entry ret = put(row);- if (ret == null) return null; else return ret.getColBytes(0);+ if (ret == null) return null;+ return ret.getColBytes(0);}// Removes the mapping for this key from this map if present (optional operation).@@ -624,9 +625,8 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndexfinal kelondroRow.Entry values = row().newEntry(result.getValueRow());remove(result, writeSearchObj.getParent());return values;- } else {- return null;}+ return null;}}@@ -845,17 +845,15 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndexif (c == 0) {if (including) {break; // correct + finished- } else {- if (hasNext()) next(); else nextNode = null;- break; // corrected + finished}+ if (hasNext()) next(); else nextNode = null;+ break; // corrected + finished} else if (c < 0) {if (up) {break; // correct + finished- } else {- // firstKey < nextNode.getKey(): correct once- if (hasNext()) next(); else nextNode = null;}+ // firstKey < nextNode.getKey(): correct once+ if (hasNext()) next(); else nextNode = null;} else if (c > 0) {if (up) {// firstKey > nextNode.getKey(): correct once@@ -892,11 +890,6 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex}// now every parent node to the start node is on the stack}-- public void finalize() {- nextNode = null;- nodeStack = null;- }public boolean hasNext() {return (rot && (size() > 0)) || (nextNode != null);@@ -1229,7 +1222,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndexkelondroHandle handle;kelondroNode node;int linelength;- final int width = (1 << (height - 1)) * (row().width(0) + 1);+ final int width = (1 << (height - 1)) * (row().width(0) + 1);String key;for (int h = 1; h < height; h++) {linelength = width / (thisline.size() * 2);diff --git a/source/de/anomic/kelondro/kelondroXMLTables.java b/source/de/anomic/kelondro/kelondroXMLTables.javaindex e46c128d9..d2651d363 100644--- a/source/de/anomic/kelondro/kelondroXMLTables.java+++ b/source/de/anomic/kelondro/kelondroXMLTables.java@@ -132,10 +132,9 @@ public class kelondroXMLTables {final Hashtable<String, String> l = tables.get(table);if (l == null)throw new RuntimeException("Microtables.get: table does not exist");- if (l.containsKey(key))- return l.get(key);- else+ if (!l.containsKey(key))return deflt;+ return l.get(key);}return null;}diff --git a/source/de/anomic/language/identification/LanguageFilenameFilter.java b/source/de/anomic/language/identification/LanguageFilenameFilter.javaindex 431c2a635..053cc39b9 100644--- a/source/de/anomic/language/identification/LanguageFilenameFilter.java+++ b/source/de/anomic/language/identification/LanguageFilenameFilter.java@@ -34,8 +34,7 @@ class LanguageFilenameFilter implements FilenameFilter {public boolean accept(final File dir, final String name) {if (name.matches(".+\\."+fileExtension)) {return true;- } else {- return false;}+ return false;}}diff --git a/source/de/anomic/language/identification/LanguageStatistics.java b/source/de/anomic/language/identification/LanguageStatistics.javaindex 1f709646c..961a8f109 100644--- a/source/de/anomic/language/identification/LanguageStatistics.java+++ b/source/de/anomic/language/identification/LanguageStatistics.java@@ -90,10 +90,9 @@ public class LanguageStatistics {*/public final float get(final char letter) {if (stats.containsKey(letter)) {- return stats.get(letter);- } else {- return 0;+ return stats.get(letter);}+ return 0;}/**@@ -149,9 +148,8 @@ public class LanguageStatistics {public boolean contains(final Character character) {if (stats.containsKey(character)) {return true;- } else {- return false;}+ return false;}/**diff --git a/source/de/anomic/net/ftpc.java b/source/de/anomic/net/ftpc.javaindex 11a299fb0..be30edc47 100644--- a/source/de/anomic/net/ftpc.java+++ b/source/de/anomic/net/ftpc.java@@ -236,17 +236,16 @@ public class ftpc {.booleanValue());} catch (final InvocationTargetException e) {if (e.getMessage() != null) {- if (notConnected()) {- // the error was probably caused because there is no- // connection- errPrintln("not connected. no effect.");- e.printStackTrace(err);- return ret;- } else {- errPrintln("ftp internal exception: target exception " + e);+ if (notConnected()) {+ // the error was probably caused because there is no+ // connection+ errPrintln("not connected. no effect.");+ e.printStackTrace(err);+ } else {+ errPrintln("ftp internal exception: target exception " + e);+ }return ret;}- }} catch (final IllegalAccessException e) {errPrintln("ftp internal exception: wrong access " + e);return ret;@@ -1407,37 +1406,36 @@ public class ftpc {// get status codefinal int status = getStatus(reply);-+ if (status != 1) {+ throw new IOException(reply);+ }+// starting data transaction- if (status == 1) {- final Socket data = getDataSocket();- final BufferedReader ClientStream = new BufferedReader(new InputStreamReader(data.getInputStream()));-- // read file system data- String line;- final ArrayList<String> files = new ArrayList<String>();- while ((line = ClientStream.readLine()) != null) {- if (!line.startsWith("total ")) {- files.add(line);- }+ final Socket data = getDataSocket();+ final BufferedReader ClientStream = new BufferedReader(new InputStreamReader(data.getInputStream()));++ // read file system data+ String line;+ final ArrayList<String> files = new ArrayList<String>();+ while ((line = ClientStream.readLine()) != null) {+ if (!line.startsWith("total ")) {+ files.add(line);}+ }- // after stream is empty we should get control completion echo- reply = receive();+ // after stream is empty we should get control completion echo+ reply = receive();- // boolean success = !isNotPositiveCompletion(reply);+ // boolean success = !isNotPositiveCompletion(reply);- // shutdown connection- ClientStream.close(); // Closing the returned InputStream will- closeDataSocket(); // close the associated socket.+ // shutdown connection+ ClientStream.close(); // Closing the returned InputStream will+ closeDataSocket(); // close the associated socket.- // if (!success) throw new IOException(reply);+ // if (!success) throw new IOException(reply);- files.trimToSize();- return files;- } else {- throw new IOException(reply);- }+ files.trimToSize();+ return files;}public boolean MDIR() {@@ -1775,14 +1773,13 @@ public class ftpc {// read status of the command from the control portfinal String reply = receive();- // starting data transaction- if (getStatusCode(reply) == 213) {- try {- return Integer.parseInt(reply.substring(4));- } catch (final NumberFormatException e) {- throw new IOException(reply);- }- } else {+ if (getStatusCode(reply) != 213) {+ throw new IOException(reply);+ }++ try {+ return Integer.parseInt(reply.substring(4));+ } catch (final NumberFormatException e) {throw new IOException(reply);}}@@ -2541,7 +2538,7 @@ public class ftpc {public StringBuilder dirhtml(String remotePath) {// returns a directory listing using an existing connectiontry {- if(isFolder(remotePath) && !"/".equals(remotePath.charAt(remotePath.length()-1))) {+ if(isFolder(remotePath) && '/' != remotePath.charAt(remotePath.length()-1)) {remotePath += '/';}final List<String> list = list(remotePath, true);@@ -2636,7 +2633,7 @@ public class ftpc {FileOutputStream fos;try {fos = new FileOutputStream(file);- fos.write((new String(page)).getBytes());+ fos.write(page.toString().getBytes());fos.close();} catch (final FileNotFoundException e) {e.printStackTrace();diff --git a/source/de/anomic/plasma/cache/ftp/ResourceInfo.java b/source/de/anomic/plasma/cache/ftp/ResourceInfo.javaindex 56679e068..82dce34aa 100644--- a/source/de/anomic/plasma/cache/ftp/ResourceInfo.java+++ b/source/de/anomic/plasma/cache/ftp/ResourceInfo.java@@ -32,7 +32,6 @@ import java.util.Map;import java.util.TreeMap;import de.anomic.plasma.cache.IResourceInfo;-import de.anomic.plasma.cache.ResourceInfoFactory;import de.anomic.yacy.yacyURL;public class ResourceInfo implements IResourceInfo {@@ -41,7 +40,7 @@ public class ResourceInfo implements IResourceInfo {public static final String MODIFICATION_DATE = "modificationDate";private final yacyURL objectURL;- private yacyURL refererURL;+ private yacyURL refererURL;private final TreeMap<String, String> propertyMap;/**diff --git a/source/de/anomic/plasma/cache/http/ResourceInfo.java b/source/de/anomic/plasma/cache/http/ResourceInfo.javaindex 0c4ec24be..f3d9d5069 100644--- a/source/de/anomic/plasma/cache/http/ResourceInfo.java+++ b/source/de/anomic/plasma/cache/http/ResourceInfo.java@@ -34,7 +34,6 @@ import java.util.TreeMap;import de.anomic.http.httpHeader;import de.anomic.plasma.plasmaHTCache;import de.anomic.plasma.cache.IResourceInfo;-import de.anomic.plasma.cache.ResourceInfoFactory;import de.anomic.server.serverDate;import de.anomic.yacy.yacyURL;diff --git a/source/de/anomic/plasma/parser/sevenzip/sevenzipParser.java b/source/de/anomic/plasma/parser/sevenzip/sevenzipParser.javaindex e814c8181..9fde0a890 100644--- a/source/de/anomic/plasma/parser/sevenzip/sevenzipParser.java+++ b/source/de/anomic/plasma/parser/sevenzip/sevenzipParser.java@@ -112,9 +112,8 @@ public class sevenzipParser extends AbstractParser implements Parser {serverFileUtils.copy(source, cfos);if (cfos.isFallback()) {return parse(location, mimeType, charset, cfos.getContentFile());- } else {- return parse(location, mimeType, charset, cfos.getContentBAOS());}+ return parse(location, mimeType, charset, cfos.getContentBAOS());} catch (final IOException e) {throw new ParserException("error processing 7zip archive", location, e);}diff --git a/source/de/anomic/plasma/plasmaCondenser.java b/source/de/anomic/plasma/plasmaCondenser.javaindex 8a15b7e2a..73d069182 100644--- a/source/de/anomic/plasma/plasmaCondenser.java+++ b/source/de/anomic/plasma/plasmaCondenser.java@@ -505,7 +505,7 @@ public final class plasmaCondenser {loop: while (e.hasMoreElements()) {s = e.nextElement();if ((s.length() == 1) && (htmlFilterContentScraper.punctuation(s.charAt(0)))) return s;- if ((s.length() < ml) && (!(s.equals("of")))) continue loop;+ if ((s.length() < ml) && (!(s.toString().equals("of")))) continue loop;for (int i = 0; i < s.length(); i++) {c = s.charAt(i);// TODO: Bugfix needed for UTF-8@@ -651,12 +651,11 @@ public final class plasmaCondenser {public StringBuffer next() {if (buffer == null) {return null;- } else {- counter = counter + buffer.length() + 1;- final StringBuffer r = buffer;- buffer = nextElement0();- return r;}+ counter = counter + buffer.length() + 1;+ final StringBuffer r = buffer;+ buffer = nextElement0();+ return r;}public int count() {@@ -678,7 +677,8 @@ public final class plasmaCondenser {nextChar = reader.read();//System.out.print((char) nextChar); // DEBUGif (nextChar < 0) {- if (s.length() == 0) return null; else break;+ if (s.length() == 0) return null;+ break;}c = (char) nextChar;if (pre && ((c == (char) 10) || (c == (char) 13))) break;diff --git a/source/de/anomic/plasma/plasmaDHTChunk.java b/source/de/anomic/plasma/plasmaDHTChunk.javaindex bb6122e63..89411d6ff 100644--- a/source/de/anomic/plasma/plasmaDHTChunk.java+++ b/source/de/anomic/plasma/plasmaDHTChunk.java@@ -164,9 +164,8 @@ public class plasmaDHTChunk {// if that fails, take simply the best start pointif (bestHash == null) {return wordIndex.seedDB.mySeed().hash.substring(0, 11) + "z";- } else {- return bestHash;}+ return bestHash;}private void selectTransferContainers(final String hash, final int mincount, final int maxcount, final int maxtime) throws InterruptedException {diff --git a/source/de/anomic/plasma/plasmaDHTFlush.java b/source/de/anomic/plasma/plasmaDHTFlush.javaindex ac0608cde..0353610e6 100644--- a/source/de/anomic/plasma/plasmaDHTFlush.java+++ b/source/de/anomic/plasma/plasmaDHTFlush.java@@ -110,7 +110,7 @@ public class plasmaDHTFlush extends Thread {public int getTransferedEntrySpeed() {long transferTime = System.currentTimeMillis() - this.startingTime;if (transferTime <= 0) transferTime = 1;- return (int) ((1000L * (long) this.transferedEntryCount) / transferTime);+ return (int) ((1000L * this.transferedEntryCount) / transferTime);}public yacySeed getSeed() {diff --git a/source/de/anomic/plasma/plasmaDHTTransfer.java b/source/de/anomic/plasma/plasmaDHTTransfer.javaindex 87df13f8e..05745251e 100644--- a/source/de/anomic/plasma/plasmaDHTTransfer.java+++ b/source/de/anomic/plasma/plasmaDHTTransfer.java@@ -134,7 +134,7 @@ public class plasmaDHTTransfer extends Thread {*/this.transferStatus = plasmaDHTChunk.chunkStatus_RUNNING;long retryCount = 0;- final long start = System.currentTimeMillis();+ final long start = System.currentTimeMillis();while (true) {// testing if we were abortedif (this.isAborted()) return;diff --git a/source/de/anomic/plasma/plasmaDbImporter.java b/source/de/anomic/plasma/plasmaDbImporter.javaindex 4fcc557a5..f9604645a 100644--- a/source/de/anomic/plasma/plasmaDbImporter.java+++ b/source/de/anomic/plasma/plasmaDbImporter.java@@ -137,28 +137,27 @@ public class plasmaDbImporter extends AbstractImporter implements Importer {notBoundEntryCounter++;newContainer.remove(urlHash);continue;- } else {- // we need to import the url-- // getting the url entry- final indexURLReference urlEntry = this.importWordIndex.getURL(urlHash, null, 0);- if (urlEntry != null) {-- /* write it into the home url db */- homeWordIndex.putURL(urlEntry);- importedUrlBuffer.add(urlHash);- this.urlCounter++;-- if (this.urlCounter % 500 == 0) {- this.log.logFine(this.urlCounter + " URLs processed so far.");- }-- } else {- unknownUrlBuffer.add(urlHash);- notBoundEntryCounter++;- newContainer.remove(urlHash);- continue;+ }+ // we need to import the url++ // getting the url entry+ final indexURLReference urlEntry = this.importWordIndex.getURL(urlHash, null, 0);+ if (urlEntry != null) {++ /* write it into the home url db */+ homeWordIndex.putURL(urlEntry);+ importedUrlBuffer.add(urlHash);+ this.urlCounter++;++ if (this.urlCounter % 500 == 0) {+ this.log.logFine(this.urlCounter + " URLs processed so far.");}++ } else {+ unknownUrlBuffer.add(urlHash);+ notBoundEntryCounter++;+ newContainer.remove(urlHash);+ continue;}//} else {// already known urldiff --git a/source/de/anomic/plasma/plasmaGrafics.java b/source/de/anomic/plasma/plasmaGrafics.javaindex cb09288db..434e110b8 100644--- a/source/de/anomic/plasma/plasmaGrafics.java+++ b/source/de/anomic/plasma/plasmaGrafics.java@@ -171,12 +171,12 @@ public class plasmaGrafics {private static void drawNetworkPicture(final yacySeedDB seedDB, final int width, final int height, final int passiveLimit, final int potentialLimit, final int maxCount, final boolean corona, final String networkName, final String networkTitle, final String bgcolor) {+ if (seedDB == null) return; // no other peers known+final int innerradius = Math.min(width, height) / 5;int outerradius = innerradius + innerradius * seedDB.sizeConnected() / 100;if (outerradius > innerradius * 2) outerradius = innerradius * 2;- if (seedDB == null) return; // no other peers known-networkPicture = new ymageMatrix(width, height, (bgcolor.equals("000000")) ? ymageMatrix.MODE_ADD : ymageMatrix.MODE_SUB, bgcolor);// draw network circle@@ -251,7 +251,7 @@ public class plasmaGrafics {if (name.length() > longestName) longestName = name.length();final int angle = (int) (360 * seed.dhtPosition());//System.out.println("Seed " + seed.hash + " has distance " + seed.dhtDistance() + ", angle = " + angle);- int linelength = 20 + outerradius * (20 * (name.length() - shortestName) / (longestName - shortestName) + (Math.abs(seed.hash.hashCode()) % 20)) / 60;+ int linelength = 20 + outerradius * (20 * (name.length() - shortestName) / (longestName - shortestName) + Math.abs(seed.hash.hashCode() % 20)) / 60;if (linelength > outerradius) linelength = outerradius;int dotsize = 6 + 2 * (int) (seed.getLinkCount() / 500000L);if (dotsize > 18) dotsize = 18;diff --git a/source/de/anomic/plasma/plasmaHTCache.java b/source/de/anomic/plasma/plasmaHTCache.javaindex cff631cd1..863877e4f 100644--- a/source/de/anomic/plasma/plasmaHTCache.java+++ b/source/de/anomic/plasma/plasmaHTCache.java@@ -912,6 +912,13 @@ public final class plasmaHTCache {return entry;}+ /**+ * @return the responseHeaderDB+ */+ static kelondroMap getResponseHeaderDB() {+ return responseHeaderDB;+ }+public final static class Entry {// the class objects@@ -1044,7 +1051,7 @@ public final class plasmaHTCache {return this.resInfo;}- private boolean writeResourceInfo() {+ boolean writeResourceInfo() {if (this.resInfo == null) return false;try {final HashMap<String, String> hm = new HashMap<String, String>();@@ -1052,7 +1059,7 @@ public final class plasmaHTCache {hm.put("@@URL", this.url.toNormalform(false, false));hm.put("@@DEPTH", Integer.toString(this.depth));if (this.initiator != null) hm.put("@@INITIATOR", this.initiator);- responseHeaderDB.put(this.url.hash(), hm);+ getResponseHeaderDB().put(this.url.hash(), hm);} catch (final Exception e) {resetResponseHeaderDB();return false;diff --git a/source/de/anomic/plasma/plasmaParser.java b/source/de/anomic/plasma/plasmaParser.javaindex 7ed80f11e..9ab5cb6f8 100644--- a/source/de/anomic/plasma/plasmaParser.java+++ b/source/de/anomic/plasma/plasmaParser.java@@ -208,10 +208,9 @@ public final class plasmaParser {final LinkedList<String> extensions = new LinkedList<String>();if ((extString == null) || (extString.length() == 0)) {return extensions;- } else {- final String[] xs = extString.split(",");- for (int i = 0; i < xs.length; i++) extensions.add(xs[i].toLowerCase().trim());}+ final String[] xs = extString.split(",");+ for (int i = 0; i < xs.length; i++) extensions.add(xs[i].toLowerCase().trim());return extensions;}@@ -364,7 +363,7 @@ public final class plasmaParser {if (encoding.startsWith("WINDOWS")) encoding = "windows" + encoding.substring(7);// fix wrong fill characters- encoding.replaceAll("_", "-");+ encoding = encoding.replaceAll("_", "-");if (encoding.matches("GB[_-]?2312([-_]80)?")) return "GB2312";if (encoding.matches(".*UTF[-_]?8.*")) return "UTF-8";diff --git a/source/de/anomic/plasma/plasmaParserConfig.java b/source/de/anomic/plasma/plasmaParserConfig.javaindex db99dd1be..d6241dccb 100644--- a/source/de/anomic/plasma/plasmaParserConfig.java+++ b/source/de/anomic/plasma/plasmaParserConfig.java@@ -28,7 +28,6 @@package de.anomic.plasma;import java.util.Arrays;-import java.util.Enumeration;import java.util.HashSet;import java.util.Hashtable;import java.util.Iterator;diff --git a/source/de/anomic/plasma/plasmaParserDocument.java b/source/de/anomic/plasma/plasmaParserDocument.javaindex 81d616015..e8eb86164 100644--- a/source/de/anomic/plasma/plasmaParserDocument.java+++ b/source/de/anomic/plasma/plasmaParserDocument.java@@ -151,7 +151,9 @@ dc_rights}public String dc_creator() {- if (creator != null) return creator.toString(); else return new String();+ if (creator == null)+ return new String();+ return creator.toString();}public String dc_subject(final char separator) {@@ -172,7 +174,9 @@ dc_rights}public String dc_description() {- if (description != null) return description.toString(); else return dc_title();+ if (description == null)+ return dc_title();+ return description.toString();}public String dc_publisher() {@@ -200,11 +204,10 @@ dc_rights}public String[] getSectionTitles() {- if (sections != null) {- return sections.toArray(new String[this.sections.size()]);- } else {+ if (sections == null) {return new String[] { dc_title() };}+ return sections.toArray(new String[this.sections.size()]);}public InputStream getText() {@@ -237,9 +240,8 @@ dc_rightsfinal serverCachedFileOutputStream ffbaos = (serverCachedFileOutputStream)this.text;if (ffbaos.isFallback()) {return serverFileUtils.read(ffbaos.getContent());- } else {- return ffbaos.getContentBAOS();}+ return ffbaos.getContentBAOS();}} catch (final Exception e) {e.printStackTrace();diff --git a/source/de/anomic/plasma/plasmaProfiling.java b/source/de/anomic/plasma/plasmaProfiling.javaindex 8089226c0..4695317a4 100644--- a/source/de/anomic/plasma/plasmaProfiling.java+++ b/source/de/anomic/plasma/plasmaProfiling.java@@ -74,8 +74,8 @@ public class plasmaProfiling {// draw ppmIterator<Event> i = serverProfiling.history("ppm");long time;- final long now = System.currentTimeMillis();- long bytes;+ final long now = System.currentTimeMillis();+ long bytes;int x0 = 1, x1, y0 = 0, y1, ppm;serverProfiling.Event event;try {diff --git a/source/de/anomic/plasma/plasmaRankingDistribution.java b/source/de/anomic/plasma/plasmaRankingDistribution.javaindex 11e4a73ac..2ee30e005 100644--- a/source/de/anomic/plasma/plasmaRankingDistribution.java+++ b/source/de/anomic/plasma/plasmaRankingDistribution.java@@ -78,7 +78,9 @@ public final class plasmaRankingDistribution {}public int size() {- if ((sourcePath.exists()) && (sourcePath.isDirectory())) return sourcePath.list().length; else return 0;+ if ((sourcePath.exists()) && (sourcePath.isDirectory()))+ return sourcePath.list().length;+ return 0;}public boolean transferRanking(int count) throws InterruptedException {diff --git a/source/de/anomic/plasma/plasmaSearchEvent.java b/source/de/anomic/plasma/plasmaSearchEvent.javaindex b7ddbd829..a96713e7d 100644--- a/source/de/anomic/plasma/plasmaSearchEvent.java+++ b/source/de/anomic/plasma/plasmaSearchEvent.java@@ -870,11 +870,10 @@ public final class plasmaSearchEvent {}public String resource() {// generate transport resource- if ((textSnippet != null) && (textSnippet.exists())) {- return urlentry.toString(textSnippet.getLineRaw());- } else {+ if ((textSnippet == null) || (!textSnippet.exists())) {return urlentry.toString();}+ return urlentry.toString(textSnippet.getLineRaw());}}}diff --git a/source/de/anomic/plasma/plasmaSearchQuery.java b/source/de/anomic/plasma/plasmaSearchQuery.javaindex 7ed8f181d..c5bc5a36d 100644--- a/source/de/anomic/plasma/plasmaSearchQuery.java+++ b/source/de/anomic/plasma/plasmaSearchQuery.java@@ -264,9 +264,8 @@ public final class plasmaSearchQuery {public String queryString(final boolean encodeHTML) {if(encodeHTML){return htmlTools.encodeUnicode2html(this.queryString, true);- } else {- return this.queryString;}+ return this.queryString;}public TreeSet<String>[] queryWords() {@@ -284,9 +283,8 @@ public final class plasmaSearchQuery {// generate a string that identifies a search so results can be re-used in a cacheif (anonymized) {return anonymizedQueryHashes(this.queryHashes) + "-" + anonymizedQueryHashes(this.excludeHashes) + "*" + this.contentdom + "*" + this.zonecode + "*" + indexWord.word2hash(this.ranking.toExternalString());- } else {- return hashSet2hashString(this.queryHashes) + "-" + hashSet2hashString(this.excludeHashes) + "*" + this.contentdom + "*" + this.zonecode + "*" + indexWord.word2hash(this.ranking.toExternalString());}+ return hashSet2hashString(this.queryHashes) + "-" + hashSet2hashString(this.excludeHashes) + "*" + this.contentdom + "*" + this.zonecode + "*" + indexWord.word2hash(this.ranking.toExternalString());}}diff --git a/source/de/anomic/plasma/plasmaSearchRankingProcess.java b/source/de/anomic/plasma/plasmaSearchRankingProcess.javaindex 3dd1581f6..6bc2494e6 100644--- a/source/de/anomic/plasma/plasmaSearchRankingProcess.java+++ b/source/de/anomic/plasma/plasmaSearchRankingProcess.java@@ -203,11 +203,10 @@ public final class plasmaSearchRankingProcess {// if we already have enough entries, insert only such that are necessary to get a better resultif (stack.bottom(r.longValue())) {continue;- } else {- // double-check- if (urlhashes.containsKey(iEntry.urlHash())) continue;- stack.push(iEntry, r);}+ // double-check+ if (urlhashes.containsKey(iEntry.urlHash())) continue;+ stack.push(iEntry, r);}// increase counter for statisticsdiff --git a/source/de/anomic/plasma/plasmaSearchRankingProfile.java b/source/de/anomic/plasma/plasmaSearchRankingProfile.javaindex 7bf5b0721..72bdca15a 100644--- a/source/de/anomic/plasma/plasmaSearchRankingProfile.java+++ b/source/de/anomic/plasma/plasmaSearchRankingProfile.java@@ -164,13 +164,9 @@ public class plasmaSearchRankingProfile {}private static int parseMap(final HashMap<String, Integer> coeff, final String attr, final int dflt) {- if (coeff.containsKey(attr)) try {- return (coeff.get(attr)).intValue();- } catch (final NumberFormatException e) {+ if (!coeff.containsKey(attr))return dflt;- } else {- return dflt;- }+ return (coeff.get(attr)).intValue();}public String toExternalString() {diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.javaindex 7736864f9..4eb342c47 100644--- a/source/de/anomic/plasma/plasmaSwitchboard.java+++ b/source/de/anomic/plasma/plasmaSwitchboard.java@@ -117,7 +117,6 @@ import de.anomic.crawler.HTTPLoader;import de.anomic.crawler.ImporterManager;import de.anomic.crawler.IndexingStack;import de.anomic.crawler.NoticedURL;-import de.anomic.crawler.ProtocolLoader;import de.anomic.crawler.ResourceObserver;import de.anomic.crawler.ResultImages;import de.anomic.crawler.ResultURLs;@@ -137,12 +136,9 @@ import de.anomic.http.JakartaCommonsHttpClient;import de.anomic.http.httpHeader;import de.anomic.http.httpRemoteProxyConfig;import de.anomic.http.httpd;-import de.anomic.http.httpdProxyHandler;import de.anomic.http.httpdRobotsTxtConfig;-import de.anomic.index.indexDefaultReferenceBlacklist;import de.anomic.index.indexReferenceBlacklist;import de.anomic.index.indexURLReference;-import de.anomic.kelondro.kelondroBitfield;import de.anomic.kelondro.kelondroCache;import de.anomic.kelondro.kelondroCachedRecords;import de.anomic.kelondro.kelondroMSetTools;@@ -185,18 +181,6 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.private int dhtTransferIndexCount = 100;public static long lastPPMUpdate = System.currentTimeMillis()- 30000;- // we must distinguish the following cases: resource-load was initiated by- // 1) global crawling: the index is extern, not here (not possible here)- // 2) result of search queries, some indexes are here (not possible here)- // 3) result of index transfer, some of them are here (not possible here)- // 4) proxy-load (initiator is "------------")- // 5) local prefetch/crawling (initiator is own seedHash)- // 6) local fetching for global crawling (other known or unknown initiator)- public static final int PROCESSCASE_0_UNKNOWN = 0;- public static final int PROCESSCASE_4_PROXY_LOAD = 4;- public static final int PROCESSCASE_5_LOCAL_CRAWLING = 5;- public static final int PROCESSCASE_6_GLOBAL_CRAWLING = 6;-// couloured list managementpublic static TreeSet<String> badwords = null;public static TreeSet<String> blueList = null;@@ -215,7 +199,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.public File rankingPath;public File workPath;public File releasePath;- public HashMap<String, String> rankingPermissions;+ public Map<String, String> rankingPermissions;public plasmaWordIndex webIndex;public CrawlQueues crawlQueues;public ResultURLs crawlResults;@@ -262,568 +246,12 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.public httpdRobotsTxtConfig robotstxtConfig = null;- /*- * Some constants- */- public static final String STR_REMOTECRAWLTRIGGER = "REMOTECRAWLTRIGGER: REMOTE CRAWL TO PEER ";-private final serverSemaphore shutdownSync = new serverSemaphore(0);private boolean terminate = false;//private Object crawlingPausedSync = new Object();//private boolean crawlingIsPaused = false;- public static final int CRAWLJOB_SYNC = 0;- public static final int CRAWLJOB_STATUS = 1;-- //////////////////////////////////////////////////////////////////////////////////////////////- // Thread settings- //////////////////////////////////////////////////////////////////////////////////////////////-- // 20_dhtdistribution- /**- * <p><code>public static final String <strong>INDEX_DIST</strong> = "20_dhtdistribution"</code></p>- * <p>Name of the DHT distribution thread, which selects index chunks and transfers them to other peers- * according to the global DHT rules</p>- */- public static final String INDEX_DIST = "20_dhtdistribution";- public static final String INDEX_DIST_METHOD_START = "dhtTransferJob";- public static final String INDEX_DIST_METHOD_JOBCOUNT = null;- public static final String INDEX_DIST_METHOD_FREEMEM = null;- public static final String INDEX_DIST_MEMPREREQ = "20_dhtdistribution_memprereq";- public static final String INDEX_DIST_IDLESLEEP = "20_dhtdistribution_idlesleep";- public static final String INDEX_DIST_BUSYSLEEP = "20_dhtdistribution_busysleep";-- // 30_peerping- /**- * <p><code>public static final String <strong>PEER_PING</strong> = "30_peerping"</code></p>- * <p>Name of the Peer Ping thread which publishes the own peer and retrieves information about other peers- * connected to the YaCy-network</p>- */- public static final String PEER_PING = "30_peerping";- public static final String PEER_PING_METHOD_START = "peerPing";- public static final String PEER_PING_METHOD_JOBCOUNT = null;- public static final String PEER_PING_METHOD_FREEMEM = null;- public static final String PEER_PING_IDLESLEEP = "30_peerping_idlesleep";- public static final String PEER_PING_BUSYSLEEP = "30_peerping_busysleep";-- // 40_peerseedcycle- /**- * <p><code>public static final String <strong>SEED_UPLOAD</strong> = "40_peerseedcycle"</code></p>- * <p>Name of the seed upload thread, providing the so-called seed-lists needed during bootstrapping</p>- */- public static final String SEED_UPLOAD = "40_peerseedcycle";- public static final String SEED_UPLOAD_METHOD_START = "publishSeedList";- public static final String SEED_UPLOAD_METHOD_JOBCOUNT = null;- public static final String SEED_UPLOAD_METHOD_FREEMEM = null;- public static final String SEED_UPLOAD_IDLESLEEP = "40_peerseedcycle_idlesleep";- public static final String SEED_UPLOAD_BUSYSLEEP = "40_peerseedcycle_busysleep";-- // 50_localcrawl- /**- * <p><code>public static final String <strong>CRAWLJOB_LOCAL_CRAWL</strong> = "50_localcrawl"</code></p>- * <p>Name of the local crawler thread, popping one entry off the Local Crawl Queue, and passing it to the- * proxy cache enqueue thread to download and further process it</p>- *- * @see plasmaSwitchboard#PROXY_CACHE_ENQUEUE- */- public static final String CRAWLJOB_LOCAL_CRAWL = "50_localcrawl";- public static final String CRAWLJOB_LOCAL_CRAWL_METHOD_START = "coreCrawlJob";- public static final String CRAWLJOB_LOCAL_CRAWL_METHOD_JOBCOUNT = "coreCrawlJobSize";- public static final String CRAWLJOB_LOCAL_CRAWL_METHOD_FREEMEM = null;- public static final String CRAWLJOB_LOCAL_CRAWL_IDLESLEEP = "50_localcrawl_idlesleep";- public static final String CRAWLJOB_LOCAL_CRAWL_BUSYSLEEP = "50_localcrawl_busysleep";-- // 61_globalcawltrigger- /**- * <p><code>public static final String <strong>CRAWLJOB_REMOTE_CRAWL_LOADER</strong> = "60_remotecrawlloader"</code></p>- * <p>Name of the remote crawl list loading thread</p>- *- * @see plasmaSwitchboard#CRAWLJOB_REMOTE_CRAWL_LOADER- */- public static final String CRAWLJOB_REMOTE_CRAWL_LOADER = "60_remotecrawlloader";- public static final String CRAWLJOB_REMOTE_CRAWL_LOADER_METHOD_START = "remoteCrawlLoaderJob";- public static final String CRAWLJOB_REMOTE_CRAWL_LOADER_METHOD_JOBCOUNT = null;- public static final String CRAWLJOB_REMOTE_CRAWL_LOADER_METHOD_FREEMEM = null;- public static final String CRAWLJOB_REMOTE_CRAWL_LOADER_IDLESLEEP = "60_remotecrawlloader_idlesleep";- public static final String CRAWLJOB_REMOTE_CRAWL_LOADER_BUSYSLEEP = "60_remotecrawlloader_busysleep";-- // 62_remotetriggeredcrawl- /**- * <p><code>public static final String <strong>CRAWLJOB_REMOTE_TRIGGERED_CRAWL</strong> = "62_remotetriggeredcrawl"</code></p>- * <p>Name of the remote triggered crawl thread, responsible for processing a remote crawl received from another peer</p>- */- public static final String CRAWLJOB_REMOTE_TRIGGERED_CRAWL = "62_remotetriggeredcrawl";- public static final String CRAWLJOB_REMOTE_TRIGGERED_CRAWL_METHOD_START = "remoteTriggeredCrawlJob";- public static final String CRAWLJOB_REMOTE_TRIGGERED_CRAWL_METHOD_JOBCOUNT = "remoteTriggeredCrawlJobSize";- public static final String CRAWLJOB_REMOTE_TRIGGERED_CRAWL_METHOD_FREEMEM = null;- public static final String CRAWLJOB_REMOTE_TRIGGERED_CRAWL_IDLESLEEP = "62_remotetriggeredcrawl_idlesleep";- public static final String CRAWLJOB_REMOTE_TRIGGERED_CRAWL_BUSYSLEEP = "62_remotetriggeredcrawl_busysleep";-- // 70_cachemanager- /**- * <p><code>public static final String <strong>PROXY_CACHE_ENQUEUE</strong> = "70_cachemanager"</code></p>- * <p>Name of the proxy cache enqueue thread which fetches a given website and saves the site itself as well as it's- * HTTP-headers in the HTCACHE</p>- *- * @see plasmaSwitchboard#PROXY_CACHE_PATH- */- public static final String PROXY_CACHE_ENQUEUE = "70_cachemanager";- public static final String PROXY_CACHE_ENQUEUE_METHOD_START = "htEntryStoreJob";- public static final String PROXY_CACHE_ENQUEUE_METHOD_JOBCOUNT = "htEntrySize";- public static final String PROXY_CACHE_ENQUEUE_METHOD_FREEMEM = null;- public static final String PROXY_CACHE_ENQUEUE_IDLESLEEP = "70_cachemanager_idlesleep";- public static final String PROXY_CACHE_ENQUEUE_BUSYSLEEP = "70_cachemanager_busysleep";--- // 74_parsing- /**- * <p><code>public static final String <strong>INDEXER</strong> = "80_indexing"</code></p>- * <p>Name of the indexer thread, performing the actual indexing of a website</p>- */- public static final String PARSER = "74_indexing";- public static final String PARSER_MEMPREREQ = "74_indexing_memprereq";- public static final String PARSER_IDLESLEEP = "74_indexing_idlesleep";- public static final String PARSER_BUSYSLEEP = "74_indexing_busysleep";- public static final String PARSER_METHOD_START = "deQueueProcess";- public static final String PARSER_METHOD_JOBCOUNT = "queueSize";- public static final String PARSER_METHOD_FREEMEM = "deQueueFreeMem";--- // 80_indexing- /**- * <p><code>public static final String <strong>INDEXER</strong> = "80_indexing"</code></p>- * <p>Name of the indexer thread, performing the actual indexing of a website</p>- */- public static final String INDEXER = "80_indexing";- public static final String INDEXER_MEMPREREQ = "80_indexing_memprereq";- public static final String INDEXER_IDLESLEEP = "80_indexing_idlesleep";- public static final String INDEXER_BUSYSLEEP = "80_indexing_busysleep";- public static final String INDEXER_METHOD_START = "deQueueProcess";- public static final String INDEXER_METHOD_JOBCOUNT = "queueSize";- public static final String INDEXER_METHOD_FREEMEM = "deQueueFreeMem";- public static final String INDEXER_SLOTS = "indexer.slots";-- // 82_crawlstack- /**- * <p><code>public static final String <strong>CRAWLSTACK</strong> = "82_crawlstack"</code></p>- * <p>Name of the crawl stacker thread, performing several checks on new URLs to crawl, i.e. double-check</p>- */- public static final String CRAWLSTACK = "82_crawlstack";- public static final String CRAWLSTACK_METHOD_START = "job";- public static final String CRAWLSTACK_METHOD_JOBCOUNT = "size";- public static final String CRAWLSTACK_METHOD_FREEMEM = null;- public static final String CRAWLSTACK_IDLESLEEP = "82_crawlstack_idlesleep";- public static final String CRAWLSTACK_BUSYSLEEP = "82_crawlstack_busysleep";- public static final String CRAWLSTACK_SLOTS = "stacker.slots";-- // 90_cleanup- /**- * <p><code>public static final String <strong>CLEANUP</strong> = "90_cleanup"</code></p>- * <p>The cleanup thread which is responsible for pendant cleanup-jobs, news/ranking distribution, etc.</p>- */- public static final String CLEANUP = "90_cleanup";- public static final String CLEANUP_METHOD_START = "cleanupJob";- public static final String CLEANUP_METHOD_JOBCOUNT = "cleanupJobSize";- public static final String CLEANUP_METHOD_FREEMEM = null;- public static final String CLEANUP_IDLESLEEP = "90_cleanup_idlesleep";- public static final String CLEANUP_BUSYSLEEP = "90_cleanup_busysleep";-- //////////////////////////////////////////////////////////////////////////////////////////////- // RAM Cache settings- //////////////////////////////////////////////////////////////////////////////////////////////-- /**- * <p><code>public static final String <strong>RAM_CACHE_LURL</strong> = "ramCacheLURL"</code></p>- * <p>Name of the setting how much memory in bytes should be assigned to the Loaded URLs DB for caching purposes</p>- */- public static final String RAM_CACHE_LURL_TIME = "ramCacheLURL_time";- /**- * <p><code>public static final String <strong>RAM_CACHE_NURL</strong> = "ramCacheNURL"</code></p>- * <p>Name of the setting how much memory in bytes should be assigned to the Noticed URLs DB for caching purposes</p>- */- public static final String RAM_CACHE_NURL_TIME = "ramCacheNURL_time";- /**- * <p><code>public static final String <strong>RAM_CACHE_EURL</strong> = "ramCacheEURL"</code></p>- * <p>Name of the setting how much memory in bytes should be assigned to the Erroneous URLs DB for caching purposes</p>- */- public static final String RAM_CACHE_EURL_TIME = "ramCacheEURL_time";- /**- * <p><code>public static final String <strong>RAM_CACHE_RWI</strong> = "ramCacheRWI"</code></p>- * <p>Name of the setting how much memory in bytes should be assigned to the RWIs DB for caching purposes</p>- */- public static final String RAM_CACHE_RWI_TIME = "ramCacheRWI_time";- /**- * <p><code>public static final String <strong>RAM_CACHE_HTTP</strong> = "ramCacheHTTP"</code></p>- * <p>Name of the setting how much memory in bytes should be assigned to the HTTP Headers DB for caching purposes</p>- */- public static final String RAM_CACHE_HTTP_TIME = "ramCacheHTTP_time";- /**- * <p><code>public static final String <strong>RAM_CACHE_MESSAGE</strong> = "ramCacheMessage"</code></p>- * <p>Name of the setting how much memory in bytes should be assigned to the Message DB for caching purposes</p>- */- public static final String RAM_CACHE_MESSAGE_TIME = "ramCacheMessage_time";- /**- * <p><code>public static final String <strong>RAM_CACHE_ROBOTS</strong> = "ramCacheRobots"</code></p>- * <p>Name of the setting how much memory in bytes should be assigned to the robots.txts DB for caching purposes</p>- */- public static final String RAM_CACHE_ROBOTS_TIME = "ramCacheRobots_time";- /**- * <p><code>public static final String <strong>RAM_CACHE_PROFILES</strong> = "ramCacheProfiles"</code></p>- * <p>Name of the setting how much memory in bytes should be assigned to the Crawl Profiles DB for caching purposes</p>- */- public static final String RAM_CACHE_PROFILES_TIME = "ramCacheProfiles_time";- /**- * <p><code>public static final String <strong>RAM_CACHE_PRE_NURL</strong> = "ramCachePreNURL"</code></p>- * <p>Name of the setting how much memory in bytes should be assigned to the Pre-Noticed URLs DB for caching purposes</p>- */- public static final String RAM_CACHE_PRE_NURL_TIME = "ramCachePreNURL_time";- /**- * <p><code>public static final String <strong>RAM_CACHE_WIKI</strong> = "ramCacheWiki"</code></p>- * <p>Name of the setting how much memory in bytes should be assigned to the Wiki DB for caching purposes</p>- */- public static final String RAM_CACHE_WIKI_TIME = "ramCacheWiki_time";- /**- * <p><code>public static final String <strong>RAM_CACHE_BLOG</strong> = "ramCacheBlog"</code></p>- * <p>Name of the setting how much memory in bytes should be assigned to the Blog DB for caching purposes</p>- */- public static final String RAM_CACHE_BLOG_TIME = "ramCacheBlog_time";-- //////////////////////////////////////////////////////////////////////////////////////////////- // DHT settings- //////////////////////////////////////////////////////////////////////////////////////////////-- /**- * <p><code>public static final String <strong>INDEX_DIST_DHT_RECEIPT_LIMIT</strong> = "indexDistribution.dhtReceiptLimit"</code></p>- * <p>Name of the setting how many words the DHT-In cache may contain maximal before new DHT receipts- * will be rejected</p>- */- public static final String INDEX_DIST_DHT_RECEIPT_LIMIT = "indexDistribution.dhtReceiptLimit";- /**- * <p><code>public static final String <strong>INDEX_DIST_CHUNK_SIZE_START</strong> = "indexDistribution.startChunkSize"</code></p>- * <p>Name of the setting specifying how many words the very first chunk will contain when the DHT-thread starts</p>- */- public static final String INDEX_DIST_CHUNK_SIZE_START = "indexDistribution.startChunkSize";- /**- * <p><code>public static final String <strong>INDEX_DIST_CHUNK_SIZE_MIN</strong> = "indexDistribution.minChunkSize"</code></p>- * <p>Name of the setting specifying how many words the smallest chunk may contain</p>- */- public static final String INDEX_DIST_CHUNK_SIZE_MIN = "indexDistribution.minChunkSize";- /**- * <p><code>public static final String <strong>INDEX_DIST_CHUNK_SIZE_MAX</strong> = "indexDistribution.maxChunkSize"</code></p>- * <p>Name of the setting specifying how many words the hugest chunk may contain</p>- */- public static final String INDEX_DIST_CHUNK_SIZE_MAX = "indexDistribution.maxChunkSize";- public static final String INDEX_DIST_CHUNK_FAILS_MAX = "indexDistribution.maxChunkFails";- /**- * <p><code>public static final String <strong>INDEX_DIST_TIMEOUT</strong> = "indexDistribution.timeout"</code></p>- * <p>Name of the setting how long the timeout for an Index Distribution shall be in milliseconds</p>- */- public static final String INDEX_DIST_TIMEOUT = "indexDistribution.timeout";- /**- * <p><code>public static final String <strong>INDEX_DIST_GZIP_BODY</strong> = "indexDistribution.gzipBody"</code></p>- * <p>Name of the setting whether DHT chunks shall be transferred gzip-encodedly</p>- */- public static final String INDEX_DIST_GZIP_BODY = "indexDistribution.gzipBody";- /**- * <p><code>public static final String <strong>INDEX_DIST_ALLOW</strong> = "allowDistributeIndex"</code></p>- * <p>Name of the setting whether Index Distribution shall be allowed (and the DHT-thread therefore started) or not</p>- *- * @see plasmaSwitchboard#INDEX_DIST_ALLOW_WHILE_CRAWLING- */- public static final String INDEX_DIST_ALLOW = "allowDistributeIndex";- public static final String INDEX_RECEIVE_ALLOW = "allowReceiveIndex";- /**- * <p><code>public static final String <strong>INDEX_DIST_ALLOW_WHILE_CRAWLING</strong> = "allowDistributeIndexWhileCrawling"</code></p>- * <p>Name of the setting whether Index Distribution shall be allowed while crawling is in progress, i.e.- * the Local Crawler Queue is filled.</p>- * <p>This setting only has effect if {@link #INDEX_DIST_ALLOW} is enabled</p>- *- * @see plasmaSwitchboard#INDEX_DIST_ALLOW- */- public static final String INDEX_DIST_ALLOW_WHILE_CRAWLING = "allowDistributeIndexWhileCrawling";- public static final String INDEX_DIST_ALLOW_WHILE_INDEXING = "allowDistributeIndexWhileIndexing";- public static final String INDEX_TRANSFER_TIMEOUT = "indexTransfer.timeout";- public static final String INDEX_TRANSFER_GZIP_BODY = "indexTransfer.gzipBody";-- //////////////////////////////////////////////////////////////////////////////////////////////- // Ranking settings- //////////////////////////////////////////////////////////////////////////////////////////////-- public static final String RANKING_DIST_ON = "CRDistOn";- public static final String RANKING_DIST_0_PATH = "CRDist0Path";- public static final String RANKING_DIST_0_METHOD = "CRDist0Method";- public static final String RANKING_DIST_0_PERCENT = "CRDist0Percent";- public static final String RANKING_DIST_0_TARGET = "CRDist0Target";- public static final String RANKING_DIST_1_PATH = "CRDist1Path";- public static final String RANKING_DIST_1_METHOD = "CRDist1Method";- public static final String RANKING_DIST_1_PERCENT = "CRDist1Percent";- public static final String RANKING_DIST_1_TARGET = "CRDist1Target";-- //////////////////////////////////////////////////////////////////////////////////////////////- // Parser settings- //////////////////////////////////////////////////////////////////////////////////////////////-- public static final String PARSER_MIMETYPES_HTML = "parseableMimeTypes.HTML";- public static final String PARSER_MIMETYPES_PROXY = "parseableMimeTypes.PROXY";- public static final String PARSER_MIMETYPES_CRAWLER = "parseableMimeTypes.CRAWLER";- public static final String PARSER_MIMETYPES_ICAP = "parseableMimeTypes.ICAP";- public static final String PARSER_MIMETYPES_URLREDIRECTOR = "parseableMimeTypes.URLREDIRECTOR";- public static final String PARSER_MIMETYPES_IMAGE = "parseableMimeTypes.IMAGE";- public static final String PARSER_MEDIA_EXT = "mediaExt";- public static final String PARSER_MEDIA_EXT_PARSEABLE = "parseableExt";-- //////////////////////////////////////////////////////////////////////////////////////////////- // Proxy settings- //////////////////////////////////////////////////////////////////////////////////////////////-- /**- * <p><code>public static final String <strong>PROXY_ONLINE_CAUTION_DELAY</strong> = "onlineCautionDelay"</code></p>- * <p>Name of the setting how long indexing should pause after the last time the proxy was used in milliseconds</p>- */- public static final String PROXY_ONLINE_CAUTION_DELAY = "crawlPause.proxy";- public static final String LOCALSEACH_ONLINE_CAUTION_DELAY = "crawlPause.localsearch";- public static final String REMOTESEARCH_ONLINE_CAUTION_DELAY = "crawlPause.remotesearch";- /**- * <p><code>public static final String <strong>PROXY_PREFETCH_DEPTH</strong> = "proxyPrefetchDepth"</code></p>- * <p>Name of the setting how deep URLs fetched by proxy usage shall be followed</p>- */- public static final String PROXY_PREFETCH_DEPTH = "proxyPrefetchDepth";- public static final String PROXY_CRAWL_ORDER = "proxyCrawlOrder";-- public static final String PROXY_INDEXING_REMOTE = "proxyIndexingRemote";- public static final String PROXY_INDEXING_LOCAL_TEXT = "proxyIndexingLocalText";- public static final String PROXY_INDEXING_LOCAL_MEDIA = "proxyIndexingLocalMedia";-- public static final String PROXY_CACHE_SIZE = "proxyCacheSize";- /**- * <p><code>public static final String <strong>PROXY_CACHE_LAYOUT</strong> = "proxyCacheLayout"</code></p>- * <p>Name of the setting which file-/folder-layout the proxy cache shall use. Possible values are {@link #PROXY_CACHE_LAYOUT_TREE}- * and {@link #PROXY_CACHE_LAYOUT_HASH}</p>- *- * @see plasmaSwitchboard#PROXY_CACHE_LAYOUT_TREE- * @see plasmaSwitchboard#PROXY_CACHE_LAYOUT_HASH- */-- //////////////////////////////////////////////////////////////////////////////////////////////- // Cluster settings- //////////////////////////////////////////////////////////////////////////////////////////////-- public static final String CLUSTER_MODE = "cluster.mode";- public static final String CLUSTER_MODE_PUBLIC_CLUSTER = "publiccluster";- public static final String CLUSTER_MODE_PRIVATE_CLUSTER = "privatecluster";- public static final String CLUSTER_MODE_PUBLIC_PEER = "publicpeer";- public static final String CLUSTER_PEERS_IPPORT = "cluster.peers.ipport";-- //////////////////////////////////////////////////////////////////////////////////////////////- // Miscellaneous settings- //////////////////////////////////////////////////////////////////////////////////////////////-- /**- * <p><code>public static final String <strong>CRAWLER_THREADS_ACTIVE_MAX</strong> = "crawler.MaxActiveThreads"</code></p>- * <p>Name of the setting how many active crawler-threads may maximal be running on the same time</p>- */- public static final String CRAWLER_THREADS_ACTIVE_MAX = "crawler.MaxActiveThreads";- public static final String YACY_MODE_DEBUG = "yacyDebugMode";- public static final String WORDCACHE_INIT_COUNT = "wordCacheInitCount";- /**- * <p><code>public static final String <strong>WORDCACHE_MAX_COUNT</strong> = "wordCacheMaxCount"</code></p>- * <p>Name of the setting how many words the word-cache (or DHT-Out cache) shall contain maximal. Indexing pages if the- * cache has reached this limit will slow down the indexing process by flushing some of it's entries</p>- */- public static final String WORDCACHE_MAX_COUNT = "wordCacheMaxCount";-- public static final String HTTPC_NAME_CACHE_CACHING_PATTERNS_NO = "httpc.nameCacheNoCachingPatterns";-- public static final String ROBOTS_TXT = "httpd.robots.txt";- public static final String ROBOTS_TXT_DEFAULT = httpdRobotsTxtConfig.LOCKED + "," + httpdRobotsTxtConfig.DIRS;-- public static final String WIKIPARSER_CLASS = "wikiParser.class";- public static final String WIKIPARSER_CLASS_DEFAULT = "de.anomic.data.wikiCode";-- //////////////////////////////////////////////////////////////////////////////////////////////- // Lists- //////////////////////////////////////////////////////////////////////////////////////////////-- /**- * <p><code>public static final String <strong>BLACKLIST_CLASS</strong> = "Blacklist.class"</code></p>- * <p>Name of the setting which Blacklist backend shall be used. Due to different requirements of users, the- * {@link plasmaURLPattern}-interface has been created to support blacklist engines different from YaCy's default</p>- * <p>Attention is required when the backend is changed, because different engines may have different syntaxes</p>- */- public static final String BLACKLIST_CLASS = "BlackLists.class";- /**- * <p><code>public static final String <strong>BLACKLIST_CLASS_DEFAULT</strong> = "de.anomic.plasma.urlPattern.defaultURLPattern"</code></p>- * <p>Package and name of YaCy's {@link indexDefaultReferenceBlacklist default} blacklist implementation</p>- *- * @see indexDefaultReferenceBlacklist for a detailed overview about the syntax of the default implementation- */- public static final String BLACKLIST_CLASS_DEFAULT = "de.anomic.index.indexDefaultReferenceBlacklist";-- public static final String LIST_BLUE = "plasmaBlueList";- public static final String LIST_BLUE_DEFAULT = null;- public static final String LIST_BADWORDS_DEFAULT = "yacy.badwords";- public static final String LIST_STOPWORDS_DEFAULT = "yacy.stopwords";-- //////////////////////////////////////////////////////////////////////////////////////////////- // DB Paths- //////////////////////////////////////////////////////////////////////////////////////////////-- /**- * <p><code>public static final String <strong>DBPATH</strong> = "dbPath"</code></p>- * <p>Name of the setting specifying the folder beginning from the YaCy-installation's top-folder, where all- * databases containing queues are stored</p>- */- public static final String PLASMA_PATH = "dbPath";- public static final String PLASMA_PATH_DEFAULT = "DATA/PLASMADB";- /**- * <p><code>public static final String <strong>HTCACHE_PATH</strong> = "proxyCache"</code></p>- * <p>Name of the setting specifying the folder beginning from the YaCy-installation's top-folder, where all- * downloaded webpages and their respective ressources and HTTP-headers are stored. It is the location containing- * the proxy-cache</p>- *- * @see plasmaSwitchboard#PROXY_CACHE_LAYOUT for details on the file-layout in this path- */- public static final String HTCACHE_PATH = "proxyCache";- public static final String HTCACHE_PATH_DEFAULT = "DATA/HTCACHE";- public static final String RELEASE_PATH = "releases";- public static final String RELEASE_PATH_DEFAULT = "DATA/RELEASE";- /**- * <p><code>public static final String <strong>HTDOCS_PATH</strong> = "htDocsPath"</code></p>- * <p>Name of the setting specifying the folder beginning from the YaCy-installation's top-folder, where all- * user-ressources (i.e. for the fileshare or the contents displayed on <code>www.peername.yacy</code>) lie.- * The translated templates of the webinterface will also be put in here</p>- */- public static final String HTDOCS_PATH = "htDocsPath";- public static final String HTDOCS_PATH_DEFAULT = "DATA/HTDOCS";- /**- * <p><code>public static final String <strong>HTROOT_PATH</strong> = "htRootPath"</code></p>- * <p>Name of the setting specifying the folder beginning from the YaCy-installation's top-folder, where all- * original servlets, their stylesheets, scripts, etc. lie. It is also home of the XML-interface to YaCy</p>- */- public static final String HTROOT_PATH = "htRootPath";- public static final String HTROOT_PATH_DEFAULT = "htroot";- /**- * <p><code>public static final String <strong>INDEX_PATH</strong> = "indexPath"</code></p>- * <p>Name of the setting specifying the folder beginning from the YaCy-installation's top-folder, where the- * whole database of known RWIs and URLs as well as dumps of the DHT-In and DHT-Out caches are stored</p>- */- public static final String INDEX_PRIMARY_PATH = "indexPrimaryPath"; // this is a relative path to the data root- public static final String INDEX_SECONDARY_PATH = "indexSecondaryPath"; // this is a absolute path to any location- public static final String INDEX_PATH_DEFAULT = "DATA/INDEX";- /**- * <p><code>public static final String <strong>LISTS_PATH</strong> = "listsPath"</code></p>- * <p>Name of the setting specifying the folder beginning from the YaCy-installation's top-folder, where all- * user-lists like blacklists, etc. are stored</p>- */- public static final String LISTS_PATH = "listsPath";- public static final String LISTS_PATH_DEFAULT = "DATA/LISTS";- /**- * <p><code>public static final String <strong>RANKING_PATH</strong> = "rankingPath"</code></p>- * <p>Name of the setting specifying the folder beginning from the YaCy-installation's top-folder, where all- * ranking files are stored, self-generated as well as received ranking files</p>- *- * @see plasmaSwitchboard#RANKING_DIST_0_PATH- * @see plasmaSwitchboard#RANKING_DIST_1_PATH- */- public static final String RANKING_PATH = "rankingPath";- public static final String RANKING_PATH_DEFAULT = "DATA/RANKING";- /**- * <p><code>public static final String <strong>WORK_PATH</strong> = "wordPath"</code></p>- * <p>Name of the setting specifying the folder beginning from the YaCy-installation's top-folder, where all- * DBs containing "work" of the user are saved. Such include bookmarks, messages, wiki, blog</p>- *- * @see plasmaSwitchboard#DBFILE_BLOG- * @see plasmaSwitchboard#DBFILE_BOOKMARKS- * @see plasmaSwitchboard#DBFILE_BOOKMARKS_DATES- * @see plasmaSwitchboard#DBFILE_BOOKMARKS_TAGS- * @see plasmaSwitchboard#DBFILE_MESSAGE- * @see plasmaSwitchboard#DBFILE_WIKI- * @see plasmaSwitchboard#DBFILE_WIKI_BKP- */- public static final String WORK_PATH = "workPath";- public static final String WORK_PATH_DEFAULT = "DATA/WORK";-- //////////////////////////////////////////////////////////////////////////////////////////////- // DB files- //////////////////////////////////////////////////////////////////////////////////////////////-- /**- * <p><code>public static final String <strong>DBFILE_MESSAGE</strong> = "message.db"</code></p>- * <p>Name of the file containing the database holding the user's peer-messages</p>- *- * @see plasmaSwitchboard#WORK_PATH for the folder, this file lies in- */- public static final String DBFILE_MESSAGE = "message.db";- /**- * <p><code>public static final String <strong>DBFILE_WIKI</strong> = "wiki.db"</code></p>- * <p>Name of the file containing the database holding the whole wiki of this peer</p>- *- * @see plasmaSwitchboard#WORK_PATH for the folder, this file lies in- * @see plasmaSwitchboard#DBFILE_WIKI_BKP for the file previous versions of wiki-pages lie in- */- public static final String DBFILE_WIKI = "wiki.db";- /**- * <p><code>public static final String <strong>DBFILE_WIKI_BKP</strong> = "wiki-bkp.db"</code></p>- * <p>Name of the file containing the database holding all versions but the latest of the wiki-pages of this peer</p>- *- * @see plasmaSwitchboard#WORK_PATH for the folder this file lies in- * @see plasmaSwitchboard#DBFILE_WIKI for the file the latest version of wiki-pages lie in- */- public static final String DBFILE_WIKI_BKP = "wiki-bkp.db";- /**- * <p><code>public static final String <strong>DBFILE_BLOG</strong> = "blog.db"</code></p>- * <p>Name of the file containing the database holding all blog-entries available on this peer</p>- *- * @see plasmaSwitchboard#WORK_PATH for the folder this file lies in- */- public static final String DBFILE_BLOG = "blog.db";- /**- * <p><code>public static final String <strong>DBFILE_BLOGCOMMENTS</strong> = "blogComment.db"</code></p>- * <p>Name of the file containing the database holding all blogComment-entries available on this peer</p>- *- * @see plasmaSwitchboard#WORK_PATH for the folder this file lies in- */- public static final String DBFILE_BLOGCOMMENTS = "blogComment.db";- /**- * <p><code>public static final String <strong>DBFILE_BOOKMARKS</strong> = "bookmarks.db"</code></p>- * <p>Name of the file containing the database holding all bookmarks available on this peer</p>- *- * @see plasmaSwitchboard#WORK_PATH for the folder this file lies in- * @see bookmarksDB for more detailed overview about the bookmarks structure- */- public static final String DBFILE_BOOKMARKS = "bookmarks.db";- /**- * <p><code>public static final String <strong>DBFILE_BOOKMARKS_TAGS</strong> = "bookmarkTags.db"</code></p>- * <p>Name of the file containing the database holding all tag->bookmark relations</p>- *- * @see plasmaSwitchboard#WORK_PATH for the folder this file lies in- * @see bookmarksDB for more detailed overview about the bookmarks structure- */- public static final String DBFILE_BOOKMARKS_TAGS = "bookmarkTags.db";- /**- * <p><code>public static final String <strong>DBFILE_BOOKMARKS_DATES</strong> = "bookmarkDates.db"</code></p>- * <p>Name of the file containing the database holding all date->bookmark relations</p>- *- * @see plasmaSwitchboard#WORK_PATH for the folder this file lies in- * @see bookmarksDB for more detailed overview about the bookmarks structure- */- public static final String DBFILE_BOOKMARKS_DATES = "bookmarkDates.db";- /**- * <p><code>public static final String <strong>DBFILE_CRAWL_ROBOTS</strong> = "crawlRobotsTxt.db"</code></p>- * <p>Name of the file containing the database holding all <code>robots.txt</code>-entries of the lately crawled domains</p>- *- * @see plasmaSwitchboard#PLASMA_PATH for the folder this file lies in- */- public static final String DBFILE_CRAWL_ROBOTS = "crawlRobotsTxt.heap";- /**- * <p><code>public static final String <strong>DBFILE_USER</strong> = "DATA/SETTINGS/user.db"</code></p>- * <p>Path to the user-DB, beginning from the YaCy-installation's top-folder. It holds all rights the created- * users have as well as all other needed data about them</p>- */- public static final String DBFILE_USER = "DATA/SETTINGS/user.db";--public Hashtable<String, Object[]> crawlJobsStatus = new Hashtable<String, Object[]>();private static plasmaSwitchboard sb = null;@@ -837,46 +265,35 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.setLog(new serverLog("PLASMA"));if (applyPro) this.log.logInfo("This is the pro-version of YaCy");- // make system tray- // TODO: make tray on linux- try {- final boolean trayIcon = getConfig("trayIcon", "false").equals("true");- if (trayIcon && serverSystem.isWindows) {- System.setProperty("java.awt.headless", "false");- yacytray = new yacyTray(this, false);- }- } catch (final Exception e) {- System.setProperty("java.awt.headless", "true");- }-+ initSystemTray();+// remote proxy configuration- httpdProxyHandler.setRemoteProxyConfig(httpRemoteProxyConfig.init(this)); // TODO refactoring- this.log.logConfig("Remote proxy configuration:\n" + httpdProxyHandler.getRemoteProxyConfig().toString());+ httpRemoteProxyConfig.init(this);// load the network definitionoverwriteNetworkDefinition(this);// load values from configs- this.plasmaPath = getConfigPath(PLASMA_PATH, PLASMA_PATH_DEFAULT);+ this.plasmaPath = getConfigPath(plasmaSwitchboardConstants.PLASMA_PATH, plasmaSwitchboardConstants.PLASMA_PATH_DEFAULT);this.log.logConfig("Plasma DB Path: " + this.plasmaPath.toString());- final File indexPrimaryPath = getConfigPath(INDEX_PRIMARY_PATH, INDEX_PATH_DEFAULT);+ final File indexPrimaryPath = getConfigPath(plasmaSwitchboardConstants.INDEX_PRIMARY_PATH, plasmaSwitchboardConstants.INDEX_PATH_DEFAULT);this.log.logConfig("Index Primary Path: " + indexPrimaryPath.toString());- final File indexSecondaryPath = (getConfig(INDEX_SECONDARY_PATH, "").length() == 0) ? indexPrimaryPath : new File(getConfig(INDEX_SECONDARY_PATH, ""));+ final File indexSecondaryPath = (getConfig(plasmaSwitchboardConstants.INDEX_SECONDARY_PATH, "").length() == 0) ? indexPrimaryPath : new File(getConfig(plasmaSwitchboardConstants.INDEX_SECONDARY_PATH, ""));this.log.logConfig("Index Secondary Path: " + indexSecondaryPath.toString());- this.listsPath = getConfigPath(LISTS_PATH, LISTS_PATH_DEFAULT);+ this.listsPath = getConfigPath(plasmaSwitchboardConstants.LISTS_PATH, plasmaSwitchboardConstants.LISTS_PATH_DEFAULT);this.log.logConfig("Lists Path: " + this.listsPath.toString());- this.htDocsPath = getConfigPath(HTDOCS_PATH, HTDOCS_PATH_DEFAULT);+ this.htDocsPath = getConfigPath(plasmaSwitchboardConstants.HTDOCS_PATH, plasmaSwitchboardConstants.HTDOCS_PATH_DEFAULT);this.log.logConfig("HTDOCS Path: " + this.htDocsPath.toString());- this.rankingPath = getConfigPath(RANKING_PATH, RANKING_PATH_DEFAULT);+ this.rankingPath = getConfigPath(plasmaSwitchboardConstants.RANKING_PATH, plasmaSwitchboardConstants.RANKING_PATH_DEFAULT);this.log.logConfig("Ranking Path: " + this.rankingPath.toString());this.rankingPermissions = new HashMap<String, String>(); // mapping of permission - to filename.- this.workPath = getConfigPath(WORK_PATH, WORK_PATH_DEFAULT);+ this.workPath = getConfigPath(plasmaSwitchboardConstants.WORK_PATH, plasmaSwitchboardConstants.WORK_PATH_DEFAULT);this.log.logConfig("Work Path: " + this.workPath.toString());// set a high maximum cache size to current size; this is adopted later automatically- final int wordCacheMaxCount = Math.max((int) getConfigLong(WORDCACHE_INIT_COUNT, 30000),- (int) getConfigLong(WORDCACHE_MAX_COUNT, 20000));- setConfig(WORDCACHE_MAX_COUNT, Integer.toString(wordCacheMaxCount));+ final int wordCacheMaxCount = Math.max((int) getConfigLong(plasmaSwitchboardConstants.WORDCACHE_INIT_COUNT, 30000),+ (int) getConfigLong(plasmaSwitchboardConstants.WORDCACHE_MAX_COUNT, 20000));+ setConfig(plasmaSwitchboardConstants.WORDCACHE_MAX_COUNT, Integer.toString(wordCacheMaxCount));// start indexing managementlog.logConfig("Starting Indexing Management");@@ -905,7 +322,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.// load coloured listsif (blueList == null) {// read only once upon first instantiation of this class- final String f = getConfig(LIST_BLUE, LIST_BLUE_DEFAULT);+ final String f = getConfig(plasmaSwitchboardConstants.LIST_BLUE, plasmaSwitchboardConstants.LIST_BLUE_DEFAULT);final File plasmaBlueListFile = new File(f);if (f != null) blueList = kelondroMSetTools.loadList(plasmaBlueListFile, kelondroNaturalOrder.naturalComparator); else blueList= new TreeSet<String>();this.log.logConfig("loaded blue-list from file " + plasmaBlueListFile.getName() + ", " +@@ -914,12 +331,12 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.}// load the black-list / inspired by [AS]- final File blacklistsPath = getConfigPath(LISTS_PATH, LISTS_PATH_DEFAULT);- String blacklistClassName = getConfig(BLACKLIST_CLASS, BLACKLIST_CLASS_DEFAULT);+ final File blacklistsPath = getConfigPath(plasmaSwitchboardConstants.LISTS_PATH, plasmaSwitchboardConstants.LISTS_PATH_DEFAULT);+ String blacklistClassName = getConfig(plasmaSwitchboardConstants.BLACKLIST_CLASS, plasmaSwitchboardConstants.BLACKLIST_CLASS_DEFAULT);if (blacklistClassName.equals("de.anomic.plasma.urlPattern.defaultURLPattern")) {// patch old class location- blacklistClassName = BLACKLIST_CLASS_DEFAULT;- setConfig(BLACKLIST_CLASS, blacklistClassName);+ blacklistClassName = plasmaSwitchboardConstants.BLACKLIST_CLASS_DEFAULT;+ setConfig(plasmaSwitchboardConstants.BLACKLIST_CLASS, blacklistClassName);}this.log.logConfig("Starting blacklist engine ...");@@ -944,7 +361,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.// load badwords (to filter the topwords)if (badwords == null) {- final File badwordsFile = new File(rootPath, LIST_BADWORDS_DEFAULT);+ final File badwordsFile = new File(rootPath, plasmaSwitchboardConstants.LIST_BADWORDS_DEFAULT);badwords = kelondroMSetTools.loadList(badwordsFile, kelondroNaturalOrder.naturalComparator);this.log.logConfig("loaded badwords from file " + badwordsFile.getName() +", " + badwords.size() + " entries, " +@@ -953,7 +370,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.// load stopwordsif (stopwords == null) {- final File stopwordsFile = new File(rootPath, LIST_STOPWORDS_DEFAULT);+ final File stopwordsFile = new File(rootPath, plasmaSwitchboardConstants.LIST_STOPWORDS_DEFAULT);stopwords = kelondroMSetTools.loadList(stopwordsFile, kelondroNaturalOrder.naturalComparator);this.log.logConfig("loaded stopwords from file " + stopwordsFile.getName() + ", " +stopwords.size() + " entries, " +@@ -968,7 +385,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.// loading the robots.txt dbthis.log.logConfig("Initializing robots.txt DB");- final File robotsDBFile = new File(this.plasmaPath, DBFILE_CRAWL_ROBOTS);+ final File robotsDBFile = new File(this.plasmaPath, plasmaSwitchboardConstants.DBFILE_CRAWL_ROBOTS);robots = new RobotsTxt(robotsDBFile);this.log.logConfig("Loaded robots.txt DB from file " + robotsDBFile.getName() +", " + robots.size() + " entries" +@@ -978,13 +395,13 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.log.logConfig("Starting HT Cache Manager");// create the cache directory- htCachePath = getConfigPath(HTCACHE_PATH, HTCACHE_PATH_DEFAULT);+ htCachePath = getConfigPath(plasmaSwitchboardConstants.HTCACHE_PATH, plasmaSwitchboardConstants.HTCACHE_PATH_DEFAULT);this.log.logInfo("HTCACHE Path = " + htCachePath.getAbsolutePath());- final long maxCacheSize = 1024 * 1024 * Long.parseLong(getConfig(PROXY_CACHE_SIZE, "2")); // this is megabyte+ final long maxCacheSize = 1024 * 1024 * Long.parseLong(getConfig(plasmaSwitchboardConstants.PROXY_CACHE_SIZE, "2")); // this is megabyteplasmaHTCache.init(htCachePath, maxCacheSize);// create the release download directory- releasePath = getConfigPath(RELEASE_PATH, RELEASE_PATH_DEFAULT);+ releasePath = getConfigPath(plasmaSwitchboardConstants.RELEASE_PATH, plasmaSwitchboardConstants.RELEASE_PATH_DEFAULT);releasePath.mkdirs();this.log.logInfo("RELEASE Path = " + releasePath.getAbsolutePath());@@ -999,7 +416,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.// Init User DBthis.log.logConfig("Loading User DB");- final File userDbFile = new File(getRootPath(), DBFILE_USER);+ final File userDbFile = new File(getRootPath(), plasmaSwitchboardConstants.DBFILE_USER);this.userDB = new userDB(userDbFile);this.log.logConfig("Loaded User DB from file " + userDbFile.getName() +", " + this.userDB.size() + " entries" +@@ -1021,17 +438,17 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.// define an extension-blacklistlog.logConfig("Parser: Initializing Extension Mappings for Media/Parser");- plasmaParser.initMediaExt(plasmaParser.extString2extList(getConfig(PARSER_MEDIA_EXT,"")));- plasmaParser.initSupportedHTMLFileExt(plasmaParser.extString2extList(getConfig(PARSER_MEDIA_EXT_PARSEABLE,"")));+ plasmaParser.initMediaExt(plasmaParser.extString2extList(getConfig(plasmaSwitchboardConstants.PARSER_MEDIA_EXT,"")));+ plasmaParser.initSupportedHTMLFileExt(plasmaParser.extString2extList(getConfig(plasmaSwitchboardConstants.PARSER_MEDIA_EXT_PARSEABLE,"")));// define a realtime parsable mimetype listlog.logConfig("Parser: Initializing Mime Types");- plasmaParser.initHTMLParsableMimeTypes(getConfig(PARSER_MIMETYPES_HTML, "application/xhtml+xml,text/html,text/plain"));- plasmaParser.initParseableMimeTypes(plasmaParser.PARSER_MODE_PROXY, getConfig(PARSER_MIMETYPES_PROXY, null));- plasmaParser.initParseableMimeTypes(plasmaParser.PARSER_MODE_CRAWLER, getConfig(PARSER_MIMETYPES_CRAWLER, null));- plasmaParser.initParseableMimeTypes(plasmaParser.PARSER_MODE_ICAP, getConfig(PARSER_MIMETYPES_ICAP, null));- plasmaParser.initParseableMimeTypes(plasmaParser.PARSER_MODE_URLREDIRECTOR, getConfig(PARSER_MIMETYPES_URLREDIRECTOR, null));- plasmaParser.initParseableMimeTypes(plasmaParser.PARSER_MODE_IMAGE, getConfig(PARSER_MIMETYPES_IMAGE, null));+ plasmaParser.initHTMLParsableMimeTypes(getConfig(plasmaSwitchboardConstants.PARSER_MIMETYPES_HTML, "application/xhtml+xml,text/html,text/plain"));+ plasmaParser.initParseableMimeTypes(plasmaParser.PARSER_MODE_PROXY, getConfig(plasmaSwitchboardConstants.PARSER_MIMETYPES_PROXY, null));+ plasmaParser.initParseableMimeTypes(plasmaParser.PARSER_MODE_CRAWLER, getConfig(plasmaSwitchboardConstants.PARSER_MIMETYPES_CRAWLER, null));+ plasmaParser.initParseableMimeTypes(plasmaParser.PARSER_MODE_ICAP, getConfig(plasmaSwitchboardConstants.PARSER_MIMETYPES_ICAP, null));+ plasmaParser.initParseableMimeTypes(plasmaParser.PARSER_MODE_URLREDIRECTOR, getConfig(plasmaSwitchboardConstants.PARSER_MIMETYPES_URLREDIRECTOR, null));+ plasmaParser.initParseableMimeTypes(plasmaParser.PARSER_MODE_IMAGE, getConfig(plasmaSwitchboardConstants.PARSER_MIMETYPES_IMAGE, null));// start a loaderlog.logConfig("Starting Crawl Loader");@@ -1045,15 +462,15 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.* b) remote triggered crawl* c) global crawl trigger*/- this.crawlJobsStatus.put(CRAWLJOB_LOCAL_CRAWL, new Object[]{+ this.crawlJobsStatus.put(plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL, new Object[]{new Object(),- Boolean.valueOf(getConfig(CRAWLJOB_LOCAL_CRAWL + "_isPaused", "false"))});- this.crawlJobsStatus.put(CRAWLJOB_REMOTE_TRIGGERED_CRAWL, new Object[]{+ Boolean.valueOf(getConfig(plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL + "_isPaused", "false"))});+ this.crawlJobsStatus.put(plasmaSwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL, new Object[]{new Object(),- Boolean.valueOf(getConfig(CRAWLJOB_REMOTE_TRIGGERED_CRAWL + "_isPaused", "false"))});- this.crawlJobsStatus.put(CRAWLJOB_REMOTE_CRAWL_LOADER, new Object[]{+ Boolean.valueOf(getConfig(plasmaSwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL + "_isPaused", "false"))});+ this.crawlJobsStatus.put(plasmaSwitchboardConstants.CRAWLJOB_REMOTE_CRAWL_LOADER, new Object[]{new Object(),- Boolean.valueOf(getConfig(CRAWLJOB_REMOTE_CRAWL_LOADER + "_isPaused", "false"))});+ Boolean.valueOf(getConfig(plasmaSwitchboardConstants.CRAWLJOB_REMOTE_CRAWL_LOADER + "_isPaused", "false"))});// init cookie-Monitorthis.log.logConfig("Starting Cookie Monitor");@@ -1067,8 +484,8 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.this.remoteSearches = new ArrayList<plasmaSearchQuery>();// init messages: clean up message symbol- final File notifierSource = new File(getRootPath(), getConfig(HTROOT_PATH, HTROOT_PATH_DEFAULT) + "/env/grafics/empty.gif");- final File notifierDest = new File(getConfigPath(HTDOCS_PATH, HTDOCS_PATH_DEFAULT), "notifier.gif");+ final File notifierSource = new File(getRootPath(), getConfig(plasmaSwitchboardConstants.HTROOT_PATH, plasmaSwitchboardConstants.HTROOT_PATH_DEFAULT) + "/env/grafics/empty.gif");+ final File notifierDest = new File(getConfigPath(plasmaSwitchboardConstants.HTDOCS_PATH, plasmaSwitchboardConstants.HTDOCS_PATH_DEFAULT), "notifier.gif");try {serverFileUtils.copy(notifierSource, notifierDest);} catch (final IOException e) {@@ -1090,9 +507,9 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.CRDist1Percent = 30CRDist1Target = kaskelix.de:8080,yacy.dyndns.org:8000,suma-lab.de:8080**/- rankingOn = getConfig(RANKING_DIST_ON, "true").equals("true") && networkName.equals("freeworld");- rankingOwnDistribution = new plasmaRankingDistribution(log, webIndex.seedDB, new File(rankingPath, getConfig(RANKING_DIST_0_PATH, plasmaRankingDistribution.CR_OWN)), (int) getConfigLong(RANKING_DIST_0_METHOD, plasmaRankingDistribution.METHOD_ANYSENIOR), (int) getConfigLong(RANKING_DIST_0_METHOD, 0), getConfig(RANKING_DIST_0_TARGET, ""));- rankingOtherDistribution = new plasmaRankingDistribution(log, webIndex.seedDB, new File(rankingPath, getConfig(RANKING_DIST_1_PATH, plasmaRankingDistribution.CR_OTHER)), (int) getConfigLong(RANKING_DIST_1_METHOD, plasmaRankingDistribution.METHOD_MIXEDSENIOR), (int) getConfigLong(RANKING_DIST_1_METHOD, 30), getConfig(RANKING_DIST_1_TARGET, "kaskelix.de:8080,yacy.dyndns.org:8000"));+ rankingOn = getConfig(plasmaSwitchboardConstants.RANKING_DIST_ON, "true").equals("true") && networkName.equals("freeworld");+ rankingOwnDistribution = new plasmaRankingDistribution(log, webIndex.seedDB, new File(rankingPath, getConfig(plasmaSwitchboardConstants.RANKING_DIST_0_PATH, plasmaRankingDistribution.CR_OWN)), (int) getConfigLong(plasmaSwitchboardConstants.RANKING_DIST_0_METHOD, plasmaRankingDistribution.METHOD_ANYSENIOR), (int) getConfigLong(plasmaSwitchboardConstants.RANKING_DIST_0_METHOD, 0), getConfig(plasmaSwitchboardConstants.RANKING_DIST_0_TARGET, ""));+ rankingOtherDistribution = new plasmaRankingDistribution(log, webIndex.seedDB, new File(rankingPath, getConfig(plasmaSwitchboardConstants.RANKING_DIST_1_PATH, plasmaRankingDistribution.CR_OTHER)), (int) getConfigLong(plasmaSwitchboardConstants.RANKING_DIST_1_METHOD, plasmaRankingDistribution.METHOD_MIXEDSENIOR), (int) getConfigLong(plasmaSwitchboardConstants.RANKING_DIST_1_METHOD, 30), getConfig(plasmaSwitchboardConstants.RANKING_DIST_1_TARGET, "kaskelix.de:8080,yacy.dyndns.org:8000"));// init facility DB/*@@ -1111,7 +528,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.*/// init nameCacheNoCachingList- final String noCachingList = getConfig(HTTPC_NAME_CACHE_CACHING_PATTERNS_NO,"");+ final String noCachingList = getConfig(plasmaSwitchboardConstants.HTTPC_NAME_CACHE_CACHING_PATTERNS_NO,"");final String[] noCachingEntries = noCachingList.split(",");for (int i = 0; i < noCachingEntries.length; i++) {final String entry = noCachingEntries[i].trim();@@ -1122,7 +539,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.log.logConfig("Initializing Snippet Cache");plasmaSnippetCache.init(parser, log);- final String wikiParserClassName = getConfig(WIKIPARSER_CLASS, WIKIPARSER_CLASS_DEFAULT);+ final String wikiParserClassName = getConfig(plasmaSwitchboardConstants.WIKIPARSER_CLASS, plasmaSwitchboardConstants.WIKIPARSER_CLASS_DEFAULT);this.log.logConfig("Loading wiki parser " + wikiParserClassName + " ...");try {final Class<?> wikiParserClass = Class.forName(wikiParserClassName);@@ -1138,13 +555,13 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.this.observer.resourceObserverJob();// initializing the stackCrawlThread- this.crawlStacker = new CrawlStacker(this, this.plasmaPath, (int) getConfigLong("tableTypeForPreNURL", 0), (((int) getConfigLong("tableTypeForPreNURL", 0) == 0) && (getConfigLong(CRAWLSTACK_BUSYSLEEP, 0) <= 100)));+ this.crawlStacker = new CrawlStacker(this, this.plasmaPath, (int) getConfigLong("tableTypeForPreNURL", 0), (((int) getConfigLong("tableTypeForPreNURL", 0) == 0) && (getConfigLong(plasmaSwitchboardConstants.CRAWLSTACK_BUSYSLEEP, 0) <= 100)));//this.sbStackCrawlThread = new plasmaStackCrawlThread(this,this.plasmaPath,ramPreNURL);//this.sbStackCrawlThread.start();// initializing dht chunk generationthis.dhtTransferChunk = null;- this.dhtTransferIndexCount = (int) getConfigLong(INDEX_DIST_CHUNK_SIZE_START, 50);+ this.dhtTransferIndexCount = (int) getConfigLong(plasmaSwitchboardConstants.INDEX_DIST_CHUNK_SIZE_START, 50);// init robinson cluster// before we do that, we wait some time until the seed list is loaded.@@ -1165,30 +582,30 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.moreMemory = new Timer(); // init GC Thread - thqmoreMemory.schedule(new MoreMemory(), 300000, 600000);- deployThread(CLEANUP, "Cleanup", "simple cleaning process for monitoring information", null,- new serverInstantBusyThread(this, CLEANUP_METHOD_START, CLEANUP_METHOD_JOBCOUNT, CLEANUP_METHOD_FREEMEM), 600000); // all 5 Minutes, wait 10 minutes until first run- deployThread(CRAWLSTACK, "Crawl URL Stacker", "process that checks url for double-occurrences and for allowance/disallowance by robots.txt", null,- new serverInstantBusyThread(crawlStacker, CRAWLSTACK_METHOD_START, CRAWLSTACK_METHOD_JOBCOUNT, CRAWLSTACK_METHOD_FREEMEM), 8000);- deployThread(INDEXER, "Indexing", "thread that either initiates a parsing/indexing queue, distributes the index into the DHT, stores parsed documents or flushes the index cache", "/IndexCreateIndexingQueue_p.html",- new serverInstantBusyThread(this, INDEXER_METHOD_START, INDEXER_METHOD_JOBCOUNT, INDEXER_METHOD_FREEMEM), 10000);- deployThread(PROXY_CACHE_ENQUEUE, "Proxy Cache Enqueue", "job takes new input files from RAM stack, stores them, and hands over to the Indexing Stack", null,- new serverInstantBusyThread(this, PROXY_CACHE_ENQUEUE_METHOD_START, PROXY_CACHE_ENQUEUE_METHOD_JOBCOUNT, PROXY_CACHE_ENQUEUE_METHOD_FREEMEM), 10000);- deployThread(CRAWLJOB_REMOTE_TRIGGERED_CRAWL, "Remote Crawl Job", "thread that performes a single crawl/indexing step triggered by a remote peer", null,- new serverInstantBusyThread(crawlQueues, CRAWLJOB_REMOTE_TRIGGERED_CRAWL_METHOD_START, CRAWLJOB_REMOTE_TRIGGERED_CRAWL_METHOD_JOBCOUNT, CRAWLJOB_REMOTE_TRIGGERED_CRAWL_METHOD_FREEMEM), 30000);- deployThread(CRAWLJOB_REMOTE_CRAWL_LOADER, "Remote Crawl URL Loader", "thread that loads remote crawl lists from other peers", "",- new serverInstantBusyThread(crawlQueues, CRAWLJOB_REMOTE_CRAWL_LOADER_METHOD_START, CRAWLJOB_REMOTE_CRAWL_LOADER_METHOD_JOBCOUNT, CRAWLJOB_REMOTE_CRAWL_LOADER_METHOD_FREEMEM), 30000); // error here?- deployThread(CRAWLJOB_LOCAL_CRAWL, "Local Crawl", "thread that performes a single crawl step from the local crawl queue", "/IndexCreateWWWLocalQueue_p.html",- new serverInstantBusyThread(crawlQueues, CRAWLJOB_LOCAL_CRAWL_METHOD_START, CRAWLJOB_LOCAL_CRAWL_METHOD_JOBCOUNT, CRAWLJOB_LOCAL_CRAWL_METHOD_FREEMEM), 10000);- deployThread(SEED_UPLOAD, "Seed-List Upload", "task that a principal peer performes to generate and upload a seed-list to a ftp account", null,- new serverInstantBusyThread(yc, SEED_UPLOAD_METHOD_START, SEED_UPLOAD_METHOD_JOBCOUNT, SEED_UPLOAD_METHOD_FREEMEM), 180000);- deployThread(PEER_PING, "YaCy Core", "this is the p2p-control and peer-ping task", null,- new serverInstantBusyThread(yc, PEER_PING_METHOD_START, PEER_PING_METHOD_JOBCOUNT, PEER_PING_METHOD_FREEMEM), 2000);-- deployThread(INDEX_DIST, "DHT Distribution", "selection, transfer and deletion of index entries that are not searched on your peer, but on others", null,- new serverInstantBusyThread(this, INDEX_DIST_METHOD_START, INDEX_DIST_METHOD_JOBCOUNT, INDEX_DIST_METHOD_FREEMEM), 60000,- Long.parseLong(getConfig(INDEX_DIST_IDLESLEEP , "5000")),- Long.parseLong(getConfig(INDEX_DIST_BUSYSLEEP , "0")),- Long.parseLong(getConfig(INDEX_DIST_MEMPREREQ , "1000000")));+ deployThread(plasmaSwitchboardConstants.CLEANUP, "Cleanup", "simple cleaning process for monitoring information", null,+ new serverInstantBusyThread(this, plasmaSwitchboardConstants.CLEANUP_METHOD_START, plasmaSwitchboardConstants.CLEANUP_METHOD_JOBCOUNT, plasmaSwitchboardConstants.CLEANUP_METHOD_FREEMEM), 600000); // all 5 Minutes, wait 10 minutes until first run+ deployThread(plasmaSwitchboardConstants.CRAWLSTACK, "Crawl URL Stacker", "process that checks url for double-occurrences and for allowance/disallowance by robots.txt", null,+ new serverInstantBusyThread(crawlStacker, plasmaSwitchboardConstants.CRAWLSTACK_METHOD_START, plasmaSwitchboardConstants.CRAWLSTACK_METHOD_JOBCOUNT, plasmaSwitchboardConstants.CRAWLSTACK_METHOD_FREEMEM), 8000);+ deployThread(plasmaSwitchboardConstants.INDEXER, "Indexing", "thread that either initiates a parsing/indexing queue, distributes the index into the DHT, stores parsed documents or flushes the index cache", "/IndexCreateIndexingQueue_p.html",+ new serverInstantBusyThread(this, plasmaSwitchboardConstants.INDEXER_METHOD_START, plasmaSwitchboardConstants.INDEXER_METHOD_JOBCOUNT, plasmaSwitchboardConstants.INDEXER_METHOD_FREEMEM), 10000);+ deployThread(plasmaSwitchboardConstants.PROXY_CACHE_ENQUEUE, "Proxy Cache Enqueue", "job takes new input files from RAM stack, stores them, and hands over to the Indexing Stack", null,+ new serverInstantBusyThread(this, plasmaSwitchboardConstants.PROXY_CACHE_ENQUEUE_METHOD_START, plasmaSwitchboardConstants.PROXY_CACHE_ENQUEUE_METHOD_JOBCOUNT, plasmaSwitchboardConstants.PROXY_CACHE_ENQUEUE_METHOD_FREEMEM), 10000);+ deployThread(plasmaSwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL, "Remote Crawl Job", "thread that performes a single crawl/indexing step triggered by a remote peer", null,+ new serverInstantBusyThread(crawlQueues, plasmaSwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL_METHOD_START, plasmaSwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL_METHOD_JOBCOUNT, plasmaSwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL_METHOD_FREEMEM), 30000);+ deployThread(plasmaSwitchboardConstants.CRAWLJOB_REMOTE_CRAWL_LOADER, "Remote Crawl URL Loader", "thread that loads remote crawl lists from other peers", "",+ new serverInstantBusyThread(crawlQueues, plasmaSwitchboardConstants.CRAWLJOB_REMOTE_CRAWL_LOADER_METHOD_START, plasmaSwitchboardConstants.CRAWLJOB_REMOTE_CRAWL_LOADER_METHOD_JOBCOUNT, plasmaSwitchboardConstants.CRAWLJOB_REMOTE_CRAWL_LOADER_METHOD_FREEMEM), 30000); // error here?+ deployThread(plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL, "Local Crawl", "thread that performes a single crawl step from the local crawl queue", "/IndexCreateWWWLocalQueue_p.html",+ new serverInstantBusyThread(crawlQueues, plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL_METHOD_START, plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL_METHOD_JOBCOUNT, plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL_METHOD_FREEMEM), 10000);+ deployThread(plasmaSwitchboardConstants.SEED_UPLOAD, "Seed-List Upload", "task that a principal peer performes to generate and upload a seed-list to a ftp account", null,+ new serverInstantBusyThread(yc, plasmaSwitchboardConstants.SEED_UPLOAD_METHOD_START, plasmaSwitchboardConstants.SEED_UPLOAD_METHOD_JOBCOUNT, plasmaSwitchboardConstants.SEED_UPLOAD_METHOD_FREEMEM), 180000);+ deployThread(plasmaSwitchboardConstants.PEER_PING, "YaCy Core", "this is the p2p-control and peer-ping task", null,+ new serverInstantBusyThread(yc, plasmaSwitchboardConstants.PEER_PING_METHOD_START, plasmaSwitchboardConstants.PEER_PING_METHOD_JOBCOUNT, plasmaSwitchboardConstants.PEER_PING_METHOD_FREEMEM), 2000);++ deployThread(plasmaSwitchboardConstants.INDEX_DIST, "DHT Distribution", "selection, transfer and deletion of index entries that are not searched on your peer, but on others", null,+ new serverInstantBusyThread(this, plasmaSwitchboardConstants.INDEX_DIST_METHOD_START, plasmaSwitchboardConstants.INDEX_DIST_METHOD_JOBCOUNT, plasmaSwitchboardConstants.INDEX_DIST_METHOD_FREEMEM), 60000,+ Long.parseLong(getConfig(plasmaSwitchboardConstants.INDEX_DIST_IDLESLEEP , "5000")),+ Long.parseLong(getConfig(plasmaSwitchboardConstants.INDEX_DIST_BUSYSLEEP , "0")),+ Long.parseLong(getConfig(plasmaSwitchboardConstants.INDEX_DIST_MEMPREREQ , "1000000")));// test routine for snippet fetch//Set query = new HashSet();@@ -1202,6 +619,24 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.log.logConfig("Finished Switchboard Initialization");}+++ /**+ *+ */+ private void initSystemTray() {+ // make system tray+ // TODO: make tray on linux+ try {+ final boolean trayIcon = getConfig("trayIcon", "false").equals("true");+ if (trayIcon && serverSystem.isWindows) {+ System.setProperty("java.awt.headless", "false");+ yacytray = new yacyTray(this, false);+ }+ } catch (final Exception e) {+ System.setProperty("java.awt.headless", "true");+ }+ }public static void overwriteNetworkDefinition(final plasmaSwitchboard sb) {@@ -1278,10 +713,10 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.public void switchNetwork(final String networkDefinition) {// pause crawls- final boolean lcp = crawlJobIsPaused(CRAWLJOB_LOCAL_CRAWL);- if (!lcp) pauseCrawlJob(CRAWLJOB_LOCAL_CRAWL);- final boolean rcp = crawlJobIsPaused(CRAWLJOB_REMOTE_TRIGGERED_CRAWL);- if (!rcp) pauseCrawlJob(CRAWLJOB_REMOTE_TRIGGERED_CRAWL);+ final boolean lcp = crawlJobIsPaused(plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL);+ if (!lcp) pauseCrawlJob(plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL);+ final boolean rcp = crawlJobIsPaused(plasmaSwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);+ if (!rcp) pauseCrawlJob(plasmaSwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);// trigger online cautionproxyLastAccess = System.currentTimeMillis() + 10000; // at least 10 seconds online caution to prevent unnecessary action on database meanwhile// clean search events which have cached relations to the old index@@ -1291,14 +726,14 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.this.webIndex.close();setConfig("network.unit.definition", networkDefinition);overwriteNetworkDefinition(this);- final File indexPrimaryPath = getConfigPath(INDEX_PRIMARY_PATH, INDEX_PATH_DEFAULT);- final File indexSecondaryPath = (getConfig(INDEX_SECONDARY_PATH, "").length() == 0) ? indexPrimaryPath : new File(getConfig(INDEX_SECONDARY_PATH, ""));- final int wordCacheMaxCount = (int) getConfigLong(WORDCACHE_MAX_COUNT, 20000);+ final File indexPrimaryPath = getConfigPath(plasmaSwitchboardConstants.INDEX_PRIMARY_PATH, plasmaSwitchboardConstants.INDEX_PATH_DEFAULT);+ final File indexSecondaryPath = (getConfig(plasmaSwitchboardConstants.INDEX_SECONDARY_PATH, "").length() == 0) ? indexPrimaryPath : new File(getConfig(plasmaSwitchboardConstants.INDEX_SECONDARY_PATH, ""));+ final int wordCacheMaxCount = (int) getConfigLong(plasmaSwitchboardConstants.WORDCACHE_MAX_COUNT, 20000);this.webIndex = new plasmaWordIndex(getConfig("network.unit.name", ""), getLog(), indexPrimaryPath, indexSecondaryPath, wordCacheMaxCount);}// start up crawl jobs- continueCrawlJob(CRAWLJOB_LOCAL_CRAWL);- continueCrawlJob(CRAWLJOB_REMOTE_TRIGGERED_CRAWL);+ continueCrawlJob(plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL);+ continueCrawlJob(plasmaSwitchboardConstants.CRAWLJOB_REMOTE_TRIGGERED_CRAWL);this.log.logInfo("switched network to " + networkDefinition);// check status of account configuration: when local url crawling is allowed, it is not allowed// that an automatic authorization of localhost is done, because in this case crawls from local@@ -1318,7 +753,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.public void initMessages() {this.log.logConfig("Starting Message Board");- final File messageDbFile = new File(workPath, DBFILE_MESSAGE);+ final File messageDbFile = new File(workPath, plasmaSwitchboardConstants.DBFILE_MESSAGE);this.messageDB = new messageBoard(messageDbFile);this.log.logConfig("Loaded Message Board DB from file " + messageDbFile.getName() +", " + this.messageDB.size() + " entries" +@@ -1327,8 +762,8 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.public void initWiki() {this.log.logConfig("Starting Wiki Board");- final File wikiDbFile = new File(workPath, DBFILE_WIKI);- this.wikiDB = new wikiBoard(wikiDbFile, new File(workPath, DBFILE_WIKI_BKP));+ final File wikiDbFile = new File(workPath, plasmaSwitchboardConstants.DBFILE_WIKI);+ this.wikiDB = new wikiBoard(wikiDbFile, new File(workPath, plasmaSwitchboardConstants.DBFILE_WIKI_BKP));this.log.logConfig("Loaded Wiki Board DB from file " + wikiDbFile.getName() +", " + this.wikiDB.size() + " entries" +", " + ppRamString(wikiDbFile.length()/1024));@@ -1336,13 +771,13 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.public void initBlog() {this.log.logConfig("Starting Blog");- final File blogDbFile = new File(workPath, DBFILE_BLOG);+ final File blogDbFile = new File(workPath, plasmaSwitchboardConstants.DBFILE_BLOG);this.blogDB = new blogBoard(blogDbFile);this.log.logConfig("Loaded Blog DB from file " + blogDbFile.getName() +", " + this.blogDB.size() + " entries" +", " + ppRamString(blogDbFile.length()/1024));- final File blogCommentDbFile = new File(workPath, DBFILE_BLOGCOMMENTS);+ final File blogCommentDbFile = new File(workPath, plasmaSwitchboardConstants.DBFILE_BLOGCOMMENTS);this.blogCommentDB = new blogBoardComments(blogCommentDbFile);this.log.logConfig("Loaded Blog-Comment DB from file " + blogCommentDbFile.getName() +", " + this.blogCommentDB.size() + " entries" +@@ -1351,9 +786,9 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.public void initBookmarks(){this.log.logConfig("Loading Bookmarks DB");- final File bookmarksFile = new File(workPath, DBFILE_BOOKMARKS);- final File tagsFile = new File(workPath, DBFILE_BOOKMARKS_TAGS);- final File datesFile = new File(workPath, DBFILE_BOOKMARKS_DATES);+ final File bookmarksFile = new File(workPath, plasmaSwitchboardConstants.DBFILE_BOOKMARKS);+ final File tagsFile = new File(workPath, plasmaSwitchboardConstants.DBFILE_BOOKMARKS_TAGS);+ final File datesFile = new File(workPath, plasmaSwitchboardConstants.DBFILE_BOOKMARKS_DATES);this.bookmarksDB = new bookmarksDB(bookmarksFile, tagsFile, datesFile);this.log.logConfig("Loaded Bookmarks DB from files "+ bookmarksFile.getName()+ ", "+tagsFile.getName());this.log.logConfig(this.bookmarksDB.tagsSize()+" Tag, "+this.bookmarksDB.bookmarksSize()+" Bookmarks");@@ -1367,14 +802,14 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.// we are in robinson mode, if we do not exchange index by dht distribution// we need to take care that search requests and remote indexing requests go only// to the peers in the same cluster, if we run a robinson cluster.- return !getConfigBool(plasmaSwitchboard.INDEX_DIST_ALLOW, false) && !getConfigBool(plasmaSwitchboard.INDEX_RECEIVE_ALLOW, false);+ return !getConfigBool(plasmaSwitchboardConstants.INDEX_DIST_ALLOW, false) && !getConfigBool(plasmaSwitchboardConstants.INDEX_RECEIVE_ALLOW, false);}public boolean isPublicRobinson() {// robinson peers may be member of robinson clusters, which can be public or private// this does not check the robinson attribute, only the specific subtype of the cluster- final String clustermode = getConfig(CLUSTER_MODE, CLUSTER_MODE_PUBLIC_PEER);- return (clustermode.equals(CLUSTER_MODE_PUBLIC_CLUSTER)) || (clustermode.equals(CLUSTER_MODE_PUBLIC_PEER));+ final String clustermode = getConfig(plasmaSwitchboardConstants.CLUSTER_MODE, plasmaSwitchboardConstants.CLUSTER_MODE_PUBLIC_PEER);+ return (clustermode.equals(plasmaSwitchboardConstants.CLUSTER_MODE_PUBLIC_CLUSTER)) || (clustermode.equals(plasmaSwitchboardConstants.CLUSTER_MODE_PUBLIC_PEER));}public boolean isInMyCluster(final String peer) {@@ -1384,12 +819,12 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.// if this robinson mode does not define a cluster membership, false is returnedif (peer == null) return false;if (!isRobinsonMode()) return false;- final String clustermode = getConfig(CLUSTER_MODE, CLUSTER_MODE_PUBLIC_PEER);- if (clustermode.equals(CLUSTER_MODE_PRIVATE_CLUSTER)) {+ final String clustermode = getConfig(plasmaSwitchboardConstants.CLUSTER_MODE, plasmaSwitchboardConstants.CLUSTER_MODE_PUBLIC_PEER);+ if (clustermode.equals(plasmaSwitchboardConstants.CLUSTER_MODE_PRIVATE_CLUSTER)) {// check if we got the request from a peer in the private cluster- final String network = getConfig(CLUSTER_PEERS_IPPORT, "");+ final String network = getConfig(plasmaSwitchboardConstants.CLUSTER_PEERS_IPPORT, "");return network.indexOf(peer) >= 0;- } else if (clustermode.equals(CLUSTER_MODE_PUBLIC_CLUSTER)) {+ } else if (clustermode.equals(plasmaSwitchboardConstants.CLUSTER_MODE_PUBLIC_CLUSTER)) {// check if we got the request from a peer in the public clusterreturn this.clusterhashes.containsKey(peer);} else {@@ -1402,12 +837,12 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.// if this robinson mode does not define a cluster membership, false is returnedif (seed == null) return false;if (!isRobinsonMode()) return false;- final String clustermode = getConfig(CLUSTER_MODE, CLUSTER_MODE_PUBLIC_PEER);- if (clustermode.equals(CLUSTER_MODE_PRIVATE_CLUSTER)) {+ final String clustermode = getConfig(plasmaSwitchboardConstants.CLUSTER_MODE, plasmaSwitchboardConstants.CLUSTER_MODE_PUBLIC_PEER);+ if (clustermode.equals(plasmaSwitchboardConstants.CLUSTER_MODE_PRIVATE_CLUSTER)) {// check if we got the request from a peer in the private cluster- final String network = getConfig(CLUSTER_PEERS_IPPORT, "");+ final String network = getConfig(plasmaSwitchboardConstants.CLUSTER_PEERS_IPPORT, "");return network.indexOf(seed.getPublicAddress()) >= 0;- } else if (clustermode.equals(CLUSTER_MODE_PUBLIC_CLUSTER)) {+ } else if (clustermode.equals(plasmaSwitchboardConstants.CLUSTER_MODE_PUBLIC_CLUSTER)) {// check if we got the request from a peer in the public clusterreturn this.clusterhashes.containsKey(seed.hash);} else {@@ -1486,9 +921,9 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.public boolean onlineCaution() {return- (System.currentTimeMillis() - this.proxyLastAccess < Integer.parseInt(getConfig(PROXY_ONLINE_CAUTION_DELAY, "30000"))) ||- (System.currentTimeMillis() - this.localSearchLastAccess < Integer.parseInt(getConfig(LOCALSEACH_ONLINE_CAUTION_DELAY, "30000"))) ||- (System.currentTimeMillis() - this.remoteSearchLastAccess < Integer.parseInt(getConfig(REMOTESEARCH_ONLINE_CAUTION_DELAY, "30000")));+ (System.currentTimeMillis() - this.proxyLastAccess < Integer.parseInt(getConfig(plasmaSwitchboardConstants.PROXY_ONLINE_CAUTION_DELAY, "30000"))) ||+ (System.currentTimeMillis() - this.localSearchLastAccess < Integer.parseInt(getConfig(plasmaSwitchboardConstants.LOCALSEACH_ONLINE_CAUTION_DELAY, "30000"))) ||+ (System.currentTimeMillis() - this.remoteSearchLastAccess < Integer.parseInt(getConfig(plasmaSwitchboardConstants.REMOTESEARCH_ONLINE_CAUTION_DELAY, "30000")));}private static String ppRamString(long bytes) {@@ -1749,7 +1184,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.(this.dhtTransferChunk.getStatus() == plasmaDHTChunk.chunkStatus_FAILED))) {// generate new chunk- final int minChunkSize = (int) getConfigLong(INDEX_DIST_CHUNK_SIZE_MIN, 30);+ final int minChunkSize = (int) getConfigLong(plasmaSwitchboardConstants.INDEX_DIST_CHUNK_SIZE_MIN, 30);dhtTransferChunk = new plasmaDHTChunk(this.log, webIndex, minChunkSize, dhtTransferIndexCount, 5000);doneSomething = true;}@@ -1763,7 +1198,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.return doneSomething; // nothing to do}- if (crawlStacker.size() >= getConfigLong(CRAWLSTACK_SLOTS, 2000)) {+ if (crawlStacker.size() >= getConfigLong(plasmaSwitchboardConstants.CRAWLSTACK_SLOTS, 2000)) {if (this.log.isFine()) log.logFine("deQueue: too many processes in stack crawl thread queue (" + "stackCrawlQueue=" + crawlStacker.size() + ")");return doneSomething;}@@ -2016,8 +1451,8 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.*/public void pauseCrawlJob(final String jobType) {final Object[] status = this.crawlJobsStatus.get(jobType);- synchronized(status[CRAWLJOB_SYNC]) {- status[CRAWLJOB_STATUS] = Boolean.TRUE;+ synchronized(status[plasmaSwitchboardConstants.CRAWLJOB_SYNC]) {+ status[plasmaSwitchboardConstants.CRAWLJOB_STATUS] = Boolean.TRUE;}setConfig(jobType + "_isPaused", "true");}@@ -2028,10 +1463,10 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.*/public void continueCrawlJob(final String jobType) {final Object[] status = this.crawlJobsStatus.get(jobType);- synchronized(status[CRAWLJOB_SYNC]) {- if (((Boolean)status[CRAWLJOB_STATUS]).booleanValue()) {- status[CRAWLJOB_STATUS] = Boolean.FALSE;- status[CRAWLJOB_SYNC].notifyAll();+ synchronized(status[plasmaSwitchboardConstants.CRAWLJOB_SYNC]) {+ if (((Boolean)status[plasmaSwitchboardConstants.CRAWLJOB_STATUS]).booleanValue()) {+ status[plasmaSwitchboardConstants.CRAWLJOB_STATUS] = Boolean.FALSE;+ status[plasmaSwitchboardConstants.CRAWLJOB_SYNC].notifyAll();}}setConfig(jobType + "_isPaused", "false");@@ -2043,8 +1478,8 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.*/public boolean crawlJobIsPaused(final String jobType) {final Object[] status = this.crawlJobsStatus.get(jobType);- synchronized(status[CRAWLJOB_SYNC]) {- return ((Boolean)status[CRAWLJOB_STATUS]).booleanValue();+ synchronized(status[plasmaSwitchboardConstants.CRAWLJOB_SYNC]) {+ return ((Boolean)status[plasmaSwitchboardConstants.CRAWLJOB_STATUS]).booleanValue();}}@@ -2085,7 +1520,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.if (document == null) return null;} catch (final ParserException e) {this.log.logInfo("Unable to parse the resource '" + entry.url() + "'. " + e.getMessage());- addURLtoErrorDB(entry.url(), entry.referrerHash(), entry.initiator(), entry.anchorName(), e.getErrorCode(), new kelondroBitfield());+ addURLtoErrorDB(entry.url(), entry.referrerHash(), entry.initiator(), entry.anchorName(), e.getErrorCode());if (document != null) {document.close();document = null;@@ -2101,7 +1536,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.// put anchors on crawl stackfinal long stackStartTime = System.currentTimeMillis();if (- ((processCase == PROCESSCASE_4_PROXY_LOAD) || (processCase == PROCESSCASE_5_LOCAL_CRAWLING)) &&+ ((processCase == plasmaSwitchboardConstants.PROCESSCASE_4_PROXY_LOAD) || (processCase == plasmaSwitchboardConstants.PROCESSCASE_5_LOCAL_CRAWLING)) &&((entry.profile() == null) || (entry.depth() < entry.profile().generalDepth()))) {final Map<yacyURL, String> hl = document.getHyperlinks();@@ -2156,7 +1591,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.final int processCase = entry.processCase();String noIndexReason = ErrorURL.DENIED_UNSPECIFIED_INDEXING_ERROR;- if (processCase == PROCESSCASE_4_PROXY_LOAD) {+ if (processCase == plasmaSwitchboardConstants.PROCESSCASE_4_PROXY_LOAD) {// proxy-loadnoIndexReason = entry.shallIndexCacheForProxy();} else {@@ -2169,7 +1604,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.checkInterruption();log.logFine("Not indexed any word in URL " + entry.url() + "; cause: " + noIndexReason);- addURLtoErrorDB(entry.url(), (referrerURL == null) ? "" : referrerURL.hash(), entry.initiator(), dc_title, noIndexReason, new kelondroBitfield());+ addURLtoErrorDB(entry.url(), (referrerURL == null) ? "" : referrerURL.hash(), entry.initiator(), dc_title, noIndexReason);/*if ((processCase == PROCESSCASE_6_GLOBAL_CRAWLING) && (initiatorPeer != null)) {if (clusterhashes != null) initiatorPeer.setAlternativeAddress((String) clusterhashes.get(initiatorPeer.hash));@@ -2222,7 +1657,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.newEntry = webIndex.storeDocument(queueEntry, document, condenser);} catch (final IOException e) {if (this.log.isFine()) log.logFine("Not Indexed Resource '" + queueEntry.url().toNormalform(false, true) + "': process case=" + processCase);- addURLtoErrorDB(queueEntry.url(), referrerURL.hash(), queueEntry.initiator(), dc_title, "error storing url: " + e.getMessage(), new kelondroBitfield());+ addURLtoErrorDB(queueEntry.url(), referrerURL.hash(), queueEntry.initiator(), dc_title, "error storing url: " + e.getMessage());return;}@@ -2237,7 +1672,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.// STORE WORD INDEXif ((!queueEntry.profile().indexText()) && (!queueEntry.profile().indexMedia())) {if (this.log.isFine()) log.logFine("Not Indexed Resource '" + queueEntry.url().toNormalform(false, true) + "': process case=" + processCase);- addURLtoErrorDB(queueEntry.url(), referrerURL.hash(), queueEntry.initiator(), dc_title, ErrorURL.DENIED_UNKNOWN_INDEXING_PROCESS_CASE, new kelondroBitfield());+ addURLtoErrorDB(queueEntry.url(), referrerURL.hash(), queueEntry.initiator(), dc_title, ErrorURL.DENIED_UNKNOWN_INDEXING_PROCESS_CASE);return;}@@ -2255,7 +1690,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.// if this was performed for a remote crawl request, notify requesterfinal yacySeed initiatorPeer = queueEntry.initiatorPeer();- if ((processCase == PROCESSCASE_6_GLOBAL_CRAWLING) && (initiatorPeer != null)) {+ if ((processCase == plasmaSwitchboardConstants.PROCESSCASE_6_GLOBAL_CRAWLING) && (initiatorPeer != null)) {log.logInfo("Sending crawl receipt for '" + queueEntry.url().toNormalform(false, true) + "' to " + initiatorPeer.getName());if (clusterhashes != null) initiatorPeer.setAlternativeAddress(clusterhashes.get(initiatorPeer.hash));// start a thread for receipt sending to avoid a blocking here@@ -2278,13 +1713,15 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.private static SimpleDateFormat DateFormatter = new SimpleDateFormat("EEE, dd MMM yyyy");public static String dateString(final Date date) {- if (date == null) return ""; else return DateFormatter.format(date);+ if (date == null) return "";+ return DateFormatter.format(date);}// we need locale independent RFC-822 dates at some placesprivate static SimpleDateFormat DateFormatter822 = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z", Locale.US);public static String dateString822(final Date date) {- if (date == null) return ""; else return DateFormatter822.format(date);+ if (date == null) return "";+ return DateFormatter822.format(date);}@@ -2400,27 +1837,27 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.serverBusyThread thread;- thread = getThread(INDEX_DIST);+ thread = getThread(plasmaSwitchboardConstants.INDEX_DIST);if (thread != null) {- setConfig(INDEX_DIST_BUSYSLEEP , thread.setBusySleep(Math.max(2000, thread.setBusySleep(newBusySleep * 2))));+ setConfig(plasmaSwitchboardConstants.INDEX_DIST_BUSYSLEEP , thread.setBusySleep(Math.max(2000, thread.setBusySleep(newBusySleep * 2))));thread.setIdleSleep(30000);}- thread = getThread(CRAWLJOB_LOCAL_CRAWL);+ thread = getThread(plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL);if (thread != null) {- setConfig(CRAWLJOB_LOCAL_CRAWL_BUSYSLEEP , thread.setBusySleep(newBusySleep));+ setConfig(plasmaSwitchboardConstants.CRAWLJOB_LOCAL_CRAWL_BUSYSLEEP , thread.setBusySleep(newBusySleep));thread.setIdleSleep(2000);}- thread = getThread(PROXY_CACHE_ENQUEUE);+ thread = getThread(plasmaSwitchboardConstants.PROXY_CACHE_ENQUEUE);if (thread != null) {- setConfig(PROXY_CACHE_ENQUEUE_BUSYSLEEP , thread.setBusySleep(0));+ setConfig(plasmaSwitchboardConstants.PROXY_CACHE_ENQUEUE_BUSYSLEEP , thread.setBusySleep(0));thread.setIdleSleep(2000);}- thread = getThread(INDEXER);+ thread = getThread(plasmaSwitchboardConstants.INDEXER);if (thread != null) {- setConfig(INDEXER_BUSYSLEEP , thread.setBusySleep(newBusySleep / 8));+ setConfig(plasmaSwitchboardConstants.INDEXER_BUSYSLEEP , thread.setBusySleep(newBusySleep / 8));thread.setIdleSleep(2000);}@@ -2437,8 +1874,8 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.public void startTransferWholeIndex(final yacySeed seed, final boolean delete) {if (transferIdxThread == null) {this.transferIdxThread = new plasmaDHTFlush(this.log, this.webIndex, seed, delete,- "true".equalsIgnoreCase(getConfig(INDEX_TRANSFER_GZIP_BODY, "false")),- (int) getConfigLong(INDEX_TRANSFER_TIMEOUT, 60000));+ "true".equalsIgnoreCase(getConfig(plasmaSwitchboardConstants.INDEX_TRANSFER_GZIP_BODY, "false")),+ (int) getConfigLong(plasmaSwitchboardConstants.INDEX_TRANSFER_TIMEOUT, 60000));this.transferIdxThread.start();}}@@ -2477,7 +1914,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.if (!this.getConfigBool("network.unit.dht", true)) {return "no DHT distribution: disabled by network.unit.dht";}- if (getConfig(INDEX_DIST_ALLOW, "false").equalsIgnoreCase("false")) {+ if (getConfig(plasmaSwitchboardConstants.INDEX_DIST_ALLOW, "false").equalsIgnoreCase("false")) {return "no DHT distribution: not enabled (ser setting)";}if (webIndex.countURL() < 10) {@@ -2486,10 +1923,10 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.if (webIndex.size() < 100) {return "no DHT distribution: not enough words - wordIndex.size() = " + webIndex.size();}- if ((getConfig(INDEX_DIST_ALLOW_WHILE_CRAWLING, "false").equalsIgnoreCase("false")) && (crawlQueues.noticeURL.notEmpty())) {+ if ((getConfig(plasmaSwitchboardConstants.INDEX_DIST_ALLOW_WHILE_CRAWLING, "false").equalsIgnoreCase("false")) && (crawlQueues.noticeURL.notEmpty())) {return "no DHT distribution: crawl in progress: noticeURL.stackSize() = " + crawlQueues.noticeURL.size() + ", sbQueue.size() = " + webIndex.queuePreStack.size();}- if ((getConfig(INDEX_DIST_ALLOW_WHILE_INDEXING, "false").equalsIgnoreCase("false")) && (webIndex.queuePreStack.size() > 1)) {+ if ((getConfig(plasmaSwitchboardConstants.INDEX_DIST_ALLOW_WHILE_INDEXING, "false").equalsIgnoreCase("false")) && (webIndex.queuePreStack.size() > 1)) {return "no DHT distribution: indexing in progress: noticeURL.stackSize() = " + crawlQueues.noticeURL.size() + ", sbQueue.size() = " + webIndex.queuePreStack.size();}return null; // this means; yes, please do dht transfer@@ -2518,6 +1955,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.final boolean ok = dhtTransferProcess(dhtTransferChunk, peerCount);+ final boolean success;if (ok) {dhtTransferChunk.setStatus(plasmaDHTChunk.chunkStatus_COMPLETE);if (this.log.isFine()) log.logFine("DHT distribution: transfer COMPLETE");@@ -2527,16 +1965,16 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.} else {if (dhtTransferChunk.indexCount() >= dhtTransferIndexCount) dhtTransferIndexCount++;}- final int minChunkSize = (int) getConfigLong(INDEX_DIST_CHUNK_SIZE_MIN, 30);- final int maxChunkSize = (int) getConfigLong(INDEX_DIST_CHUNK_SIZE_MAX, 3000);+ final int minChunkSize = (int) getConfigLong(plasmaSwitchboardConstants.INDEX_DIST_CHUNK_SIZE_MIN, 30);+ final int maxChunkSize = (int) getConfigLong(plasmaSwitchboardConstants.INDEX_DIST_CHUNK_SIZE_MAX, 3000);if (dhtTransferIndexCount < minChunkSize) dhtTransferIndexCount = minChunkSize;if (dhtTransferIndexCount > maxChunkSize) dhtTransferIndexCount = maxChunkSize;// show success- return true;+ success = true;} else {dhtTransferChunk.incTransferFailedCounter();- final int maxChunkFails = (int) getConfigLong(INDEX_DIST_CHUNK_FAILS_MAX, 1);+ final int maxChunkFails = (int) getConfigLong(plasmaSwitchboardConstants.INDEX_DIST_CHUNK_FAILS_MAX, 1);if (dhtTransferChunk.getTransferFailedCounter() >= maxChunkFails) {//System.out.println("DEBUG: " + dhtTransferChunk.getTransferFailedCounter() + " of " + maxChunkFails + " sendings failed for this chunk, aborting!");dhtTransferChunk.setStatus(plasmaDHTChunk.chunkStatus_FAILED);@@ -2546,8 +1984,9 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.//System.out.println("DEBUG: " + dhtTransferChunk.getTransferFailedCounter() + " of " + maxChunkFails + " sendings failed for this chunk, retrying!");if (this.log.isFine()) log.logFine("DHT distribution: transfer FAILED, sending this chunk again");}- return false;+ success = false;}+ return success;}public boolean dhtTransferProcess(final plasmaDHTChunk dhtChunk, final int peerCount) {@@ -2566,8 +2005,8 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.int hc1 = 0;// getting distribution configuration values- final boolean gzipBody = getConfig(INDEX_DIST_GZIP_BODY, "false").equalsIgnoreCase("true");- final int timeout = (int)getConfigLong(INDEX_DIST_TIMEOUT, 60000);+ final boolean gzipBody = getConfig(plasmaSwitchboardConstants.INDEX_DIST_GZIP_BODY, "false").equalsIgnoreCase("true");+ final int timeout = (int)getConfigLong(plasmaSwitchboardConstants.INDEX_DIST_TIMEOUT, 60000);final int retries = 0;// starting up multiple DHT transfer threads@@ -2630,8 +2069,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.final String referrerHash,final String initiator,final String name,- final String failreason,- final kelondroBitfield flags+ final String failreason) {assert initiator != null;// create a new errorURL DB entrydiff --git a/source/de/anomic/plasma/plasmaSwitchboardConstants.java b/source/de/anomic/plasma/plasmaSwitchboardConstants.javanew file mode 100644index 000000000..b024dab67--- /dev/null+++ b/source/de/anomic/plasma/plasmaSwitchboardConstants.java@@ -0,0 +1,534 @@+// plasmaSwitchboardConstants.java+// (C) 2004-2007 by Michael Peter Christen; [email protected], Frankfurt a. M., Germany+// first published 30.07.2008 on http://yacy.net+//+// This is a part of YaCy, a peer-to-peer based web search engine+//+// $LastChangedDate: 2008-03-14 01:16:04 +0100 (Fr, 14 Mrz 2008) $+// $LastChangedRevision: 4558 $+// $LastChangedBy: orbiter $+//+// LICENSE+//+// This program is free software; you can redistribute it and/or modify+// it under the terms of the GNU General Public License as published by+// the Free Software Foundation; either version 2 of the License, or+// (at your option) any later version.+//+// This program is distributed in the hope that it will be useful,+// but WITHOUT ANY WARRANTY; without even the implied warranty of+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+// GNU General Public License for more details.+//+// You should have received a copy of the GNU General Public License+// along with this program; if not, write to the Free Software+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA++package de.anomic.plasma;++import de.anomic.http.httpdRobotsTxtConfig;++/**+ * @author danielr+ *+ */+public final class plasmaSwitchboardConstants {++ public static final int CRAWLJOB_SYNC = 0;+ public static final int CRAWLJOB_STATUS = 1;+ // 20_dhtdistribution+ /**+ * <p><code>public static final String <strong>INDEX_DIST</strong> = "20_dhtdistribution"</code></p>+ * <p>Name of the DHT distribution thread, which selects index chunks and transfers them to other peers+ * according to the global DHT rules</p>+ */+ public static final String INDEX_DIST = "20_dhtdistribution";+ public static final String INDEX_DIST_METHOD_START = "dhtTransferJob";+ public static final String INDEX_DIST_METHOD_JOBCOUNT = null;+ public static final String INDEX_DIST_METHOD_FREEMEM = null;+ public static final String INDEX_DIST_MEMPREREQ = "20_dhtdistribution_memprereq";+ public static final String INDEX_DIST_IDLESLEEP = "20_dhtdistribution_idlesleep";+ public static final String INDEX_DIST_BUSYSLEEP = "20_dhtdistribution_busysleep";+ // 30_peerping+ /**+ * <p><code>public static final String <strong>PEER_PING</strong> = "30_peerping"</code></p>+ * <p>Name of the Peer Ping thread which publishes the own peer and retrieves information about other peers+ * connected to the YaCy-network</p>+ */+ public static final String PEER_PING = "30_peerping";+ public static final String PEER_PING_METHOD_START = "peerPing";+ public static final String PEER_PING_METHOD_JOBCOUNT = null;+ public static final String PEER_PING_METHOD_FREEMEM = null;+ public static final String PEER_PING_IDLESLEEP = "30_peerping_idlesleep";+ public static final String PEER_PING_BUSYSLEEP = "30_peerping_busysleep";+ // 40_peerseedcycle+ /**+ * <p><code>public static final String <strong>SEED_UPLOAD</strong> = "40_peerseedcycle"</code></p>+ * <p>Name of the seed upload thread, providing the so-called seed-lists needed during bootstrapping</p>+ */+ public static final String SEED_UPLOAD = "40_peerseedcycle";+ public static final String SEED_UPLOAD_METHOD_START = "publishSeedList";+ public static final String SEED_UPLOAD_METHOD_JOBCOUNT = null;+ public static final String SEED_UPLOAD_METHOD_FREEMEM = null;+ public static final String SEED_UPLOAD_IDLESLEEP = "40_peerseedcycle_idlesleep";+ public static final String SEED_UPLOAD_BUSYSLEEP = "40_peerseedcycle_busysleep";+ // 50_localcrawl+ /**+ * <p><code>public static final String <strong>CRAWLJOB_LOCAL_CRAWL</strong> = "50_localcrawl"</code></p>+ * <p>Name of the local crawler thread, popping one entry off the Local Crawl Queue, and passing it to the+ * proxy cache enqueue thread to download and further process it</p>+ *+ * @see plasmaSwitchboard#PROXY_CACHE_ENQUEUE+ */+ public static final String CRAWLJOB_LOCAL_CRAWL = "50_localcrawl";+ public static final String CRAWLJOB_LOCAL_CRAWL_METHOD_START = "coreCrawlJob";+ public static final String CRAWLJOB_LOCAL_CRAWL_METHOD_JOBCOUNT = "coreCrawlJobSize";+ public static final String CRAWLJOB_LOCAL_CRAWL_METHOD_FREEMEM = null;+ public static final String CRAWLJOB_LOCAL_CRAWL_IDLESLEEP = "50_localcrawl_idlesleep";+ public static final String CRAWLJOB_LOCAL_CRAWL_BUSYSLEEP = "50_localcrawl_busysleep";+ // 61_globalcawltrigger+ /**+ * <p><code>public static final String <strong>CRAWLJOB_REMOTE_CRAWL_LOADER</strong> = "60_remotecrawlloader"</code></p>+ * <p>Name of the remote crawl list loading thread</p>+ *+ * @see plasmaSwitchboard#CRAWLJOB_REMOTE_CRAWL_LOADER+ */+ public static final String CRAWLJOB_REMOTE_CRAWL_LOADER = "60_remotecrawlloader";+ public static final String CRAWLJOB_REMOTE_CRAWL_LOADER_METHOD_START = "remoteCrawlLoaderJob";+ public static final String CRAWLJOB_REMOTE_CRAWL_LOADER_METHOD_JOBCOUNT = null;+ public static final String CRAWLJOB_REMOTE_CRAWL_LOADER_METHOD_FREEMEM = null;+ public static final String CRAWLJOB_REMOTE_CRAWL_LOADER_IDLESLEEP = "60_remotecrawlloader_idlesleep";+ public static final String CRAWLJOB_REMOTE_CRAWL_LOADER_BUSYSLEEP = "60_remotecrawlloader_busysleep";+ // 62_remotetriggeredcrawl+ /**+ * <p><code>public static final String <strong>CRAWLJOB_REMOTE_TRIGGERED_CRAWL</strong> = "62_remotetriggeredcrawl"</code></p>+ * <p>Name of the remote triggered crawl thread, responsible for processing a remote crawl received from another peer</p>+ */+ public static final String CRAWLJOB_REMOTE_TRIGGERED_CRAWL = "62_remotetriggeredcrawl";+ public static final String CRAWLJOB_REMOTE_TRIGGERED_CRAWL_METHOD_START = "remoteTriggeredCrawlJob";+ public static final String CRAWLJOB_REMOTE_TRIGGERED_CRAWL_METHOD_JOBCOUNT = "remoteTriggeredCrawlJobSize";+ public static final String CRAWLJOB_REMOTE_TRIGGERED_CRAWL_METHOD_FREEMEM = null;+ public static final String CRAWLJOB_REMOTE_TRIGGERED_CRAWL_IDLESLEEP = "62_remotetriggeredcrawl_idlesleep";+ public static final String CRAWLJOB_REMOTE_TRIGGERED_CRAWL_BUSYSLEEP = "62_remotetriggeredcrawl_busysleep";+ // 70_cachemanager+ /**+ * <p><code>public static final String <strong>PROXY_CACHE_ENQUEUE</strong> = "70_cachemanager"</code></p>+ * <p>Name of the proxy cache enqueue thread which fetches a given website and saves the site itself as well as it's+ * HTTP-headers in the HTCACHE</p>+ *+ * @see plasmaSwitchboard#PROXY_CACHE_PATH+ */+ public static final String PROXY_CACHE_ENQUEUE = "70_cachemanager";+ public static final String PROXY_CACHE_ENQUEUE_METHOD_START = "htEntryStoreJob";+ public static final String PROXY_CACHE_ENQUEUE_METHOD_JOBCOUNT = "htEntrySize";+ public static final String PROXY_CACHE_ENQUEUE_METHOD_FREEMEM = null;+ public static final String PROXY_CACHE_ENQUEUE_IDLESLEEP = "70_cachemanager_idlesleep";+ public static final String PROXY_CACHE_ENQUEUE_BUSYSLEEP = "70_cachemanager_busysleep";+ // 74_parsing+ /**+ * <p><code>public static final String <strong>INDEXER</strong> = "80_indexing"</code></p>+ * <p>Name of the indexer thread, performing the actual indexing of a website</p>+ */+ public static final String PARSER = "74_indexing";+ public static final String PARSER_MEMPREREQ = "74_indexing_memprereq";+ public static final String PARSER_IDLESLEEP = "74_indexing_idlesleep";+ public static final String PARSER_BUSYSLEEP = "74_indexing_busysleep";+ public static final String PARSER_METHOD_START = "deQueueProcess";+ public static final String PARSER_METHOD_JOBCOUNT = "queueSize";+ public static final String PARSER_METHOD_FREEMEM = "deQueueFreeMem";+ // 80_indexing+ /**+ * <p><code>public static final String <strong>INDEXER</strong> = "80_indexing"</code></p>+ * <p>Name of the indexer thread, performing the actual indexing of a website</p>+ */+ public static final String INDEXER = "80_indexing";+ public static final String INDEXER_MEMPREREQ = "80_indexing_memprereq";+ public static final String INDEXER_IDLESLEEP = "80_indexing_idlesleep";+ public static final String INDEXER_BUSYSLEEP = "80_indexing_busysleep";+ public static final String INDEXER_METHOD_START = "deQueueProcess";+ public static final String INDEXER_METHOD_JOBCOUNT = "queueSize";+ public static final String INDEXER_METHOD_FREEMEM = "deQueueFreeMem";+ public static final String INDEXER_SLOTS = "indexer.slots";+ // 82_crawlstack+ /**+ * <p><code>public static final String <strong>CRAWLSTACK</strong> = "82_crawlstack"</code></p>+ * <p>Name of the crawl stacker thread, performing several checks on new URLs to crawl, i.e. double-check</p>+ */+ public static final String CRAWLSTACK = "82_crawlstack";+ public static final String CRAWLSTACK_METHOD_START = "job";+ public static final String CRAWLSTACK_METHOD_JOBCOUNT = "size";+ public static final String CRAWLSTACK_METHOD_FREEMEM = null;+ public static final String CRAWLSTACK_IDLESLEEP = "82_crawlstack_idlesleep";+ public static final String CRAWLSTACK_BUSYSLEEP = "82_crawlstack_busysleep";+ public static final String CRAWLSTACK_SLOTS = "stacker.slots";+ // 90_cleanup+ /**+ * <p><code>public static final String <strong>CLEANUP</strong> = "90_cleanup"</code></p>+ * <p>The cleanup thread which is responsible for pendant cleanup-jobs, news/ranking distribution, etc.</p>+ */+ public static final String CLEANUP = "90_cleanup";+ public static final String CLEANUP_METHOD_START = "cleanupJob";+ public static final String CLEANUP_METHOD_JOBCOUNT = "cleanupJobSize";+ public static final String CLEANUP_METHOD_FREEMEM = null;+ public static final String CLEANUP_IDLESLEEP = "90_cleanup_idlesleep";+ public static final String CLEANUP_BUSYSLEEP = "90_cleanup_busysleep";+ /**+ * <p><code>public static final String <strong>RAM_CACHE_LURL</strong> = "ramCacheLURL"</code></p>+ * <p>Name of the setting how much memory in bytes should be assigned to the Loaded URLs DB for caching purposes</p>+ */+ public static final String RAM_CACHE_LURL_TIME = "ramCacheLURL_time";+ /**+ * <p><code>public static final String <strong>RAM_CACHE_NURL</strong> = "ramCacheNURL"</code></p>+ * <p>Name of the setting how much memory in bytes should be assigned to the Noticed URLs DB for caching purposes</p>+ */+ public static final String RAM_CACHE_NURL_TIME = "ramCacheNURL_time";+ /**+ * <p><code>public static final String <strong>RAM_CACHE_EURL</strong> = "ramCacheEURL"</code></p>+ * <p>Name of the setting how much memory in bytes should be assigned to the Erroneous URLs DB for caching purposes</p>+ */+ public static final String RAM_CACHE_EURL_TIME = "ramCacheEURL_time";+ /**+ * <p><code>public static final String <strong>RAM_CACHE_RWI</strong> = "ramCacheRWI"</code></p>+ * <p>Name of the setting how much memory in bytes should be assigned to the RWIs DB for caching purposes</p>+ */+ public static final String RAM_CACHE_RWI_TIME = "ramCacheRWI_time";+ /**+ * <p><code>public static final String <strong>RAM_CACHE_HTTP</strong> = "ramCacheHTTP"</code></p>+ * <p>Name of the setting how much memory in bytes should be assigned to the HTTP Headers DB for caching purposes</p>+ */+ public static final String RAM_CACHE_HTTP_TIME = "ramCacheHTTP_time";+ /**+ * <p><code>public static final String <strong>RAM_CACHE_MESSAGE</strong> = "ramCacheMessage"</code></p>+ * <p>Name of the setting how much memory in bytes should be assigned to the Message DB for caching purposes</p>+ */+ public static final String RAM_CACHE_MESSAGE_TIME = "ramCacheMessage_time";+ /**+ * <p><code>public static final String <strong>RAM_CACHE_ROBOTS</strong> = "ramCacheRobots"</code></p>+ * <p>Name of the setting how much memory in bytes should be assigned to the robots.txts DB for caching purposes</p>+ */+ public static final String RAM_CACHE_ROBOTS_TIME = "ramCacheRobots_time";+ /**+ * <p><code>public static final String <strong>RAM_CACHE_PROFILES</strong> = "ramCacheProfiles"</code></p>+ * <p>Name of the setting how much memory in bytes should be assigned to the Crawl Profiles DB for caching purposes</p>+ */+ public static final String RAM_CACHE_PROFILES_TIME = "ramCacheProfiles_time";+ /**+ * <p><code>public static final String <strong>RAM_CACHE_PRE_NURL</strong> = "ramCachePreNURL"</code></p>+ * <p>Name of the setting how much memory in bytes should be assigned to the Pre-Noticed URLs DB for caching purposes</p>+ */+ public static final String RAM_CACHE_PRE_NURL_TIME = "ramCachePreNURL_time";+ /**+ * <p><code>public static final String <strong>RAM_CACHE_WIKI</strong> = "ramCacheWiki"</code></p>+ * <p>Name of the setting how much memory in bytes should be assigned to the Wiki DB for caching purposes</p>+ */+ public static final String RAM_CACHE_WIKI_TIME = "ramCacheWiki_time";+ /**+ * <p><code>public static final String <strong>RAM_CACHE_BLOG</strong> = "ramCacheBlog"</code></p>+ * <p>Name of the setting how much memory in bytes should be assigned to the Blog DB for caching purposes</p>+ */+ public static final String RAM_CACHE_BLOG_TIME = "ramCacheBlog_time";+ /**+ * <p><code>public static final String <strong>INDEX_DIST_DHT_RECEIPT_LIMIT</strong> = "indexDistribution.dhtReceiptLimit"</code></p>+ * <p>Name of the setting how many words the DHT-In cache may contain maximal before new DHT receipts+ * will be rejected</p>+ */+ public static final String INDEX_DIST_DHT_RECEIPT_LIMIT = "indexDistribution.dhtReceiptLimit";+ /**+ * <p><code>public static final String <strong>INDEX_DIST_CHUNK_SIZE_START</strong> = "indexDistribution.startChunkSize"</code></p>+ * <p>Name of the setting specifying how many words the very first chunk will contain when the DHT-thread starts</p>+ */+ public static final String INDEX_DIST_CHUNK_SIZE_START = "indexDistribution.startChunkSize";+ /**+ * <p><code>public static final String <strong>INDEX_DIST_CHUNK_SIZE_MIN</strong> = "indexDistribution.minChunkSize"</code></p>+ * <p>Name of the setting specifying how many words the smallest chunk may contain</p>+ */+ public static final String INDEX_DIST_CHUNK_SIZE_MIN = "indexDistribution.minChunkSize";+ /**+ * <p><code>public static final String <strong>INDEX_DIST_CHUNK_SIZE_MAX</strong> = "indexDistribution.maxChunkSize"</code></p>+ * <p>Name of the setting specifying how many words the hugest chunk may contain</p>+ */+ public static final String INDEX_DIST_CHUNK_SIZE_MAX = "indexDistribution.maxChunkSize";+ public static final String INDEX_DIST_CHUNK_FAILS_MAX = "indexDistribution.maxChunkFails";+ /**+ * <p><code>public static final String <strong>INDEX_DIST_TIMEOUT</strong> = "indexDistribution.timeout"</code></p>+ * <p>Name of the setting how long the timeout for an Index Distribution shall be in milliseconds</p>+ */+ public static final String INDEX_DIST_TIMEOUT = "indexDistribution.timeout";+ /**+ * <p><code>public static final String <strong>INDEX_DIST_GZIP_BODY</strong> = "indexDistribution.gzipBody"</code></p>+ * <p>Name of the setting whether DHT chunks shall be transferred gzip-encodedly</p>+ */+ public static final String INDEX_DIST_GZIP_BODY = "indexDistribution.gzipBody";+ /**+ * <p><code>public static final String <strong>INDEX_DIST_ALLOW</strong> = "allowDistributeIndex"</code></p>+ * <p>Name of the setting whether Index Distribution shall be allowed (and the DHT-thread therefore started) or not</p>+ *+ * @see plasmaSwitchboard#INDEX_DIST_ALLOW_WHILE_CRAWLING+ */+ public static final String INDEX_DIST_ALLOW = "allowDistributeIndex";+ public static final String INDEX_RECEIVE_ALLOW = "allowReceiveIndex";+ /**+ * <p><code>public static final String <strong>INDEX_DIST_ALLOW_WHILE_CRAWLING</strong> = "allowDistributeIndexWhileCrawling"</code></p>+ * <p>Name of the setting whether Index Distribution shall be allowed while crawling is in progress, i.e.+ * the Local Crawler Queue is filled.</p>+ * <p>This setting only has effect if {@link #INDEX_DIST_ALLOW} is enabled</p>+ *+ * @see plasmaSwitchboard#INDEX_DIST_ALLOW+ */+ public static final String INDEX_DIST_ALLOW_WHILE_CRAWLING = "allowDistributeIndexWhileCrawling";+ public static final String INDEX_DIST_ALLOW_WHILE_INDEXING = "allowDistributeIndexWhileIndexing";+ public static final String INDEX_TRANSFER_TIMEOUT = "indexTransfer.timeout";+ public static final String INDEX_TRANSFER_GZIP_BODY = "indexTransfer.gzipBody";+ public static final String RANKING_DIST_ON = "CRDistOn";+ public static final String RANKING_DIST_0_PATH = "CRDist0Path";+ public static final String RANKING_DIST_0_METHOD = "CRDist0Method";+ public static final String RANKING_DIST_0_PERCENT = "CRDist0Percent";+ public static final String RANKING_DIST_0_TARGET = "CRDist0Target";+ public static final String RANKING_DIST_1_PATH = "CRDist1Path";+ public static final String RANKING_DIST_1_METHOD = "CRDist1Method";+ public static final String RANKING_DIST_1_PERCENT = "CRDist1Percent";+ public static final String RANKING_DIST_1_TARGET = "CRDist1Target";+ public static final String PARSER_MIMETYPES_HTML = "parseableMimeTypes.HTML";+ public static final String PARSER_MIMETYPES_PROXY = "parseableMimeTypes.PROXY";+ public static final String PARSER_MIMETYPES_CRAWLER = "parseableMimeTypes.CRAWLER";+ public static final String PARSER_MIMETYPES_ICAP = "parseableMimeTypes.ICAP";+ public static final String PARSER_MIMETYPES_URLREDIRECTOR = "parseableMimeTypes.URLREDIRECTOR";+ public static final String PARSER_MIMETYPES_IMAGE = "parseableMimeTypes.IMAGE";+ public static final String PARSER_MEDIA_EXT = "mediaExt";+ public static final String PARSER_MEDIA_EXT_PARSEABLE = "parseableExt";+ /**+ * <p><code>public static final String <strong>PROXY_ONLINE_CAUTION_DELAY</strong> = "onlineCautionDelay"</code></p>+ * <p>Name of the setting how long indexing should pause after the last time the proxy was used in milliseconds</p>+ */+ public static final String PROXY_ONLINE_CAUTION_DELAY = "crawlPause.proxy";+ public static final String LOCALSEACH_ONLINE_CAUTION_DELAY = "crawlPause.localsearch";+ public static final String REMOTESEARCH_ONLINE_CAUTION_DELAY = "crawlPause.remotesearch";+ /**+ * <p><code>public static final String <strong>PROXY_PREFETCH_DEPTH</strong> = "proxyPrefetchDepth"</code></p>+ * <p>Name of the setting how deep URLs fetched by proxy usage shall be followed</p>+ */+ public static final String PROXY_PREFETCH_DEPTH = "proxyPrefetchDepth";+ public static final String PROXY_CRAWL_ORDER = "proxyCrawlOrder";+ public static final String PROXY_INDEXING_REMOTE = "proxyIndexingRemote";+ public static final String PROXY_INDEXING_LOCAL_TEXT = "proxyIndexingLocalText";+ public static final String PROXY_INDEXING_LOCAL_MEDIA = "proxyIndexingLocalMedia";+ public static final String PROXY_CACHE_SIZE = "proxyCacheSize";+ /**+ * <p><code>public static final String <strong>PROXY_CACHE_LAYOUT</strong> = "proxyCacheLayout"</code></p>+ * <p>Name of the setting which file-/folder-layout the proxy cache shall use. Possible values are {@link #PROXY_CACHE_LAYOUT_TREE}+ * and {@link #PROXY_CACHE_LAYOUT_HASH}</p>+ *+ * @see plasmaSwitchboard#PROXY_CACHE_LAYOUT_TREE+ * @see plasmaSwitchboard#PROXY_CACHE_LAYOUT_HASH+ */++ //////////////////////////////////////////////////////////////////////////////////////////////+ // Cluster settings+ //////////////////////////////////////////////////////////////////////////////////////////////++ public static final String CLUSTER_MODE = "cluster.mode";+ public static final String CLUSTER_MODE_PUBLIC_CLUSTER = "publiccluster";+ public static final String CLUSTER_MODE_PRIVATE_CLUSTER = "privatecluster";+ public static final String CLUSTER_MODE_PUBLIC_PEER = "publicpeer";+ public static final String CLUSTER_PEERS_IPPORT = "cluster.peers.ipport";+ /**+ * <p><code>public static final String <strong>CRAWLER_THREADS_ACTIVE_MAX</strong> = "crawler.MaxActiveThreads"</code></p>+ * <p>Name of the setting how many active crawler-threads may maximal be running on the same time</p>+ */+ public static final String CRAWLER_THREADS_ACTIVE_MAX = "crawler.MaxActiveThreads";+ public static final String YACY_MODE_DEBUG = "yacyDebugMode";+ public static final String WORDCACHE_INIT_COUNT = "wordCacheInitCount";+ /**+ * <p><code>public static final String <strong>WORDCACHE_MAX_COUNT</strong> = "wordCacheMaxCount"</code></p>+ * <p>Name of the setting how many words the word-cache (or DHT-Out cache) shall contain maximal. Indexing pages if the+ * cache has reached this limit will slow down the indexing process by flushing some of it's entries</p>+ */+ public static final String WORDCACHE_MAX_COUNT = "wordCacheMaxCount";+ public static final String HTTPC_NAME_CACHE_CACHING_PATTERNS_NO = "httpc.nameCacheNoCachingPatterns";+ public static final String ROBOTS_TXT = "httpd.robots.txt";+ public static final String ROBOTS_TXT_DEFAULT = httpdRobotsTxtConfig.LOCKED + "," + httpdRobotsTxtConfig.DIRS;+ public static final String WIKIPARSER_CLASS = "wikiParser.class";+ public static final String WIKIPARSER_CLASS_DEFAULT = "de.anomic.data.wikiCode";+ /**+ * <p><code>public static final String <strong>BLACKLIST_CLASS</strong> = "Blacklist.class"</code></p>+ * <p>Name of the setting which Blacklist backend shall be used. Due to different requirements of users, the+ * {@link plasmaURLPattern}-interface has been created to support blacklist engines different from YaCy's default</p>+ * <p>Attention is required when the backend is changed, because different engines may have different syntaxes</p>+ */+ public static final String BLACKLIST_CLASS = "BlackLists.class";+ /**+ * <p><code>public static final String <strong>BLACKLIST_CLASS_DEFAULT</strong> = "de.anomic.plasma.urlPattern.defaultURLPattern"</code></p>+ * <p>Package and name of YaCy's {@link indexDefaultReferenceBlacklist default} blacklist implementation</p>+ *+ * @see indexDefaultReferenceBlacklist for a detailed overview about the syntax of the default implementation+ */+ public static final String BLACKLIST_CLASS_DEFAULT = "de.anomic.index.indexDefaultReferenceBlacklist";+ public static final String LIST_BLUE = "plasmaBlueList";+ public static final String LIST_BLUE_DEFAULT = null;+ public static final String LIST_BADWORDS_DEFAULT = "yacy.badwords";+ public static final String LIST_STOPWORDS_DEFAULT = "yacy.stopwords";+ /**+ * <p><code>public static final String <strong>DBPATH</strong> = "dbPath"</code></p>+ * <p>Name of the setting specifying the folder beginning from the YaCy-installation's top-folder, where all+ * databases containing queues are stored</p>+ */+ public static final String PLASMA_PATH = "dbPath";+ public static final String PLASMA_PATH_DEFAULT = "DATA/PLASMADB";+ /**+ * <p><code>public static final String <strong>HTCACHE_PATH</strong> = "proxyCache"</code></p>+ * <p>Name of the setting specifying the folder beginning from the YaCy-installation's top-folder, where all+ * downloaded webpages and their respective ressources and HTTP-headers are stored. It is the location containing+ * the proxy-cache</p>+ *+ * @see plasmaSwitchboard#PROXY_CACHE_LAYOUT for details on the file-layout in this path+ */+ public static final String HTCACHE_PATH = "proxyCache";+ public static final String HTCACHE_PATH_DEFAULT = "DATA/HTCACHE";+ public static final String RELEASE_PATH = "releases";+ public static final String RELEASE_PATH_DEFAULT = "DATA/RELEASE";+ /**+ * <p><code>public static final String <strong>HTDOCS_PATH</strong> = "htDocsPath"</code></p>+ * <p>Name of the setting specifying the folder beginning from the YaCy-installation's top-folder, where all+ * user-ressources (i.e. for the fileshare or the contents displayed on <code>www.peername.yacy</code>) lie.+ * The translated templates of the webinterface will also be put in here</p>+ */+ public static final String HTDOCS_PATH = "htDocsPath";+ public static final String HTDOCS_PATH_DEFAULT = "DATA/HTDOCS";+ /**+ * <p><code>public static final String <strong>HTROOT_PATH</strong> = "htRootPath"</code></p>+ * <p>Name of the setting specifying the folder beginning from the YaCy-installation's top-folder, where all+ * original servlets, their stylesheets, scripts, etc. lie. It is also home of the XML-interface to YaCy</p>+ */+ public static final String HTROOT_PATH = "htRootPath";+ public static final String HTROOT_PATH_DEFAULT = "htroot";+ /**+ * <p><code>public static final String <strong>INDEX_PATH</strong> = "indexPath"</code></p>+ * <p>Name of the setting specifying the folder beginning from the YaCy-installation's top-folder, where the+ * whole database of known RWIs and URLs as well as dumps of the DHT-In and DHT-Out caches are stored</p>+ */+ public static final String INDEX_PRIMARY_PATH = "indexPrimaryPath"; // this is a relative path to the data root+ public static final String INDEX_SECONDARY_PATH = "indexSecondaryPath"; // this is a absolute path to any location+ public static final String INDEX_PATH_DEFAULT = "DATA/INDEX";+ /**+ * <p><code>public static final String <strong>LISTS_PATH</strong> = "listsPath"</code></p>+ * <p>Name of the setting specifying the folder beginning from the YaCy-installation's top-folder, where all+ * user-lists like blacklists, etc. are stored</p>+ */+ public static final String LISTS_PATH = "listsPath";+ public static final String LISTS_PATH_DEFAULT = "DATA/LISTS";+ /**+ * <p><code>public static final String <strong>RANKING_PATH</strong> = "rankingPath"</code></p>+ * <p>Name of the setting specifying the folder beginning from the YaCy-installation's top-folder, where all+ * ranking files are stored, self-generated as well as received ranking files</p>+ *+ * @see plasmaSwitchboard#RANKING_DIST_0_PATH+ * @see plasmaSwitchboard#RANKING_DIST_1_PATH+ */+ public static final String RANKING_PATH = "rankingPath";+ public static final String RANKING_PATH_DEFAULT = "DATA/RANKING";+ /**+ * <p><code>public static final String <strong>WORK_PATH</strong> = "wordPath"</code></p>+ * <p>Name of the setting specifying the folder beginning from the YaCy-installation's top-folder, where all+ * DBs containing "work" of the user are saved. Such include bookmarks, messages, wiki, blog</p>+ *+ * @see plasmaSwitchboard#DBFILE_BLOG+ * @see plasmaSwitchboard#DBFILE_BOOKMARKS+ * @see plasmaSwitchboard#DBFILE_BOOKMARKS_DATES+ * @see plasmaSwitchboard#DBFILE_BOOKMARKS_TAGS+ * @see plasmaSwitchboard#DBFILE_MESSAGE+ * @see plasmaSwitchboard#DBFILE_WIKI+ * @see plasmaSwitchboard#DBFILE_WIKI_BKP+ */+ public static final String WORK_PATH = "workPath";+ public static final String WORK_PATH_DEFAULT = "DATA/WORK";+ /**+ * <p><code>public static final String <strong>DBFILE_MESSAGE</strong> = "message.db"</code></p>+ * <p>Name of the file containing the database holding the user's peer-messages</p>+ *+ * @see plasmaSwitchboard#WORK_PATH for the folder, this file lies in+ */+ public static final String DBFILE_MESSAGE = "message.db";+ /**+ * <p><code>public static final String <strong>DBFILE_WIKI</strong> = "wiki.db"</code></p>+ * <p>Name of the file containing the database holding the whole wiki of this peer</p>+ *+ * @see plasmaSwitchboard#WORK_PATH for the folder, this file lies in+ * @see plasmaSwitchboard#DBFILE_WIKI_BKP for the file previous versions of wiki-pages lie in+ */+ public static final String DBFILE_WIKI = "wiki.db";+ /**+ * <p><code>public static final String <strong>DBFILE_WIKI_BKP</strong> = "wiki-bkp.db"</code></p>+ * <p>Name of the file containing the database holding all versions but the latest of the wiki-pages of this peer</p>+ *+ * @see plasmaSwitchboard#WORK_PATH for the folder this file lies in+ * @see plasmaSwitchboard#DBFILE_WIKI for the file the latest version of wiki-pages lie in+ */+ public static final String DBFILE_WIKI_BKP = "wiki-bkp.db";+ /**+ * <p><code>public static final String <strong>DBFILE_BLOG</strong> = "blog.db"</code></p>+ * <p>Name of the file containing the database holding all blog-entries available on this peer</p>+ *+ * @see plasmaSwitchboard#WORK_PATH for the folder this file lies in+ */+ public static final String DBFILE_BLOG = "blog.db";+ /**+ * <p><code>public static final String <strong>DBFILE_BLOGCOMMENTS</strong> = "blogComment.db"</code></p>+ * <p>Name of the file containing the database holding all blogComment-entries available on this peer</p>+ *+ * @see plasmaSwitchboard#WORK_PATH for the folder this file lies in+ */+ public static final String DBFILE_BLOGCOMMENTS = "blogComment.db";+ /**+ * <p><code>public static final String <strong>DBFILE_BOOKMARKS</strong> = "bookmarks.db"</code></p>+ * <p>Name of the file containing the database holding all bookmarks available on this peer</p>+ *+ * @see plasmaSwitchboard#WORK_PATH for the folder this file lies in+ * @see bookmarksDB for more detailed overview about the bookmarks structure+ */+ public static final String DBFILE_BOOKMARKS = "bookmarks.db";+ /**+ * <p><code>public static final String <strong>DBFILE_BOOKMARKS_TAGS</strong> = "bookmarkTags.db"</code></p>+ * <p>Name of the file containing the database holding all tag->bookmark relations</p>+ *+ * @see plasmaSwitchboard#WORK_PATH for the folder this file lies in+ * @see bookmarksDB for more detailed overview about the bookmarks structure+ */+ public static final String DBFILE_BOOKMARKS_TAGS = "bookmarkTags.db";+ /**+ * <p><code>public static final String <strong>DBFILE_BOOKMARKS_DATES</strong> = "bookmarkDates.db"</code></p>+ * <p>Name of the file containing the database holding all date->bookmark relations</p>+ *+ * @see plasmaSwitchboard#WORK_PATH for the folder this file lies in+ * @see bookmarksDB for more detailed overview about the bookmarks structure+ */+ public static final String DBFILE_BOOKMARKS_DATES = "bookmarkDates.db";+ /**+ * <p><code>public static final String <strong>DBFILE_CRAWL_ROBOTS</strong> = "crawlRobotsTxt.db"</code></p>+ * <p>Name of the file containing the database holding all <code>robots.txt</code>-entries of the lately crawled domains</p>+ *+ * @see plasmaSwitchboard#PLASMA_PATH for the folder this file lies in+ */+ public static final String DBFILE_CRAWL_ROBOTS = "crawlRobotsTxt.heap";+ /**+ * <p><code>public static final String <strong>DBFILE_USER</strong> = "DATA/SETTINGS/user.db"</code></p>+ * <p>Path to the user-DB, beginning from the YaCy-installation's top-folder. It holds all rights the created+ * users have as well as all other needed data about them</p>+ */+ public static final String DBFILE_USER = "DATA/SETTINGS/user.db";+ // we must distinguish the following cases: resource-load was initiated by+ // 1) global crawling: the index is extern, not here (not possible here)+ // 2) result of search queries, some indexes are here (not possible here)+ // 3) result of index transfer, some of them are here (not possible here)+ // 4) proxy-load (initiator is "------------")+ // 5) local prefetch/crawling (initiator is own seedHash)+ // 6) local fetching for global crawling (other known or unknown initiator)+ public static final int PROCESSCASE_0_UNKNOWN = 0;+ public static final int PROCESSCASE_4_PROXY_LOAD = 4;+ public static final int PROCESSCASE_5_LOCAL_CRAWLING = 5;+ public static final int PROCESSCASE_6_GLOBAL_CRAWLING = 6;+ /*+ * Some constants+ */+ public static final String STR_REMOTECRAWLTRIGGER = "REMOTECRAWLTRIGGER: REMOTE CRAWL TO PEER ";++}diff --git a/source/de/anomic/plasma/plasmaWordIndex.java b/source/de/anomic/plasma/plasmaWordIndex.javaindex 517f4ac89..c40619bf1 100644--- a/source/de/anomic/plasma/plasmaWordIndex.java+++ b/source/de/anomic/plasma/plasmaWordIndex.java@@ -129,8 +129,8 @@ public final class plasmaWordIndex implements indexRI {final File textindexcache = new File(indexPrimaryTextLocation, "RICACHE");if (!(textindexcache.exists())) textindexcache.mkdirs();- this.dhtOutCache = new indexRAMRI(textindexcache, indexRWIRowEntry.urlEntryRow, entityCacheMaxSize, wCacheMaxChunk, wCacheMaxAge, "dump1.array", "index.dhtout.heap", log);- this.dhtInCache = new indexRAMRI(textindexcache, indexRWIRowEntry.urlEntryRow, entityCacheMaxSize, wCacheMaxChunk, wCacheMaxAge, "dump2.array", "index.dhtin.heap", log);+ this.dhtOutCache = new indexRAMRI(textindexcache, indexRWIRowEntry.urlEntryRow, entityCacheMaxSize, wCacheMaxChunk, wCacheMaxAge, "index.dhtout.heap", log);+ this.dhtInCache = new indexRAMRI(textindexcache, indexRWIRowEntry.urlEntryRow, entityCacheMaxSize, wCacheMaxChunk, wCacheMaxAge, "index.dhtin.heap", log);// create collections storage pathfinal File textindexcollections = new File(indexPrimaryTextLocation, "RICOLLECTION");@@ -511,10 +511,21 @@ public final class plasmaWordIndex implements indexRI {}- public int addPageIndex(final yacyURL url, final Date urlModified, final int size, final plasmaParserDocument document, final plasmaCondenser condenser, final String language, final char doctype, final int outlinksSame, final int outlinksOther) {- // this is called by the switchboard to put in a new page into the index- // use all the words in one condenser object to simultanous create index entries-+ /**+ * this is called by the switchboard to put in a new page into the index+ * use all the words in one condenser object to simultanous create index entries+ *+ * @param url+ * @param urlModified+ * @param document+ * @param condenser+ * @param language+ * @param doctype+ * @param outlinksSame+ * @param outlinksOther+ * @return+ */+ public int addPageIndex(final yacyURL url, final Date urlModified, final plasmaParserDocument document, final plasmaCondenser condenser, final String language, final char doctype, final int outlinksSame, final int outlinksOther) {int wordCount = 0;final int urlLength = url.toNormalform(true, true).length();final int urlComps = htmlFilterContentScraper.urlComps(url.toString()).length;@@ -607,9 +618,16 @@ public final class plasmaWordIndex implements indexRI {return container;}- public HashMap<String, indexContainer> getContainers(final Set<String> wordHashes, final Set<String> urlselection, final boolean deleteIfEmpty, final boolean interruptIfEmpty) {- // return map of wordhash:indexContainer-+ /**+ * return map of wordhash:indexContainer+ *+ * @param wordHashes+ * @param urlselection+ * @param deleteIfEmpty+ * @param interruptIfEmpty+ * @return+ */+ public HashMap<String, indexContainer> getContainers(final Set<String> wordHashes, final Set<String> urlselection, final boolean interruptIfEmpty) {// retrieve entities that belong to the hashesfinal HashMap<String, indexContainer> containers = new HashMap<String, indexContainer>(wordHashes.size());String singleHash;@@ -639,13 +657,11 @@ public final class plasmaWordIndex implements indexRI {HashMap<String, indexContainer> inclusionContainers = (query.queryHashes.size() == 0) ? new HashMap<String, indexContainer>(0) : getContainers(query.queryHashes,urlselection,- true,true);if ((inclusionContainers.size() != 0) && (inclusionContainers.size() < query.queryHashes.size())) inclusionContainers = new HashMap<String, indexContainer>(0); // prevent that only a subset is returnedfinal HashMap<String, indexContainer> exclusionContainers = (inclusionContainers.size() == 0) ? new HashMap<String, indexContainer>(0) : getContainers(query.excludeHashes,urlselection,- true,true);return new HashMap[]{inclusionContainers, exclusionContainers};}@@ -816,7 +832,6 @@ public final class plasmaWordIndex implements indexRI {final int words = addPageIndex(entry.url(), // document urldocDate, // document mod date- (int) entry.size(), // document sizedocument, // document contentcondenser, // document condenseryacyURL.language(entry.url()), // document language@@ -849,9 +864,8 @@ public final class plasmaWordIndex implements indexRI {final kelondroCloneableIterator<indexContainer> i = wordContainers(startHash, ram);if (rot) {return new kelondroRotateIterator<indexContainer>(i, new String(kelondroBase64Order.zero(startHash.length())), dhtOutCache.size() + ((ram) ? 0 : collections.size()));- } else {- return i;}+ return i;}public synchronized kelondroCloneableIterator<indexContainer> wordContainers(final String startWordHash, final boolean ram) {@@ -859,14 +873,13 @@ public final class plasmaWordIndex implements indexRI {containerOrder.rotate(emptyContainer(startWordHash, 0));if (ram) {return dhtOutCache.wordContainers(startWordHash, false);- } else {- return new kelondroMergeIterator<indexContainer>(- dhtOutCache.wordContainers(startWordHash, false),- collections.wordContainers(startWordHash, false),- containerOrder,- indexContainer.containerMergeMethod,- true);}+ return new kelondroMergeIterator<indexContainer>(+ dhtOutCache.wordContainers(startWordHash, false),+ collections.wordContainers(startWordHash, false),+ containerOrder,+ indexContainer.containerMergeMethod,+ true);}diff --git a/source/de/anomic/server/logging/LogalizerHandler.java b/source/de/anomic/server/logging/LogalizerHandler.javaindex a4d175415..d9f269fa6 100644--- a/source/de/anomic/server/logging/LogalizerHandler.java+++ b/source/de/anomic/server/logging/LogalizerHandler.java@@ -54,7 +54,6 @@ public class LogalizerHandler extends Handler {configure();}- @SuppressWarnings("null")private HashMap<String, Object> loadParsers() {final HashMap<String, Object> logParsers = new HashMap<String, Object>();try {diff --git a/source/de/anomic/server/serverAbstractSwitch.java b/source/de/anomic/server/serverAbstractSwitch.javaindex 6f9f980ae..8d61f3bae 100644--- a/source/de/anomic/server/serverAbstractSwitch.java+++ b/source/de/anomic/server/serverAbstractSwitch.java@@ -285,7 +285,7 @@ public abstract class serverAbstractSwitch<E> implements serverSwitch<E> {// return valueif (s == null) return dflt;- else return (String) s;+ return (String) s;}}diff --git a/source/de/anomic/server/serverCachedFileOutputStream.java b/source/de/anomic/server/serverCachedFileOutputStream.javaindex c43e15e08..7be8550eb 100644--- a/source/de/anomic/server/serverCachedFileOutputStream.java+++ b/source/de/anomic/server/serverCachedFileOutputStream.java@@ -77,9 +77,8 @@ public class serverCachedFileOutputStream extends ByteArrayOutputStream {return true;} catch (final IOException e) {throw new RuntimeException("error falling back to file", e);- } else {- return false;}+ return false;}public void fallback() throws IOException {@@ -133,9 +132,8 @@ public class serverCachedFileOutputStream extends ByteArrayOutputStream {if (this.isFallback) {final InputStream is = new FileInputStream(this.fallbackFile);return (this.buffered) ? new BufferedInputStream(is) : is;- } else {- return new ByteArrayInputStream(this.buf);}+ return new ByteArrayInputStream(this.buf);}public byte[] getContentBAOS() {diff --git a/source/de/anomic/server/serverClassLoader.java b/source/de/anomic/server/serverClassLoader.javaindex af314b695..b6c4181df 100644--- a/source/de/anomic/server/serverClassLoader.java+++ b/source/de/anomic/server/serverClassLoader.java@@ -91,7 +91,7 @@ public final class serverClassLoader extends ClassLoader {packge = "";}if(packge.length() > 0) {- packge.replace(File.separatorChar, '.');+ packge = packge.replace(File.separatorChar, '.');packge += ".";}}diff --git a/source/de/anomic/server/serverCore.java b/source/de/anomic/server/serverCore.javaindex 8a1bd47a5..a72f1668a 100644--- a/source/de/anomic/server/serverCore.java+++ b/source/de/anomic/server/serverCore.java@@ -104,7 +104,7 @@ public final class serverCore extends serverAbstractBusyThread implements server/*** for brute-force prevention*/- public static ConcurrentHashMap<String, Integer> bfHost = new ConcurrentHashMap<String, Integer>();+ public static final ConcurrentHashMap<String, Integer> bfHost = new ConcurrentHashMap<String, Integer>();// class variables/**@@ -890,7 +890,8 @@ public final class serverCore extends serverAbstractBusyThread implements serverwhile ((l = is.read(buffer)) > 0) {os.write(buffer, 0, l);}os.write(CRLF);os.flush();- if (bufferSize > 80) return "<LONG STREAM>"; else return new String(buffer);+ if (bufferSize > 80) return "<LONG STREAM>";+ return new String(buffer);}protected void finalize() throws Throwable {diff --git a/source/de/anomic/server/serverDate.java b/source/de/anomic/server/serverDate.javaindex 7e3b49e29..e7cd93956 100644--- a/source/de/anomic/server/serverDate.java+++ b/source/de/anomic/server/serverDate.java@@ -62,17 +62,17 @@ public final class serverDate {private static final Calendar CAL_GMT = Calendar.getInstance(TZ_GMT, Locale.US);/** Date formatter/parser for minimal yyyyMMdd pattern */- public static final SimpleDateFormat FORMAT_SHORT_DAY = new SimpleDateFormat(PATTERN_SHORT_DAY);+ private static final SimpleDateFormat FORMAT_SHORT_DAY = new SimpleDateFormat(PATTERN_SHORT_DAY);/** Date formatter/parser for minimal yyyyMMddHHmmss pattern */- public static final SimpleDateFormat FORMAT_SHORT_SECOND = new SimpleDateFormat(PATTERN_SHORT_SECOND);+ private static final SimpleDateFormat FORMAT_SHORT_SECOND = new SimpleDateFormat(PATTERN_SHORT_SECOND);/** Date formatter/parser for minimal yyyyMMddHHmmssSSS pattern */- public static final SimpleDateFormat FORMAT_SHORT_MILSEC = new SimpleDateFormat(PATTERN_SHORT_MILSEC);+ private static final SimpleDateFormat FORMAT_SHORT_MILSEC = new SimpleDateFormat(PATTERN_SHORT_MILSEC);/** Date formatter/non-sloppy parser for W3C datetime (ISO8601) in GMT/UTC */- public static final SimpleDateFormat FORMAT_ISO8601 = new SimpleDateFormat(PATTERN_ISO8601);+ private static final SimpleDateFormat FORMAT_ISO8601 = new SimpleDateFormat(PATTERN_ISO8601);/** Date formatter/parser for standard compliant HTTP header dates (RFC 1123) */- public static final SimpleDateFormat FORMAT_RFC1123 = new SimpleDateFormat(PATTERN_RFC1123, Locale.US);+ private static final SimpleDateFormat FORMAT_RFC1123 = new SimpleDateFormat(PATTERN_RFC1123, Locale.US);/*** RFC 2616 requires that HTTP clients are able to parse all 3 different@@ -462,20 +462,21 @@ public final class serverDate {if (diff.length() < 2) diff = "0" + diff;diff = Integer.toString(oh) + diff;if (diff.length() < 4) diff = "0" + diff;- if (offsetHours >= 0) {- return "+" + diff;- } else {+ if (offsetHours < 0) {return "-" + diff;}+ return "+" + diff;}public static long UTCDiff() {// DST_OFFSET is dependent on the time of the Calendar, so it has to be updated// to get the correct current offset- thisCalendar.setTimeInMillis(System.currentTimeMillis());- final long zoneOffsetHours = thisCalendar.get(Calendar.ZONE_OFFSET);- final long DSTOffsetHours = thisCalendar.get(Calendar.DST_OFFSET);- return zoneOffsetHours + DSTOffsetHours;+ synchronized(thisCalendar) {+ thisCalendar.setTimeInMillis(System.currentTimeMillis());+ final long zoneOffsetHours = thisCalendar.get(Calendar.ZONE_OFFSET);+ final long DSTOffsetHours = thisCalendar.get(Calendar.DST_OFFSET);+ return zoneOffsetHours + DSTOffsetHours;+ }}public static long UTCDiff(final String diffString) {@@ -610,7 +611,8 @@ public final class serverDate {public static long remainingTime(final long start, final long due, final long minimum) {if (due < 0) return -1;final long r = due + start - System.currentTimeMillis();- if (r <= 0) return minimum; else return r;+ if (r <= 0) return minimum;+ return r;}public static void main(final String[] args) {@@ -621,7 +623,7 @@ public final class serverDate {System.out.println("serverDate : " + new serverDate().toString());System.out.println(" JavaDate : " + DateFormat.getDateInstance().format(new Date()));System.out.println("serverDate0: " + new serverDate(0).toShortString(false));- System.out.println(" JavaDate0: " + FORMAT_SHORT_SECOND.format(new Date(0)));+ System.out.println(" JavaDate0: " + format(FORMAT_SHORT_SECOND, new Date(0)));System.out.println("serverDate0: " + new serverDate(0).toString());System.out.println(" JavaDate0: " + DateFormat.getDateInstance().format(new Date(0)));// parse test@@ -641,7 +643,7 @@ public final class serverDate {System.out.println("time for " + cycles + " calls to serverDate:" + (System.currentTimeMillis() - start) + " milliseconds");start = System.currentTimeMillis();- for (int i = 0; i < cycles; i++) testresult[i] = FORMAT_SHORT_SECOND.format(new Date());+ for (int i = 0; i < cycles; i++) testresult[i] = format(FORMAT_SHORT_SECOND, new Date());System.out.println("time for " + cycles + " calls to javaDate:" + (System.currentTimeMillis() - start) + " milliseconds");}}diff --git a/source/de/anomic/server/serverDomains.java b/source/de/anomic/server/serverDomains.javaindex 70f05d9f2..e5e7baae6 100644--- a/source/de/anomic/server/serverDomains.java+++ b/source/de/anomic/server/serverDomains.java@@ -553,18 +553,18 @@ public class serverDomains {final Integer i = TLDID.get(tld);if (i == null) {return (isLocal(host)) ? 7 : TLD_Generic_ID;- } else {- return i.intValue();}+ return i.intValue();}- public static boolean isLocal(String host) {+ public static boolean isLocal(final String host) {// attention! because this method does a dns resolve to look up an IP address,// the result may be very slow. Consider 100 milliseconds per accessassert (host != null);+ // FIXME IPv4 only// check local ip addressesif (host.equals("localhost") || host.startsWith("127")|| host.startsWith("192.168")@@ -602,7 +602,7 @@ public class serverDomains {final InetAddress clientAddress = dnsResolve(host);if (clientAddress != null) {if ((clientAddress.isAnyLocalAddress()) || (clientAddress.isLoopbackAddress())) return true;- if (host.charAt(0) > '9') host = clientAddress.getHostAddress();+ // FIXME !!host is not read after this!!: if (host.charAt(0) > '9') host = clientAddress.getHostAddress();}// finally check if there are other local IP adresses that are not indiff --git a/source/de/anomic/server/serverFileUtils.java b/source/de/anomic/server/serverFileUtils.javaindex 42cb32c88..3f4de96c5 100644--- a/source/de/anomic/server/serverFileUtils.java+++ b/source/de/anomic/server/serverFileUtils.java@@ -126,6 +126,7 @@ public final class serverFileUtils {dest.write(buffer, 0, n);count += n;}+ dest.flush();} catch (final Exception e) {// an "sun.io.MalformedInputException: Missing byte-order mark" - exception may occur herethrow new IOException(e.getMessage());diff --git a/source/de/anomic/server/serverInstantBlockingThread.java b/source/de/anomic/server/serverInstantBlockingThread.javaindex 91d550c09..298d81e59 100644--- a/source/de/anomic/server/serverInstantBlockingThread.java+++ b/source/de/anomic/server/serverInstantBlockingThread.java@@ -38,7 +38,7 @@ public class serverInstantBlockingThread<J extends serverProcessorJob> extends sprivate final Long handle;private static int handleCounter = 0;public static int instantThreadCounter = 0;- public static ConcurrentHashMap<Long, String> jobs = new ConcurrentHashMap<Long, String>();+ public static final ConcurrentHashMap<Long, String> jobs = new ConcurrentHashMap<Long, String>();public serverInstantBlockingThread(final Object env, final String jobExec, final BlockingQueue<J> input, final serverProcessor<J> output) {// jobExec is the name of a method of the object 'env' that executes the one-step-rundiff --git a/source/de/anomic/server/serverInstantBusyThread.java b/source/de/anomic/server/serverInstantBusyThread.javaindex 6d3b32b23..c45829986 100644--- a/source/de/anomic/server/serverInstantBusyThread.java+++ b/source/de/anomic/server/serverInstantBusyThread.java@@ -34,7 +34,7 @@ public final class serverInstantBusyThread extends serverAbstractBusyThread implprivate final Long handle;public static int instantThreadCounter = 0;- public static TreeMap<Long, String> jobs = new TreeMap<Long, String>();+ public static final TreeMap<Long, String> jobs = new TreeMap<Long, String>();public serverInstantBusyThread(final Object env, final String jobExec, final String jobCount, final String freemem) {// jobExec is the name of a method of the object 'env' that executes the one-step-rundiff --git a/source/de/anomic/server/serverObjects.java b/source/de/anomic/server/serverObjects.javaindex e33f91f0c..24368b44d 100644--- a/source/de/anomic/server/serverObjects.java+++ b/source/de/anomic/server/serverObjects.java@@ -115,9 +115,8 @@ public class serverObjects extends HashMap<String, String> implements Cloneablepublic double put(final String key, final double value) {if (null == this.put(key, Double.toString(value))) {return Double.NaN;- } else {- return value;}+ return value;}/**@@ -127,9 +126,8 @@ public class serverObjects extends HashMap<String, String> implements Cloneablepublic long put(final String key, final long value) {if (null == this.put(key, Long.toString(value))) {return 0;- } else {- return value;}+ return value;}public String put(final String key, final java.util.Date value) {@@ -227,13 +225,15 @@ public class serverObjects extends HashMap<String, String> implements Cloneable// new get with default objectspublic Object get(final String key, final Object dflt) {final Object result = super.get(key);- if (result == null) return dflt; else return result;+ if (result == null) return dflt;+ return result;}// string variantpublic String get(final String key, final String dflt) {final Object result = super.get(key);- if (result == null) return dflt; else return (String) result;+ if (result == null) return dflt;+ return (String) result;}public int getInt(final String key, final int dflt) {diff --git a/source/de/anomic/server/serverSystem.java b/source/de/anomic/server/serverSystem.javaindex 53019d2b1..7f2076e96 100644--- a/source/de/anomic/server/serverSystem.java+++ b/source/de/anomic/server/serverSystem.java@@ -65,8 +65,8 @@ public final class serverSystem {private static Method macSetFileCreator = null;private static Method macSetFileType = null;private static Method macOpenURL = null;- public static Hashtable<String, String> macFSTypeCache = null;- public static Hashtable<String, String> macFSCreatorCache = null;+ public static final Hashtable<String, String> macFSTypeCache = new Hashtable<String, String>();+ public static final Hashtable<String, String> macFSCreatorCache = new Hashtable<String, String>();// static initializationstatic {@@ -97,8 +97,6 @@ public final class serverSystem {final byte[] nullb = new byte[4];for (int i = 0; i < 4; i++) nullb[i] = 0;macMRJOSNullObj = macMRJOSTypeConstructor.newInstance(new Object[] {new String(nullb)});- macFSTypeCache = new Hashtable<String, String>();- macFSCreatorCache = new Hashtable<String, String>();} catch (final Exception e) {//e.printStackTrace();macMRJFileUtils = null; macMRJOSType = null;@@ -115,28 +113,33 @@ public final class serverSystem {public static Object getMacOSTS(final String s) {if ((isMacArchitecture) && (macMRJFileUtils != null)) try {if ((s == null) || (s.equals(blankTypeString))) return macMRJOSNullObj;- else return macMRJOSTypeConstructor.newInstance(new Object[] {s});+ return macMRJOSTypeConstructor.newInstance(new Object[] {s});} catch (final Exception e) {return macMRJOSNullObj;- } else return null;+ }+ return null;}public static String getMacFSType(final File f) {if ((isMacArchitecture) && (macMRJFileUtils != null)) try {final String s = macGetFileType.invoke(null, new Object[] {f}).toString();- if ((s == null) || (s.charAt(0) == 0)) return blankTypeString; else return s;+ if ((s == null) || (s.charAt(0) == 0)) return blankTypeString;+ return s;} catch (final Exception e) {return null;- } else return null;+ }+ return null;}public static String getMacFSCreator(final File f) {if ((isMacArchitecture) && (macMRJFileUtils != null)) try {final String s = macGetFileCreator.invoke(null, new Object[] {f}).toString();- if ((s == null) || (s.charAt(0) == 0)) return blankTypeString; else return s;+ if ((s == null) || (s.charAt(0) == 0)) return blankTypeString;+ return s;} catch (final Exception e) {return null;- } else return null;+ }+ return null;}public static void setMacFSType(final File f, final String t) {diff --git a/source/de/anomic/server/servletProperties.java b/source/de/anomic/server/servletProperties.javaindex 21e419a8d..afcf684d5 100644--- a/source/de/anomic/server/servletProperties.java+++ b/source/de/anomic/server/servletProperties.java@@ -52,10 +52,9 @@ public class servletProperties extends serverObjects {}public httpHeader getOutgoingHeader() {- if(outgoingHeader!=null)- return outgoingHeader;- else+ if(outgoingHeader == null)return new httpHeader();+ return outgoingHeader;}public void setPrefix(final String myprefix) {diff --git a/source/de/anomic/tools/Punycode.java b/source/de/anomic/tools/Punycode.javaindex 54cfec1af..4568d7359 100644--- a/source/de/anomic/tools/Punycode.java+++ b/source/de/anomic/tools/Punycode.java@@ -264,8 +264,8 @@ public class Punycode**/private static final long serialVersionUID = 1L;- public static String OVERFLOW = "Overflow.";- public static String BAD_INPUT = "Bad input.";+ public static final String OVERFLOW = "Overflow.";+ public static final String BAD_INPUT = "Bad input.";/*** Creates a new PunycodeException.diff --git a/source/de/anomic/tools/consoleInterface.java b/source/de/anomic/tools/consoleInterface.javaindex 16bdd1b1a..3566fde2e 100755--- a/source/de/anomic/tools/consoleInterface.java+++ b/source/de/anomic/tools/consoleInterface.java@@ -35,18 +35,13 @@ public class consoleInterface extends Threadprivate final InputStream stream;private final List<String> output = new ArrayList<String>();private final Semaphore dataIsRead = new Semaphore(1);- /**- * FIXME just for debugging- */- //private final String name;private final serverLog log;- public consoleInterface(final InputStream stream, final String name, final serverLog log)+ public consoleInterface(final InputStream stream, final serverLog log){this.log = log;this.stream = stream;- //this.name = name;// block reading {@see getOutput()}try {dataIsRead.acquire();@@ -74,7 +69,6 @@ public class consoleInterface extends Threadif (buffer.ready())break;}- //log.logInfo("logpoint 3 "+ name +" needed " + tries + " tries");while((line = buffer.readLine()) != null) {output.add(line);}@@ -90,10 +84,7 @@ public class consoleInterface extends Threadpublic List<String> getOutput(){// wait that data is readytry {- //log.logInfo("logpoint 4 waiting for data of '"+ name +"'");- //final long start = System.currentTimeMillis();dataIsRead.acquire();- //log.logInfo("logpoint 5 data ready for '"+ name +"' after "+ (System.currentTimeMillis() - start) +" ms");} catch (final InterruptedException e) {// after interrupt just return what is available (maybe nothing)}diff --git a/source/de/anomic/tools/crypt.java b/source/de/anomic/tools/crypt.javaindex 6d047300c..6a7346c99 100644--- a/source/de/anomic/tools/crypt.java+++ b/source/de/anomic/tools/crypt.java@@ -68,10 +68,12 @@ public class crypt {public crypt(final String pbe, final String salt) {this(pbe, salt, defaultMethod);}- private crypt(final String pbe, String salt, final String method) {+ private crypt(final String pbe, final String salt, final String method) {// a Password-Based Encryption. The SecretKey is created on the fly+ /* salt currently not usedif (salt.length() > 8) salt = salt.substring(0,8);if (salt.length() < 8) salt = (salt + "XXXXXXXX").substring(0,8);+ */// Create a cipher and initialize it for encrypting end decryptingcryptMethod = method;diff --git a/source/de/anomic/tools/cryptbig.java b/source/de/anomic/tools/cryptbig.javaindex 0b4d1d628..1e860a01d 100644--- a/source/de/anomic/tools/cryptbig.java+++ b/source/de/anomic/tools/cryptbig.java@@ -390,10 +390,12 @@ public class cryptbig {if (b64dec == null) return null; // error in input string (inconsistency)final byte[] dec = c.decryptArray(b64dec);if (dec == null) return null;- if (gzFlag)- return gzip.gunzipString(dec);- else- try {return new String(dec,"UTF8");} catch (final UnsupportedEncodingException e) {return null;}+ if (gzFlag) return gzip.gunzipString(dec);+ try {+ return new String(dec,"UTF8");+ } catch (final UnsupportedEncodingException e) {+ return null;+ }}diff --git a/source/de/anomic/tools/diskUsage.java b/source/de/anomic/tools/diskUsage.javaindex 36ed70493..33dd64ce8 100644--- a/source/de/anomic/tools/diskUsage.java+++ b/source/de/anomic/tools/diskUsage.java@@ -98,32 +98,31 @@ public class diskUsage {usedOS = getOS();if (usedOS == -1) {return;- } else {- usageError = null;-- if (usedOS <= UNIX_END) {- // some kind of *nix- dfUnixGetVolumes();- for (int i = 0; i < allMountPoints.size(); i++)- usedVolumes.add(false);- checkVolumesInUseUnix ("DATA");- checkMappedSubDirs(pathsToCheck);-- for (int i = 0; i < allVolumes.size(); i++){- if (usedVolumes.get(i) == true) {- yacyUsedVolumes.add(allVolumes.get (i));- yacyUsedMountPoints.add(allMountPoints.get (i));- }+ }+ usageError = null;++ if (usedOS <= UNIX_END) {+ // some kind of *nix+ dfUnixGetVolumes();+ for (int i = 0; i < allMountPoints.size(); i++)+ usedVolumes.add(false);+ checkVolumesInUseUnix ("DATA");+ checkMappedSubDirs(pathsToCheck);++ for (int i = 0; i < allVolumes.size(); i++){+ if (usedVolumes.get(i) == true) {+ yacyUsedVolumes.add(allVolumes.get (i));+ yacyUsedMountPoints.add(allMountPoints.get (i));}- } else {- // all Windows versions- initWindowsCommandVersion();- checkStartVolume();- checkMappedSubDirs(pathsToCheck);}- if (yacyUsedVolumes.size() < 1)- usageError = "found no volumes";+ } else {+ // all Windows versions+ initWindowsCommandVersion();+ checkStartVolume();+ checkMappedSubDirs(pathsToCheck);}+ if (yacyUsedVolumes.size() < 1)+ usageError = "found no volumes";}public static HashMap<String, long[]> getDiskUsage () {@@ -392,8 +391,8 @@ public class diskUsage {try {process = processBuilder.start();- inputStream = new consoleInterface(process.getInputStream(), "input", log);- errorStream = new consoleInterface(process.getErrorStream(), "error", log);+ inputStream = new consoleInterface(process.getInputStream(), log);+ errorStream = new consoleInterface(process.getErrorStream(), log);inputStream.start();errorStream.start();@@ -412,8 +411,8 @@ public class diskUsage {final String error = errorStream.getOutput().toString();log.logWarning("logpoint 2: "+ error);throw new IOException("empty list: " + error);- } else- return list;+ }+ return list;}}diff --git a/source/de/anomic/tools/loaderThreads.java b/source/de/anomic/tools/loaderThreads.javaindex 4c25d146e..1cbf7a087 100644--- a/source/de/anomic/tools/loaderThreads.java+++ b/source/de/anomic/tools/loaderThreads.java@@ -72,19 +72,19 @@ public class loaderThreads {public void terminateThread(final String name) {final loaderThread t = (loaderThread) threads.get(name);if (t == null) throw new RuntimeException("no such thread: " + name);- else t.terminate();+ t.terminate();}public int threadCompleted(final String name) {final loaderThread t = (loaderThread) threads.get(name);if (t == null) throw new RuntimeException("no such thread: " + name);- else return t.completed();+ return t.completed();}public int threadStatus(final String name) {final loaderThread t = (loaderThread) threads.get(name);if (t == null) throw new RuntimeException("no such thread: " + name);- else return t.status();+ return t.status();}public int completed() {@@ -102,7 +102,7 @@ public class loaderThreads {public Exception threadError(final String name) {final loaderThread t = (loaderThread) threads.get(name);if (t == null) throw new RuntimeException("no such thread: " + name);- else return t.error();+ return t.error();}protected class loaderThread extends Thread {@@ -193,11 +193,10 @@ public class loaderThreads {}if (line == lines.size()) {this.status = STATUS_COMPLETED;- return;} else {this.status = STATUS_ABORTED;- return;}+ return;} catch (final Exception e) {this.status = STATUS_FAILED;this.error = e;diff --git a/source/de/anomic/tools/nxTools.java b/source/de/anomic/tools/nxTools.javaindex fbc28f4df..9fc2986e6 100644--- a/source/de/anomic/tools/nxTools.java+++ b/source/de/anomic/tools/nxTools.java@@ -156,12 +156,12 @@ public class nxTools {while ((count >= 1) && (sentence.length() > 0)) {pos = sentence.indexOf(separator);if (pos < 0) {- if (count == 1) return sentence; else return null;- } else {- if (count == 1) return sentence.substring(0, pos);- sentence = sentence.substring(pos + separator.length());- count--;+ if (count == 1) return sentence;+ return null;}+ if (count == 1) return sentence.substring(0, pos);+ sentence = sentence.substring(pos + separator.length());+ count--;}return null;}@@ -233,23 +233,22 @@ public class nxTools {public static String shortenURLString(final String url, final int len) {// This is contributed by Thomas Quella (borg-0300)if (url == null) { return null; }- int la = url.length();- if (la > len) {+ int urlLen = url.length();+ if (urlLen > len) {int cpos;cpos = url.indexOf("://");if (cpos >= 0) {cpos = url.indexOf("/", cpos + 3);- if (cpos >= 0) {- if (cpos < len-(len / 3)) { // at least 1/3 characters for the path- final int lb = ((len - cpos) / 2) - 1;- if (lb * 2 + 2 + cpos < len) { la--; } // if smaller(odd), half right path + 1- return url.substring(0, cpos + lb).concat("..").concat(url.substring(la - lb));- } else {- return url.substring(0, len - 2).concat("..");- }- } else { // very crazy domain or very short len+ if (cpos < 0) { // very crazy domain or very short lenreturn url.substring(0, len - 2).concat("..");- } // no slash at end+ }+ if (cpos >= len-(len / 3)) {+ return url.substring(0, len - 2).concat("..");+ }+ // at least 1/3 characters for the path+ final int lb = ((len - cpos) / 2) - 1;+ if (lb * 2 + 2 + cpos < len) { urlLen--; } // if smaller(odd), half right path + 1+ return url.substring(0, cpos + lb).concat("..").concat(url.substring(urlLen - lb));} // NO URL !?} // URL < lenreturn url;diff --git a/source/de/anomic/tools/tarTools.java b/source/de/anomic/tools/tarTools.javaindex cbc857372..f03a69480 100644--- a/source/de/anomic/tools/tarTools.java+++ b/source/de/anomic/tools/tarTools.java@@ -42,9 +42,8 @@ public class tarTools {public static InputStream getInputStream(final String tarFileName) throws Exception{if(tarFileName.endsWith(".gz")){return new GZIPInputStream(new FileInputStream(new File(tarFileName)));- } else {- return new FileInputStream(new File(tarFileName));}+ return new FileInputStream(new File(tarFileName));}public static InputStream getInputStream(final File tarFileName) throws Exception{diff --git a/source/de/anomic/urlRedirector/urlRedirectord.java b/source/de/anomic/urlRedirector/urlRedirectord.javaindex 7cfebee94..f67449efc 100644--- a/source/de/anomic/urlRedirector/urlRedirectord.java+++ b/source/de/anomic/urlRedirector/urlRedirectord.java@@ -19,7 +19,7 @@ import de.anomic.server.logging.serverLog;import de.anomic.server.serverCore.Session;import de.anomic.yacy.yacyURL;-public class urlRedirectord implements serverHandler {+public class urlRedirectord implements serverHandler, Cloneable {private serverCore.Session session;private static plasmaSwitchboard sb = null;diff --git a/source/de/anomic/xml/RSSFeed.java b/source/de/anomic/xml/RSSFeed.javaindex 11216c602..7c1ac2808 100644--- a/source/de/anomic/xml/RSSFeed.java+++ b/source/de/anomic/xml/RSSFeed.java@@ -48,7 +48,7 @@ public class RSSFeed implements Iterable<RSSMessage> {* the following private channels are declared to prevent that an access to the feed servlet* gets results from news channels that are not for the public*/- public static HashSet<String> privateChannels = new HashSet<String>();+ public static final HashSet<String> privateChannels = new HashSet<String>();static {privateChannels.add(LOCALSEARCH);privateChannels.add(LOCALINDEXING);diff --git a/source/de/anomic/xml/RSSMessage.java b/source/de/anomic/xml/RSSMessage.javaindex 5caea1400..430ceb52d 100644--- a/source/de/anomic/xml/RSSMessage.java+++ b/source/de/anomic/xml/RSSMessage.java@@ -79,61 +79,70 @@ public class RSSMessage {public String getAuthor() {final String s = map.get("author");- if (s == null) return ""; else return s;+ return emptyStringOnNull(s);}public String getCopyright() {final String s = map.get("copyright");- if (s == null) return ""; else return s;+ return emptyStringOnNull(s);}public String getCategory() {final String s = map.get("category");- if (s == null) return ""; else return s;+ return emptyStringOnNull(s);}public String getTitle() {final String s = map.get("title");- if (s == null) return ""; else return s;+ return emptyStringOnNull(s);}public String getLink() {final String s = map.get("link");- if (s == null) return ""; else return s;+ return emptyStringOnNull(s);}public String getReferrer() {final String s = map.get("referrer");- if (s == null) return ""; else return s;+ return emptyStringOnNull(s);}public String getLanguage() {final String s = map.get("language");- if (s == null) return ""; else return s;+ return emptyStringOnNull(s);}public String getDescription() {final String s = map.get("description");- if (s == null) return ""; else return s;+ return emptyStringOnNull(s);}public String getCreator() {final String s = map.get("creator");- if (s == null) return ""; else return s;+ return emptyStringOnNull(s);}public String getPubDate() {final String s = map.get("pubDate");- if (s == null) return ""; else return s;+ return emptyStringOnNull(s);}public String getGuid() {final String s = map.get("guid");- if (s == null) return ""; else return s;+ return emptyStringOnNull(s);}public String getDocs() {final String s = map.get("docs");- if (s == null) return ""; else return s;+ return emptyStringOnNull(s);+ }++ /**+ * @param s+ * @return+ */+ private String emptyStringOnNull(final String s) {+ if (s == null) return "";+ return s;}}diff --git a/source/de/anomic/xml/crawlHandler.java b/source/de/anomic/xml/crawlHandler.javaindex a28d8f04a..c78429ce3 100644--- a/source/de/anomic/xml/crawlHandler.java+++ b/source/de/anomic/xml/crawlHandler.java@@ -109,7 +109,7 @@ public class crawlHandler extends DefaultHandler {}}- public void startElement(final String uri, final String name, final String tag, final Attributes atts) {+ public void startElement(final String tag) {if ("channel".equals(tag)) {channel = new Startpoint();parsingAttributes = true;diff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.javaindex c2001fcef..9a446fe4a 100644--- a/source/de/anomic/yacy/yacyClient.java+++ b/source/de/anomic/yacy/yacyClient.java@@ -56,18 +56,17 @@ import java.util.Map;import java.util.TreeMap;import org.apache.commons.httpclient.methods.multipart.ByteArrayPartSource;-import org.apache.commons.httpclient.methods.multipart.FilePart;import org.apache.commons.httpclient.methods.multipart.Part;-import org.apache.commons.httpclient.methods.multipart.StringPart;import de.anomic.crawler.HTTPLoader;import de.anomic.crawler.ResultURLs;+import de.anomic.http.DefaultCharsetFilePart;+import de.anomic.http.DefaultCharsetStringPart;import de.anomic.http.HttpClient;import de.anomic.http.JakartaCommonsHttpClient;import de.anomic.http.JakartaCommonsHttpResponse;import de.anomic.http.httpHeader;import de.anomic.http.httpRemoteProxyConfig;-import de.anomic.http.httpdProxyHandler;import de.anomic.index.indexContainer;import de.anomic.index.indexRWIEntry;import de.anomic.index.indexRWIRowEntry;@@ -92,32 +91,37 @@ import de.anomic.xml.RSSReader;public final class yacyClient {+ /**+ * this is called to enrich the seed information by+ * - own address (if peer is behind a nat/router)+ * - check peer type (virgin/junior/senior/principal)+ *+ * to do this, we send a 'Hello' to another peer+ * this carries the following information:+ * 'iam' - own hash+ * 'youare' - remote hash, to verify that we are correct+ * 'key' - a session key that the remote peer may use to answer+ * and the own seed string+ * we expect the following information to be send back:+ * - 'yourip' the ip of the connection peer (we)+ * - 'yourtype' the type of this peer that the other peer checked by asking for a specific word+ * and the remote seed string+ *+ * one exceptional failure case is when we know the other's peers hash, the other peers responds correctly+ * but they appear to be another peer by comparisment of the other peer's hash+ * this works of course only if we know the other peer's hash.+ *+ * @return the number of new seeds+ */public static int publishMySeed(final yacySeed mySeed, final yacyPeerActions peerActions, final String address, final String otherHash) {- // this is called to enrich the seed information by- // - own address (if peer is behind a nat/router)- // - check peer type (virgin/junior/senior/principal)- // to do this, we send a 'Hello' to another peer- // this carries the following information:- // 'iam' - own hash- // 'youare' - remote hash, to verify that we are correct- // 'key' - a session key that the remote peer may use to answer- // and the own seed string- // we expect the following information to be send back:- // - 'yourip' the ip of the connection peer (we)- // - 'yourtype' the type of this peer that the other peer checked by asking for a specific word- // and the remote seed string- // the number of new seeds are returned- // one exceptional failure case is when we know the other's peers hash, the other peers responds correctly- // but they appear to be another peer by comparisment of the other peer's hash- // this works of course only if we know the other peer's hash.HashMap<String, String> result = null;final String salt = crypt.randomSalt();final List<Part> post = yacyNetwork.basicRequestPost(plasmaSwitchboard.getSwitchboard(), null, salt);for (int retry = 0; retry < 4; retry++) try {// generate request- post.add(new StringPart("count", "20"));- post.add(new StringPart("seed", mySeed.genSeedStr(salt)));+ post.add(new DefaultCharsetStringPart("count", "20"));+ post.add(new DefaultCharsetStringPart("seed", mySeed.genSeedStr(salt)));// send requestfinal long start = System.currentTimeMillis();final byte[] content = wput("http://" + address + "/yacy/hello.html", yacySeed.b64Hash2hexHash(otherHash) + ".yacyh", post, 15000, false);@@ -128,10 +132,9 @@ public final class yacyClient {if (Thread.currentThread().isInterrupted()) {yacyCore.log.logWarning("yacyClient.publishMySeed thread '" + Thread.currentThread().getName() + "' interrupted.");return -1;- } else {- yacyCore.log.logWarning("yacyClient.publishMySeed thread '" + Thread.currentThread().getName() + "' exception: " + e.getMessage() + "; retry = " + retry);- // try again (go into loop)}+ yacyCore.log.logWarning("yacyClient.publishMySeed thread '" + Thread.currentThread().getName() + "' exception: " + e.getMessage() + "; retry = " + retry);+ // try again (go into loop)result = null;}@@ -304,8 +307,8 @@ public final class yacyClient {// prepare requestfinal String salt = crypt.randomSalt();final List<Part> post = yacyNetwork.basicRequestPost(plasmaSwitchboard.getSwitchboard(), target.hash, salt);- post.add(new StringPart("object", "seed"));- post.add(new StringPart("env", seedHash));+ post.add(new DefaultCharsetStringPart("object", "seed"));+ post.add(new DefaultCharsetStringPart("env", seedHash));// send requesttry {@@ -325,9 +328,9 @@ public final class yacyClient {// prepare requestfinal String salt = crypt.randomSalt();final List<Part> post = yacyNetwork.basicRequestPost(plasmaSwitchboard.getSwitchboard(), target.hash, salt);- post.add(new StringPart("object", "rwicount"));- post.add(new StringPart("ttl", "0"));- post.add(new StringPart("env", wordHash));+ post.add(new DefaultCharsetStringPart("object", "rwicount"));+ post.add(new DefaultCharsetStringPart("ttl", "0"));+ post.add(new DefaultCharsetStringPart("env", wordHash));// send requesttry {@@ -348,9 +351,9 @@ public final class yacyClient {// prepare requestfinal String salt = crypt.randomSalt();final List<Part> post = yacyNetwork.basicRequestPost(plasmaSwitchboard.getSwitchboard(), target.hash, salt);- post.add(new StringPart("object", "lurlcount"));- post.add(new StringPart("ttl", "0"));- post.add(new StringPart("env", ""));+ post.add(new DefaultCharsetStringPart("object", "lurlcount"));+ post.add(new DefaultCharsetStringPart("ttl", "0"));+ post.add(new DefaultCharsetStringPart("env", ""));// send requesttry {@@ -361,7 +364,8 @@ public final class yacyClient {final String resp = result.get("response");if (resp == null) {return -1;- } else try {+ }+ try {return Integer.parseInt(resp);} catch (final NumberFormatException e) {return -1;@@ -379,8 +383,8 @@ public final class yacyClient {// prepare requestfinal String salt = crypt.randomSalt();final List<Part> post = yacyNetwork.basicRequestPost(plasmaSwitchboard.getSwitchboard(), target.hash, salt);- post.add(new StringPart("call", "remotecrawl"));- post.add(new StringPart("count", Integer.toString(count)));+ post.add(new DefaultCharsetStringPart("call", "remotecrawl"));+ post.add(new DefaultCharsetStringPart("count", Integer.toString(count)));// send requesttry {@@ -450,21 +454,21 @@ public final class yacyClient {// prepare requestfinal String salt = crypt.randomSalt();final List<Part> post = yacyNetwork.basicRequestPost(plasmaSwitchboard.getSwitchboard(), target.hash, salt);- post.add(new StringPart("myseed", mySeed.genSeedStr(salt)));- post.add(new StringPart("count", Integer.toString(Math.max(10, count))));- post.add(new StringPart("resource", ((global) ? "global" : "local")));- post.add(new StringPart("partitions", Integer.toString(partitions)));- post.add(new StringPart("query", wordhashes));- post.add(new StringPart("exclude", excludehashes));- post.add(new StringPart("duetime", "1000"));- post.add(new StringPart("urls", urlhashes));- post.add(new StringPart("prefer", prefer));- post.add(new StringPart("filter", filter));- post.add(new StringPart("ttl", "0"));- post.add(new StringPart("maxdist", Integer.toString(maxDistance)));- post.add(new StringPart("profile", crypt.simpleEncode(rankingProfile.toExternalString())));- post.add(new StringPart("constraint", (constraint == null) ? "" : constraint.exportB64()));- if (abstractCache != null) post.add(new StringPart("abstracts", "auto"));+ post.add(new DefaultCharsetStringPart("myseed", mySeed.genSeedStr(salt)));+ post.add(new DefaultCharsetStringPart("count", Integer.toString(Math.max(10, count))));+ post.add(new DefaultCharsetStringPart("resource", ((global) ? "global" : "local")));+ post.add(new DefaultCharsetStringPart("partitions", Integer.toString(partitions)));+ post.add(new DefaultCharsetStringPart("query", wordhashes));+ post.add(new DefaultCharsetStringPart("exclude", excludehashes));+ post.add(new DefaultCharsetStringPart("duetime", "1000"));+ post.add(new DefaultCharsetStringPart("urls", urlhashes));+ post.add(new DefaultCharsetStringPart("prefer", prefer));+ post.add(new DefaultCharsetStringPart("filter", filter));+ post.add(new DefaultCharsetStringPart("ttl", "0"));+ post.add(new DefaultCharsetStringPart("maxdist", Integer.toString(maxDistance)));+ post.add(new DefaultCharsetStringPart("profile", crypt.simpleEncode(rankingProfile.toExternalString())));+ post.add(new DefaultCharsetStringPart("constraint", (constraint == null) ? "" : constraint.exportB64()));+ if (abstractCache != null) post.add(new DefaultCharsetStringPart("abstracts", "auto"));final long timestamp = System.currentTimeMillis();// send request@@ -662,7 +666,7 @@ public final class yacyClient {// prepare requestfinal String salt = crypt.randomSalt();final List<Part> post = yacyNetwork.basicRequestPost(plasmaSwitchboard.getSwitchboard(), targetHash, salt);- post.add(new StringPart("process", "permission"));+ post.add(new DefaultCharsetStringPart("process", "permission"));// send requesttry {@@ -682,13 +686,13 @@ public final class yacyClient {// prepare requestfinal String salt = crypt.randomSalt();final List<Part> post = yacyNetwork.basicRequestPost(plasmaSwitchboard.getSwitchboard(), targetHash, salt);- post.add(new StringPart("process", "post"));- post.add(new StringPart("myseed", seedDB.mySeed().genSeedStr(salt)));- post.add(new StringPart("subject", subject));+ post.add(new DefaultCharsetStringPart("process", "post"));+ post.add(new DefaultCharsetStringPart("myseed", seedDB.mySeed().genSeedStr(salt)));+ post.add(new DefaultCharsetStringPart("subject", subject));try {- post.add(new StringPart("message", new String(message, "UTF-8")));+ post.add(new DefaultCharsetStringPart("message", new String(message, "UTF-8")));} catch (final UnsupportedEncodingException e) {- post.add(new StringPart("message", new String(message)));+ post.add(new DefaultCharsetStringPart("message", new String(message)));}// send request@@ -721,11 +725,11 @@ public final class yacyClient {// prepare requestfinal String salt = crypt.randomSalt();final List<Part> post = yacyNetwork.basicRequestPost(plasmaSwitchboard.getSwitchboard(), null, salt);- post.add(new StringPart("process", "permission"));- post.add(new StringPart("purpose", "crcon"));- post.add(new StringPart("filename", filename));- post.add(new StringPart("filesize", Long.toString(filesize)));- post.add(new StringPart("can-send-protocol", "http"));+ post.add(new DefaultCharsetStringPart("process", "permission"));+ post.add(new DefaultCharsetStringPart("purpose", "crcon"));+ post.add(new DefaultCharsetStringPart("filename", filename));+ post.add(new DefaultCharsetStringPart("filesize", Long.toString(filesize)));+ post.add(new DefaultCharsetStringPart("can-send-protocol", "http"));// send requesttry {@@ -744,12 +748,12 @@ public final class yacyClient {// prepare requestfinal String salt = crypt.randomSalt();final List<Part> post = yacyNetwork.basicRequestPost(plasmaSwitchboard.getSwitchboard(), null, salt);- post.add(new StringPart("process", "store"));- post.add(new StringPart("purpose", "crcon"));- post.add(new StringPart("filesize", Long.toString(file.length)));- post.add(new StringPart("md5", serverCodings.encodeMD5Hex(file)));- post.add(new StringPart("access", access));- post.add(new FilePart("filename", new ByteArrayPartSource(filename, file)));+ post.add(new DefaultCharsetStringPart("process", "store"));+ post.add(new DefaultCharsetStringPart("purpose", "crcon"));+ post.add(new DefaultCharsetStringPart("filesize", Long.toString(file.length)));+ post.add(new DefaultCharsetStringPart("md5", serverCodings.encodeMD5Hex(file)));+ post.add(new DefaultCharsetStringPart("access", access));+ post.add(new DefaultCharsetFilePart("filename", new ByteArrayPartSource(filename, file)));// send requesttry {@@ -815,12 +819,12 @@ public final class yacyClient {// prepare requestfinal String salt = crypt.randomSalt();final List<Part> post = yacyNetwork.basicRequestPost(plasmaSwitchboard.getSwitchboard(), target.hash, salt);- post.add(new StringPart("process", process));- post.add(new StringPart("urlhash", ((entry == null) ? "" : entry.hash())));- post.add(new StringPart("result", result));- post.add(new StringPart("reason", reason));- post.add(new StringPart("wordh", wordhashes));- post.add(new StringPart("lurlEntry", ((entry == null) ? "" : crypt.simpleEncode(entry.toString(), salt))));+ post.add(new DefaultCharsetStringPart("process", process));+ post.add(new DefaultCharsetStringPart("urlhash", ((entry == null) ? "" : entry.hash())));+ post.add(new DefaultCharsetStringPart("result", result));+ post.add(new DefaultCharsetStringPart("reason", reason));+ post.add(new DefaultCharsetStringPart("wordh", wordhashes));+ post.add(new DefaultCharsetStringPart("lurlEntry", ((entry == null) ? "" : crypt.simpleEncode(entry.toString(), salt))));// determining target addressfinal String address = target.getClusterAddress();@@ -929,7 +933,7 @@ public final class yacyClient {private static HashMap<String, String> transferRWI(final yacySeedDB seedDB, final yacySeed targetSeed, final indexContainer[] indexes, boolean gzipBody, final int timeout) {final String address = targetSeed.getPublicAddress();- if (address == null) { return null; }+ if (address == null) { yacyCore.log.logWarning("no address for transferRWI"); return null; }// prepare post valuesfinal String salt = crypt.randomSalt();@@ -939,7 +943,7 @@ public final class yacyClient {if (gzipBody && (targetSeed.getVersion() < yacyVersion.YACY_SUPPORTS_GZIP_POST_REQUESTS_CHUNKED)) {gzipBody = false;}- post.add(new StringPart("wordc", Integer.toString(indexes.length)));+ post.add(new DefaultCharsetStringPart("wordc", Integer.toString(indexes.length)));int indexcount = 0;final StringBuffer entrypost = new StringBuffer(indexes.length*73);@@ -964,8 +968,8 @@ public final class yacyClient {return result;}- post.add(new StringPart("entryc", Integer.toString(indexcount)));- post.add(new StringPart("indexes", entrypost.toString()));+ post.add(new DefaultCharsetStringPart("entryc", Integer.toString(indexcount)));+ post.add(new DefaultCharsetStringPart("indexes", entrypost.toString()));try {final byte[] content = wput("http://" + address + "/yacy/transferRWI.html", targetSeed.getHexHash() + ".yacyh", post, timeout, gzipBody);final ArrayList<String> v = nxTools.strings(content, "UTF-8");@@ -1005,13 +1009,13 @@ public final class yacyClient {if (urls[i] != null) {resource = urls[i].toString();if (resource != null) {- post.add(new StringPart("url" + urlc, resource));+ post.add(new DefaultCharsetStringPart("url" + urlc, resource));urlPayloadSize += resource.length();urlc++;}}}- post.add(new StringPart("urlc", Integer.toString(urlc)));+ post.add(new DefaultCharsetStringPart("urlc", Integer.toString(urlc)));try {final byte[] content = wput("http://" + address + "/yacy/transferURL.html", targetSeed.getHexHash() + ".yacyh", post, timeout, gzipBody);final ArrayList<String> v = nxTools.strings(content, "UTF-8");@@ -1052,7 +1056,7 @@ public final class yacyClient {* @return*/private static final httpRemoteProxyConfig proxyConfig() {- final httpRemoteProxyConfig p = httpdProxyHandler.getRemoteProxyConfig();+ final httpRemoteProxyConfig p = httpRemoteProxyConfig.getRemoteProxyConfig();return ((p != null) && (p.useProxy()) && (p.useProxy4Yacy())) ? p : null;}@@ -1100,11 +1104,11 @@ public final class yacyClient {}final String vhost = url.getHost();final int timeout = 10000;- final boolean gzipBody = true;+ final boolean gzipBody = false;// datafinal List<Part> post = new ArrayList<Part>();- post.add(new StringPart("process", "permission"));- post.add(new StringPart("purpose", "crcon"));+ post.add(new DefaultCharsetStringPart("process", "permission"));+ post.add(new DefaultCharsetStringPart("purpose", "crcon"));//post.add(new FilePart("filename", new ByteArrayPartSource(filename, file)));// do it!try {diff --git a/source/de/anomic/yacy/yacyCore.java b/source/de/anomic/yacy/yacyCore.javaindex 08ec291d4..470be15dd 100644--- a/source/de/anomic/yacy/yacyCore.java+++ b/source/de/anomic/yacy/yacyCore.java@@ -104,7 +104,7 @@ public class yacyCore {if (staticIP.length() != 0 && yacySeed.isProperIP(staticIP) == null) {serverCore.useStaticIP = true;sb.webIndex.seedDB.mySeed().setIP(staticIP);- System.out.println("+-+ DEBUG staticIP set to "+ staticIP);+ log.logInfo("staticIP set to "+ staticIP);} else {serverCore.useStaticIP = false;}diff --git a/source/de/anomic/yacy/yacyDHTAction.java b/source/de/anomic/yacy/yacyDHTAction.javaindex 6109ce27e..f511d273e 100644--- a/source/de/anomic/yacy/yacyDHTAction.java+++ b/source/de/anomic/yacy/yacyDHTAction.java@@ -89,20 +89,21 @@ public class yacyDHTAction {public yacySeed next() {if (steps == 0) return null;steps--;- if ((e1 != null) && (e1.hasNext())) {- final yacySeed n = e1.next();- if (!(e1.hasNext())) {- e1 = null;- e2 = seedDB.seedsConnected(up, false, null, minVersion);- }- return n;- } else {++ if (e1 == null || !e1.hasNext()) {if (e2 == null) {e1 = null;e2 = seedDB.seedsConnected(up, false, null, minVersion);}return e2.next();}++ final yacySeed n = e1.next();+ if (!(e1.hasNext())) {+ e1 = null;+ e2 = seedDB.seedsConnected(up, false, null, minVersion);+ }+ return n;}public void remove() {@@ -313,9 +314,8 @@ public class yacyDHTAction {final double d = hashDistance(peer, word);if (d > 0) {return d; // case where the word is 'before' the peer- } else {- return (1) + d; // wrap-around case}+ return 1 + d; // wrap-around case}private static double hashDistance(final String from, final String to) {diff --git a/source/de/anomic/yacy/yacyNetwork.java b/source/de/anomic/yacy/yacyNetwork.javaindex 2f3fab19f..7d366a91d 100644--- a/source/de/anomic/yacy/yacyNetwork.java+++ b/source/de/anomic/yacy/yacyNetwork.java@@ -32,8 +32,8 @@ import java.util.Date;import java.util.List;import org.apache.commons.httpclient.methods.multipart.Part;-import org.apache.commons.httpclient.methods.multipart.StringPart;+import de.anomic.http.DefaultCharsetStringPart;import de.anomic.plasma.plasmaSwitchboard;import de.anomic.server.serverCodings;import de.anomic.server.serverDate;@@ -75,18 +75,18 @@ public class yacyNetwork {// put in all the essentials for routing and network authentification// generate a session keyfinal ArrayList<Part> post = new ArrayList<Part>();- post.add(new StringPart("key", salt));+ post.add(new DefaultCharsetStringPart("key", salt));// just standard identification essentials- post.add(new StringPart("iam", sb.webIndex.seedDB.mySeed().hash));- if (targetHash != null) post.add(new StringPart("youare", targetHash));+ post.add(new DefaultCharsetStringPart("iam", sb.webIndex.seedDB.mySeed().hash));+ if (targetHash != null) post.add(new DefaultCharsetStringPart("youare", targetHash));// time information for synchronization- post.add(new StringPart("mytime", serverDate.formatShortSecond(new Date())));- post.add(new StringPart("myUTC", Long.toString(System.currentTimeMillis())));+ post.add(new DefaultCharsetStringPart("mytime", serverDate.formatShortSecond(new Date())));+ post.add(new DefaultCharsetStringPart("myUTC", Long.toString(System.currentTimeMillis())));// network identification- post.add(new StringPart("network.unit.name", plasmaSwitchboard.getSwitchboard().getConfig("network.unit.name", yacySeed.DFLT_NETWORK_UNIT)));+ post.add(new DefaultCharsetStringPart("network.unit.name", plasmaSwitchboard.getSwitchboard().getConfig("network.unit.name", yacySeed.DFLT_NETWORK_UNIT)));// authentification essentialsfinal String authentificationControl = sb.getConfig("network.unit.protocol.control", "uncontrolled");@@ -96,7 +96,7 @@ public class yacyNetwork {// generate an authentification essential using the salt, the iam-hash and the network magicfinal String magic = sb.getConfig("network.unit.protocol.request.authentification.essentials", "");final String md5 = serverCodings.encodeMD5Hex(salt + sb.webIndex.seedDB.mySeed().hash + magic);- post.add(new StringPart("magicmd5", md5));+ post.add(new DefaultCharsetStringPart("magicmd5", md5));}}diff --git a/source/de/anomic/yacy/yacyPeerActions.java b/source/de/anomic/yacy/yacyPeerActions.javaindex e4d4a91ae..5c122999a 100644--- a/source/de/anomic/yacy/yacyPeerActions.java+++ b/source/de/anomic/yacy/yacyPeerActions.java@@ -152,42 +152,41 @@ public class yacyPeerActions {yacyCore.log.logFine("connect: returned KNOWN " + peerType + " peer '" + seed.getName() + "' from " + seed.getPublicAddress());this.seedDB.addConnected(seed);return true;- } else {- final yacySeed connectedSeed = this.seedDB.getConnected(seed.hash);- if (connectedSeed != null) {- // the seed is known: this is an update- try {- // if the old LastSeen date is later then the other- // info, then we reject the info- if ((ctimeUTC0 < (connectedSeed.getLastSeenUTC())) && (!direct)) {- yacyCore.log.logFine("connect: rejecting old info about peer '" + seed.getName() + "'");- return false;- }-- /*if (connectedSeed.getName() != seed.getName()) {- // TODO: update seed name lookup cache- }*/- } catch (final NumberFormatException e) {- yacyCore.log.logFine("connect: rejecting wrong peer '" + seed.getName() + "' from " + seed.getPublicAddress() + ". Cause: " + e.getMessage());+ }+ final yacySeed connectedSeed = this.seedDB.getConnected(seed.hash);+ if (connectedSeed != null) {+ // the seed is known: this is an update+ try {+ // if the old LastSeen date is later then the other+ // info, then we reject the info+ if ((ctimeUTC0 < (connectedSeed.getLastSeenUTC())) && (!direct)) {+ yacyCore.log.logFine("connect: rejecting old info about peer '" + seed.getName() + "'");return false;}- yacyCore.log.logFine("connect: updated KNOWN " + ((direct) ? "direct " : "") + peerType + " peer '" + seed.getName() + "' from " + seed.getPublicAddress());- seedDB.addConnected(seed);- return true;- } else {- // the seed is new- if ((seedDB.mySeedIsDefined()) && (seed.getIP().equals(this.seedDB.mySeed().getIP()))) {- // seed from the same IP as the calling client: can be- // the case if there runs another one over a NAT- yacyCore.log.logFine("connect: saved NEW seed (myself IP) " + seed.getPublicAddress());- } else {- // completely new seed- yacyCore.log.logFine("connect: saved NEW " + peerType + " peer '" + seed.getName() + "' from " + seed.getPublicAddress());- }- this.seedDB.addConnected(seed);- return true;++ /*if (connectedSeed.getName() != seed.getName()) {+ // TODO: update seed name lookup cache+ }*/+ } catch (final NumberFormatException e) {+ yacyCore.log.logFine("connect: rejecting wrong peer '" + seed.getName() + "' from " + seed.getPublicAddress() + ". Cause: " + e.getMessage());+ return false;}+ yacyCore.log.logFine("connect: updated KNOWN " + ((direct) ? "direct " : "") + peerType + " peer '" + seed.getName() + "' from " + seed.getPublicAddress());+ seedDB.addConnected(seed);+ return true;+ }++ // the seed is new+ if ((seedDB.mySeedIsDefined()) && (seed.getIP().equals(this.seedDB.mySeed().getIP()))) {+ // seed from the same IP as the calling client: can be+ // the case if there runs another one over a NAT+ yacyCore.log.logFine("connect: saved NEW seed (myself IP) " + seed.getPublicAddress());+ } else {+ // completely new seed+ yacyCore.log.logFine("connect: saved NEW " + peerType + " peer '" + seed.getName() + "' from " + seed.getPublicAddress());}+ this.seedDB.addConnected(seed);+ return true;}public boolean peerArrival(final yacySeed peer, final boolean direct) {diff --git a/source/de/anomic/yacy/yacySeed.java b/source/de/anomic/yacy/yacySeed.javaindex 6a4e71529..4d507eb40 100644--- a/source/de/anomic/yacy/yacySeed.java+++ b/source/de/anomic/yacy/yacySeed.java@@ -58,14 +58,13 @@ import de.anomic.index.indexWord;import de.anomic.kelondro.kelondroBase64Order;import de.anomic.net.natLib;import de.anomic.server.serverCodings;-import de.anomic.server.serverCore;import de.anomic.server.serverDate;import de.anomic.server.serverDomains;import de.anomic.server.serverSystem;import de.anomic.tools.bitfield;import de.anomic.tools.crypt;-public class yacySeed {+public class yacySeed implements Cloneable {public static final int maxsize = 4096;/**@@ -252,9 +251,9 @@ public class yacySeed {* @param name* @return a checked name without "<" and ">"*/- private static String checkPeerName(final String name) {- name.replaceAll("<", "_");- name.replaceAll(">", "_");+ private static String checkPeerName(String name) {+ name = name.replaceAll("<", "_");+ name = name.replaceAll(">", "_");return name;}diff --git a/source/de/anomic/yacy/yacyTray.java b/source/de/anomic/yacy/yacyTray.javaindex 781bdb95c..0ab0ef12d 100644--- a/source/de/anomic/yacy/yacyTray.java+++ b/source/de/anomic/yacy/yacyTray.java@@ -118,7 +118,7 @@ public class yacyTray implements ActionListener, ItemListener {isShown = true;}- private void trayClickAction(){ //detect doubleclick+ void trayClickAction(){ //detect doubleclickif(System.currentTimeMillis() - t1 < 500){if (lockBrowserPopup) {displayBalloonMessage("YaCy","Please wait until YaCy is started.");@@ -129,7 +129,7 @@ public class yacyTray implements ActionListener, ItemListener {} else { t1 = System.currentTimeMillis(); }}- private void openBrowser(final String browserPopUpPage){+ void openBrowser(final String browserPopUpPage){// no need for https, because we are on localhostserverSystem.openBrowser("http://localhost:" + sb.getConfig("port", "8080") + "/" + browserPopUpPage);}diff --git a/source/de/anomic/yacy/yacyURL.java b/source/de/anomic/yacy/yacyURL.javaindex 016b5a176..e17c65fcb 100644--- a/source/de/anomic/yacy/yacyURL.java+++ b/source/de/anomic/yacy/yacyURL.java@@ -110,14 +110,13 @@ public class yacyURL implements Serializable {final int q = url.indexOf('@', p + 3);if (q < 0) {throw new MalformedURLException("wrong email address: " + url);- } else {- userInfo = url.substring(p + 1, q);- host = url.substring(q + 1);- path = null;- port = -1;- quest = null;- ref = null;}+ userInfo = url.substring(p + 1, q);+ host = url.substring(q + 1);+ path = null;+ port = -1;+ quest = null;+ ref = null;} else {throw new MalformedURLException("unknown protocol: " + url);}@@ -151,9 +150,8 @@ public class yacyURL implements Serializable {(relPath.startsWith("file://")) ||(relPath.startsWith("smb://"))) {return new yacyURL(relPath, null);- } else {- return new yacyURL(new yacyURL(baseURL, null), relPath);}+ return new yacyURL(new yacyURL(baseURL, null), relPath);}public static yacyURL newURL(final yacyURL baseURL, final String relPath) throws MalformedURLException {@@ -164,9 +162,8 @@ public class yacyURL implements Serializable {(relPath.startsWith("file://")) ||(relPath.startsWith("smb://"))) {return new yacyURL(relPath, null);- } else {- return new yacyURL(baseURL, relPath);}+ return new yacyURL(baseURL, relPath);}private yacyURL(final yacyURL baseURL, String relPath) throws MalformedURLException {@@ -197,9 +194,8 @@ public class yacyURL implements Serializable {} else if (baseURL.path.endsWith("/")) {if (relPath.startsWith("#") || relPath.startsWith("?")) {throw new MalformedURLException("relative path malformed: " + relPath);- } else {- this.path = baseURL.path + relPath;}+ this.path = baseURL.path + relPath;} else {if (relPath.startsWith("#") || relPath.startsWith("?")) {this.path = baseURL.path + relPath;@@ -538,10 +534,11 @@ public class yacyURL implements Serializable {}public String toNormalform(final boolean stripReference, final boolean stripAmp) {- if (stripAmp)- return toNormalform(!stripReference).replaceAll("&", "&");- else- return toNormalform(!stripReference);+ String result = toNormalform(!stripReference);+ if (stripAmp) {+ result = result.replaceAll("&", "&");+ }+ return result;}private String toNormalform(final boolean includeReference) {@@ -568,14 +565,18 @@ public class yacyURL implements Serializable {this.getHost().toLowerCase() + ((defaultPort) ? ("") : (":" + this.port)) + path;}- public boolean equals(final yacyURL other) {- return (((this.protocol == other.protocol) || (this.protocol.equals(other.protocol))) &&- ((this.host == other.host ) || (this.host.equals(other.host))) &&- ((this.userInfo == other.userInfo) || (this.userInfo.equals(other.userInfo))) &&- ((this.path == other.path ) || (this.path.equals(other.path))) &&- ((this.quest == other.quest ) || (this.quest.equals(other.quest))) &&- ((this.ref == other.ref ) || (this.ref.equals(other.ref))) &&- ((this.port == other.port )));+ public boolean equals(final Object other) {+ if(other != null && other instanceof yacyURL) {+ final yacyURL otherURL = (yacyURL) other;+ return (((this.protocol == otherURL.protocol) || (this.protocol.equals(otherURL.protocol))) &&+ ((this.host == otherURL.host ) || (this.host.equals(otherURL.host))) &&+ ((this.userInfo == otherURL.userInfo) || (this.userInfo.equals(otherURL.userInfo))) &&+ ((this.path == otherURL.path ) || (this.path.equals(otherURL.path))) &&+ ((this.quest == otherURL.quest ) || (this.quest.equals(otherURL.quest))) &&+ ((this.ref == otherURL.ref ) || (this.ref.equals(otherURL.ref))) &&+ ((this.port == otherURL.port )));+ }+ return super.equals(other);}/**diff --git a/source/de/anomic/yacy/yacyVersion.java b/source/de/anomic/yacy/yacyVersion.javaindex d54d7729b..651d530b7 100644--- a/source/de/anomic/yacy/yacyVersion.java+++ b/source/de/anomic/yacy/yacyVersion.java@@ -71,7 +71,7 @@ public final class yacyVersion implements Comparator<yacyVersion>, Comparable<ya// this static information should be overwritten by network-specific locations// for details see defaults/yacy.network.freeworld.unitprivate static HashMap<yacyURL, DevMain> latestReleases = new HashMap<yacyURL, DevMain>();- public static ArrayList<yacyURL> latestReleaseLocations = new ArrayList<yacyURL>(); // will be initialized with value in defaults/yacy.network.freeworld.unit+ public final static ArrayList<yacyURL> latestReleaseLocations = new ArrayList<yacyURL>(); // will be initialized with value in defaults/yacy.network.freeworld.unit// private static release info about this release; is generated only once and can be retrieved by thisVersion()private static yacyVersion thisVersion = null;@@ -160,9 +160,8 @@ public final class yacyVersion implements Comparator<yacyVersion>, Comparable<yaif(obj instanceof yacyVersion) {final yacyVersion v = (yacyVersion) obj;return (this.svn == v.svn) && (this.url.toNormalform(true, true).equals(v.url.toNormalform(true, true)));- } else {- return false;}+ return false;}public int hashCode() {@@ -225,14 +224,13 @@ public final class yacyVersion implements Comparator<yacyVersion>, Comparable<ya((latestmain == null) || (latestdev.compareTo(latestmain) > 0)) &&(!(Float.toString(latestdev.releaseNr).matches(blacklist)))) {// consider a dev-release- if (latestdev.compareTo(thisVersion()) > 0) {- return latestdev;- } else {+ if (latestdev.compareTo(thisVersion()) <= 0) {yacyCore.log.logInfo("rulebasedUpdateInfo: latest dev " + latestdev.name +" is not more recent than installed release " + thisVersion().name);return null;}+ return latestdev;}if (latestmain != null) {// consider a main release@@ -242,12 +240,13 @@ public final class yacyVersion implements Comparator<yacyVersion>, Comparable<ya" matches with blacklist '" + blacklist + "'");return null;}- if (latestmain.compareTo(thisVersion()) > 0) return latestmain; else {+ if (latestmain.compareTo(thisVersion()) <= 0) {yacyCore.log.logInfo("rulebasedUpdateInfo: latest main " + latestmain.name +" is not more recent than installed release (1) " + thisVersion().name);return null;}+ return latestmain;}}if ((concept.equals("main")) && (latestmain != null)) {@@ -258,12 +257,13 @@ public final class yacyVersion implements Comparator<yacyVersion>, Comparable<ya" matches with blacklist'" + blacklist + "'");return null;}- if (latestmain.compareTo(thisVersion()) > 0) return latestmain; else {+ if (latestmain.compareTo(thisVersion()) <= 0) {yacyCore.log.logInfo("rulebasedUpdateInfo: latest main " + latestmain.name +" is not more recent than installed release (2) " + thisVersion().name);return null;}+ return latestmain;}yacyCore.log.logInfo("rulebasedUpdateInfo: failed to find more recent release");return null;diff --git a/source/de/anomic/ymage/ymageBMPParser.java b/source/de/anomic/ymage/ymageBMPParser.javaindex 002fbf580..01192afc3 100644--- a/source/de/anomic/ymage/ymageBMPParser.java+++ b/source/de/anomic/ymage/ymageBMPParser.java@@ -240,7 +240,8 @@ public class ymageBMPParser {private final int fill4(final int x) {final int r = x % 4;- if (r == 0) return 0; else return 4 - r;+ if (r == 0) return 0;+ return 4 - r;}}diff --git a/source/migration.java b/source/migration.javaindex bd68fac6f..07ed6ee48 100644--- a/source/migration.java+++ b/source/migration.java@@ -25,6 +25,7 @@ import de.anomic.data.listManager;import de.anomic.http.httpd;import de.anomic.kelondro.kelondroBase64Order;import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.plasma.plasmaSwitchboardConstants;import de.anomic.server.serverFileUtils;import de.anomic.server.logging.serverLog;@@ -95,7 +96,7 @@ public class migration {}final File skinsDir=sb.getConfigPath("skinPath", "DATA/SKINS");final File skinFile=new File(skinsDir, skin+".css");- final File htdocsPath=new File(sb.getConfigPath(plasmaSwitchboard.HTDOCS_PATH, plasmaSwitchboard.HTROOT_PATH_DEFAULT), "env");+ final File htdocsPath=new File(sb.getConfigPath(plasmaSwitchboardConstants.HTDOCS_PATH, plasmaSwitchboardConstants.HTROOT_PATH_DEFAULT), "env");final File styleFile=new File(htdocsPath, "style.css");if(!skinFile.exists()){if(styleFile.exists()){diff --git a/source/yacy.java b/source/yacy.javaindex 4ba4e39d7..7c702601c 100644--- a/source/yacy.java+++ b/source/yacy.java@@ -65,6 +65,7 @@ import de.anomic.kelondro.kelondroMScoreCluster;import de.anomic.kelondro.kelondroMapDataMining;import de.anomic.kelondro.kelondroRowCollection;import de.anomic.plasma.plasmaSwitchboard;+import de.anomic.plasma.plasmaSwitchboardConstants;import de.anomic.plasma.plasmaWordIndex;import de.anomic.server.serverCore;import de.anomic.server.serverDate;@@ -268,7 +269,7 @@ public final class yacy {// create some directoriesfinal File htRootPath = new File(homePath, sb.getConfig("htRootPath", "htroot"));- final File htDocsPath = sb.getConfigPath(plasmaSwitchboard.HTDOCS_PATH, plasmaSwitchboard.HTDOCS_PATH_DEFAULT);+ final File htDocsPath = sb.getConfigPath(plasmaSwitchboardConstants.HTDOCS_PATH, plasmaSwitchboardConstants.HTDOCS_PATH_DEFAULT);if (!(htDocsPath.exists())) htDocsPath.mkdir();//final File htTemplatePath = new File(homePath, sb.getConfig("htTemplatePath","htdocs"));