Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
introduced citation-rank transmission protocol and activate transport for anonymisation
orbiter79818a320f61
diff --git a/build.properties b/build.propertiesindex c881df280..ec0c487d3 100644--- a/build.properties+++ b/build.properties@@ -3,7 +3,7 @@ javacSource=1.4javacTarget=1.4# Release Configuration-releaseVersion=0.413+releaseVersion=0.414releaseFile=yacy_dev_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gz#releaseFile=yacy_v${releaseVersion}_${DSTAMP}_${releaseNr}.tar.gzreleaseDir=yacy_dev_v${releaseVersion}_${DSTAMP}_${releaseNr}diff --git a/htroot/CacheAdmin_p.java b/htroot/CacheAdmin_p.javaindex 6380b5ee4..e1af6c413 100644--- a/htroot/CacheAdmin_p.java+++ b/htroot/CacheAdmin_p.java@@ -106,7 +106,7 @@ public class CacheAdmin_p {final TreeSet fList = new TreeSet();File object;int size = list.length - 1;- for (int i = size; i >= 0 ; i--) { // R�ckw�rts ist schneller+ for (int i = size; i >= 0 ; i--) { // Rueckwaerts ist schnellerobject = new File(dir, list[i]);if (!object.getName().equalsIgnoreCase("responseHeader.db")) {if (object.isDirectory()) {diff --git a/htroot/Network.html b/htroot/Network.htmlindex ed9444473..629030f5a 100644--- a/htroot/Network.html+++ b/htroot/Network.html@@ -47,6 +47,7 @@<td class="small"><b>Uptime</b><br> <a href="/Network.html?page=#[page]#&sort=Uptime&order=up"><</a> <a href="/Network.html?page=#[page]#&sort=Uptime&order=down">></a></td><td class="small"><b>#Links</b><br> <a href="/Network.html?page=#[page]#&sort=LCount&order=up"><</a> <a href="/Network.html?page=#[page]#&sort=LCount&order=down">></a></td><td class="small"><b>#RWIs</b><br> <a href="/Network.html?page=#[page]#&sort=ICount&order=up"><</a> <a href="/Network.html?page=#[page]#&sort=ICount&order=down">></a></td>+<td class="small"><b>#CR-<br>Files</b><br>Own/Other</td><td class="small"><b>Sent<br>Words</b><br> </td><td class="small"><b>Sent<br>URLs</b><br> </td><td class="small"><b>Received<br>Words</b><br> </td>@@ -68,13 +69,14 @@</td><td class="small"><a href="http://www.#[fullname]#.yacy" class="small">#[shortname]#</a></td><td class="small">-#(type)##(direct)#<img border="0" src="/env/grafics/JuniorPassive.gif" title="Type: Junior | Contact: passive"></img>::<img border="0" src="/env/grafics/JuniorDirect.gif" title="Type: Junior | Contact: direct"></img>::<img border="0" src="/env/grafics/JuniorOffline.gif" title="Type: Junior | Contact: offline"></img>#(/direct)#::#(direct)#<img border="0" src="/env/grafics/SeniorPassive.gif" title="Type: Senior | Contact: passive"></img>::<img border="0" src="/env/grafics/SeniorDirect.gif" title="Type: Senior | Contact: direct"></img>::<img border="0" src="/env/grafics/SeniorOffline.gif" title="Type: Senior | Contact: offline"></img>#(/direct)#::<a href="#[url]#">#(direct)#<img border="0" src="/env/grafics/PrincipalPassive.gif" title="Type: Principal | Contact: passive | Seed download: possible"></img>::<img border="0" src="/env/grafics/PrincipalDirect.gif" title="Type: Principal | Contact: direct | Seed download: possible"></img>::<img border="0" src="/env/grafics/PrincipalOffline.gif" title="Type: Principal | Contact: offline | Seed download: ?"></img>#(/direct)#</a>#(/type)##(acceptcrawl)#<img border="0" src="/env/grafics/CrawlNo.gif" title="Accept Crawl: no"></img>::<img border="0" src="/env/grafics/CrawlYes.gif" title="Accept Crawl: yes"></img>::<img border="0" src="/env/grafics/CrawlYesOffline.gif" title="Accept Crawl: yes"></img>#(/acceptcrawl)##(dhtreceive)#<img border="0" src="/env/grafics/DHTReceiveNo.gif" title="DHT Receive: no"></img>::<img border="0" src="/env/grafics/DHTReceiveYes.gif" title="DHT Receive: yes"></img>::<img border="0" src="/env/grafics/DHTReceiveYesOffline.gif" title="DHT Receive: yes"></img>#(/dhtreceive)#</td>+#(type)##(direct)#<img border="0" src="/env/grafics/JuniorPassive.gif" title="Type: Junior | Contact: passive"></img>::<img border="0" src="/env/grafics/JuniorDirect.gif" title="Type: Junior | Contact: direct"></img>::<img border="0" src="/env/grafics/JuniorOffline.gif" title="Type: Junior | Contact: offline"></img>#(/direct)#::#(direct)#<img border="0" src="/env/grafics/SeniorPassive.gif" title="Type: Senior | Contact: passive"></img>::<img border="0" src="/env/grafics/SeniorDirect.gif" title="Type: Senior | Contact: direct"></img>::<img border="0" src="/env/grafics/SeniorOffline.gif" title="Type: Senior | Contact: offline"></img>#(/direct)#::<a href="#[url]#">#(direct)#<img border="0" src="/env/grafics/PrincipalPassive.gif" title="Type: Principal | Contact: passive | Seed download: possible"></img>::<img border="0" src="/env/grafics/PrincipalDirect.gif" title="Type: Principal | Contact: direct | Seed download: possible"></img>::<img border="0" src="/env/grafics/PrincipalOffline.gif" title="Type: Principal | Contact: offline | Seed download: ?"></img>#(/direct)#</a>#(/type)##(acceptcrawl)#<img border="0" src="/env/grafics/CrawlNo.gif" title="Accept Crawl: no"></img>::<img border="0" src="/env/grafics/CrawlYes.gif" title="Accept Crawl: yes"></img>::<img border="0" src="/env/grafics/CrawlYesOffline.gif" title="Accept Crawl: yes"></img>#(/acceptcrawl)##(dhtreceive)#<img border="0" src="/env/grafics/DHTReceiveNo.gif" title="DHT Receive: no"></img>::<img border="0" src="/env/grafics/DHTReceiveYes.gif" title="DHT Receive: yes"></img>::<img border="0" src="/env/grafics/DHTReceiveYesOffline.gif" title="DHT Receive: yes"></img>#(/dhtreceive)##(rankingreceive)#<img border="0" src="/env/grafics/RankingReceiveNo.gif" title="Ranking Receive: no"></img>::<img border="0" src="/env/grafics/RankingReceiveYes.gif" title="Ranking Receive: yes"></img>::<img border="0" src="/env/grafics/RankingCollects.gif" title="Ranking Receive: collection"></img>#(/rankingreceive)#</td><td class="small" align="right">#[version]#</td><td class="small" align="right">#[lastSeen]#</td><td class="small" align="right">#[utc]#</td><td class="small" align="right"><NOBR>#[uptime]#</NOBR></td><td class="small" align="right">#[links]#</td><td class="small" align="right">#[words]#</td>+<td class="small" align="center">#[CRWCnt]#/#[CRTCnt]#</td><td class="small" align="right">#[sI]#</td><td class="small" align="right">#[sU]#</td><td class="small" align="right">#[rI]#</td>@@ -210,4 +212,4 @@ To do this, press this button:#[footer]#</body>-</html>\ No newline at end of file+</html>diff --git a/htroot/Network.java b/htroot/Network.javaindex 183782439..55072236d 100644--- a/htroot/Network.java+++ b/htroot/Network.java@@ -59,6 +59,7 @@ import de.anomic.yacy.yacyCore;import de.anomic.yacy.yacySeed;import de.anomic.yacy.yacyNewsRecord;import de.anomic.yacy.yacyNewsPool;+import de.anomic.yacy.yacyVersion;public class Network {@@ -338,6 +339,7 @@ public class Network {if (page == 1) {prop.put(STR_TABLE_LIST + conCount + "_acceptcrawl", seed.getFlagAcceptRemoteCrawl() ? 1 : 0); // green=on or red=offprop.put(STR_TABLE_LIST + conCount + "_dhtreceive", seed.getFlagAcceptRemoteIndex() ? 1 : 0); // green=on or red=off+ prop.put(STR_TABLE_LIST + conCount + "_rankingreceive", (seed.getVersion() >= yacyVersion.YACY_ACCEPTS_RANKING_TRANSMISSION) ? 1 : 0);} else { // Passive, Potential Peersif (seed.getFlagAcceptRemoteCrawl()) {prop.put(STR_TABLE_LIST + conCount + "_acceptcrawl", 2); // red/green: offline, was on@@ -349,6 +351,11 @@ public class Network {} else {prop.put(STR_TABLE_LIST + conCount + "_dhtreceive", 0); // red/red; offline was off}+ if (seed.getVersion() >= yacyVersion.YACY_ACCEPTS_RANKING_TRANSMISSION) {+ prop.put(STR_TABLE_LIST + conCount + "_rankingreceive", 1);+ } else {+ prop.put(STR_TABLE_LIST + conCount + "_rankingreceive", 0);+ }}prop.put(STR_TABLE_LIST + conCount + "_version", yacy.combinedVersionString2PrettyString(seed.get(yacySeed.VERSION, "0.1")));prop.put(STR_TABLE_LIST + conCount + "_lastSeen", lastseen);@@ -356,6 +363,8 @@ public class Network {prop.put(STR_TABLE_LIST + conCount + "_uptime", serverDate.intervalToString(60000 * Long.parseLong(seed.get(yacySeed.UPTIME, "0"))));prop.put(STR_TABLE_LIST + conCount + "_links", groupDigits(seed.get(yacySeed.LCOUNT, "0")));prop.put(STR_TABLE_LIST + conCount + "_words", groupDigits(seed.get(yacySeed.ICOUNT, "0")));+ prop.put(STR_TABLE_LIST + conCount + "_CRWCnt", seed.get(yacySeed.CRWCNT, "0"));+ prop.put(STR_TABLE_LIST + conCount + "_CRTCnt", seed.get(yacySeed.CRTCNT, "0"));prop.put(STR_TABLE_LIST + conCount + "_sI", groupDigits(seed.get(yacySeed.INDEX_OUT, "0")));prop.put(STR_TABLE_LIST + conCount + "_sU", groupDigits(seed.get(yacySeed.URL_OUT, "0")));prop.put(STR_TABLE_LIST + conCount + "_rI", groupDigits(seed.get(yacySeed.INDEX_IN, "0")));diff --git a/htroot/env/grafics/RankingNo.gif b/htroot/env/grafics/RankingReceiveNo.gifsimilarity index 100%rename from htroot/env/grafics/RankingNo.gifrename to htroot/env/grafics/RankingReceiveNo.gifdiff --git a/htroot/env/grafics/RankingYes.gif b/htroot/env/grafics/RankingReceiveYes.gifsimilarity index 100%rename from htroot/env/grafics/RankingYes.gifrename to htroot/env/grafics/RankingReceiveYes.gifdiff --git a/htroot/htdocsdefault/dir.java b/htroot/htdocsdefault/dir.javaindex 986ec781f..2c1468d81 100644--- a/htroot/htdocsdefault/dir.java+++ b/htroot/htdocsdefault/dir.java@@ -168,7 +168,7 @@ public class dir {if (pos >= 0) { filename = filename.substring(pos + 1); }final File newfile = new File(dir, filename);final File newfilemd5 = new File(dir, filename + ".md5");- final byte[] binary = (byte[]) post.get((Object) "file$file", (Object) new byte[0]);+ final byte[] binary = (byte[]) post.get("file$file", (Object) new byte[0]);try {serverFileUtils.write(binary, newfile);String md5s = serverCodings.encodeMD5Hex(newfile);diff --git a/source/de/anomic/htmlFilter/htmlFilterContentScraper.java b/source/de/anomic/htmlFilter/htmlFilterContentScraper.javaindex 9de8c2218..99d5661c9 100644--- a/source/de/anomic/htmlFilter/htmlFilterContentScraper.java+++ b/source/de/anomic/htmlFilter/htmlFilterContentScraper.java@@ -258,12 +258,13 @@ public class htmlFilterContentScraper extends htmlFilterAbstractScraper implemen}public static void main(String[] args) {- String test = "Nokia k�rzt bei Forschung und Entwicklung";+ /*try {htmlFilterContentScraper scraper = new htmlFilterContentScraper(new URL("http://localhost"));scraper.scrapeText(test.getBytes());System.out.println(new String(scraper.getText()));} catch (MalformedURLException e) {}+ */}}\ No newline at end of filediff --git a/source/de/anomic/http/httpc.java b/source/de/anomic/http/httpc.javaindex 0218e0032..f75f845fc 100644--- a/source/de/anomic/http/httpc.java+++ b/source/de/anomic/http/httpc.java@@ -1128,7 +1128,8 @@ do uploadboolean ssl,httpRemoteProxyConfig theRemoteProxyConfig,httpHeader requestHeader,- serverObjects props+ serverObjects props,+ HashMap files) throws IOException {if (requestHeader == null) requestHeader = new httpHeader();@@ -1143,7 +1144,7 @@ do upload} else {con = httpc.getInstance(host, port, timeout, ssl, theRemoteProxyConfig);}- httpc.response res = con.POST(path, requestHeader, props, null);+ httpc.response res = con.POST(path, requestHeader, props, files);//System.out.println("response=" + res.toString());if (res.status.startsWith("2")) {@@ -1164,7 +1165,8 @@ do uploadString user,String password,httpRemoteProxyConfig theRemoteProxyConfig,- serverObjects props+ serverObjects props,+ HashMap files) throws IOException {int port = u.getPort();boolean ssl = u.getProtocol().equals("https");@@ -1182,7 +1184,8 @@ do uploadssl,theRemoteProxyConfig,null,- props+ props,+ files);}@@ -1198,7 +1201,8 @@ do uploadnull,null,null,- props+ props,+ null);} catch (MalformedURLException e) {throw new IOException("Malformed URL: " + e.getMessage());@@ -1328,7 +1332,8 @@ do uploadString user,String password,httpRemoteProxyConfig theRemoteProxyConfig,- serverObjects props+ serverObjects props,+ HashMap files) throws IOException {// splitting of the byte array into linesbyte[] a = singlePOST(@@ -1337,7 +1342,8 @@ do uploaduser,password,theRemoteProxyConfig,- props+ props,+ files);//System.out.println("wput-out=" + new String(a));diff --git a/source/de/anomic/http/httpdFileHandler.java b/source/de/anomic/http/httpdFileHandler.javaindex d3dfd6999..d27394de0 100644--- a/source/de/anomic/http/httpdFileHandler.java+++ b/source/de/anomic/http/httpdFileHandler.java@@ -203,13 +203,6 @@ public final class httpdFileHandler extends httpdAbstractHandler implements http//htLocaleSelection = switchboard.getConfig("htLocaleSelection","default");}-------// initialise an message digest for Content-MD5 support ...try {this.md5Digest = MessageDigest.getInstance("MD5");diff --git a/source/de/anomic/net/natLib.java b/source/de/anomic/net/natLib.javaindex 82e0ebfb0..6b79b358c 100644--- a/source/de/anomic/net/natLib.java+++ b/source/de/anomic/net/natLib.java@@ -125,7 +125,8 @@ public class natLib {//TODO: This is not IPv6 compatiblepublic static boolean isProper(String ip) {plasmaSwitchboard sb=plasmaSwitchboard.getSwitchboard();- String yacyDebugMode = sb.getConfig("yacyDebugMode", "false");+ if (sb == null) return false;+ String yacyDebugMode = sb.getConfig("yacyDebugMode", "false");if(yacyDebugMode.equals("true")){return true;}diff --git a/source/de/anomic/plasma/plasmaCrawlLURL.java b/source/de/anomic/plasma/plasmaCrawlLURL.javaindex ef0f8340e..09c064666 100644--- a/source/de/anomic/plasma/plasmaCrawlLURL.java+++ b/source/de/anomic/plasma/plasmaCrawlLURL.java@@ -380,7 +380,7 @@ public final class plasmaCrawlLURL extends plasmaURL {url = urle.url().toString();txt = urle.url().toString();- // Kosmetik, die wirklich benutzte URL beh�lt die ':80'+ // Kosmetik, die wirklich benutzte URL behaelt die ':80'if (txt.endsWith(":80")) txt = txt.substring(0, txt.length() - 3);if ((p = txt.indexOf(":80/")) != -1) {txt = txt.substring(0, p).concat(txt.substring(p + 3)); // den '/' erstmal nicht abschneidendiff --git a/source/de/anomic/plasma/plasmaHTCache.java b/source/de/anomic/plasma/plasmaHTCache.javaindex 4563c9cf2..01b398fe2 100644--- a/source/de/anomic/plasma/plasmaHTCache.java+++ b/source/de/anomic/plasma/plasmaHTCache.java@@ -470,7 +470,7 @@ public final class plasmaHTCache {s = s.substring(pos + c.length());while (s.startsWith("/")) s = s.substring(1);- // dieser Block kann sp�ter gel�scht werden+ // dieser Block kann spaeter geloescht werdenpos = s.indexOf("+");if (pos >= 0) {s = s.substring(0, pos) + ":" + s.substring(pos + 1);diff --git a/source/de/anomic/plasma/plasmaRankingDistribution.java b/source/de/anomic/plasma/plasmaRankingDistribution.javanew file mode 100644index 000000000..9d0e34712--- /dev/null+++ b/source/de/anomic/plasma/plasmaRankingDistribution.java@@ -0,0 +1,133 @@+// plasmaRankingDistribution.java+// -------------------------------------------+// (C) by Michael Peter Christen; [email protected]+// first published on http://www.anomic.de+// Frankfurt, Germany, 2005+// created 9.11.2005+//+// $LastChangedDate: 2005-11-04 14:41:51 +0100 (Fri, 04 Nov 2005) $+// $LastChangedRevision: 1026 $+// $LastChangedBy: borg-0300 $+//+// 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+//+// Using this software in any meaning (reading, learning, copying, compiling,+// running) means that you agree that the Author(s) is (are) not responsible+// for cost, loss of data or any harm that may be caused directly or indirectly+// by usage of this softare or this documentation. The usage of this software+// is on your own risk. The installation and usage (starting/running) of this+// software may allow other people or application to access your computer and+// any attached devices and is highly dependent on the configuration of the+// software which must be done by the user of the software; the author(s) is+// (are) also not responsible for proper configuration and usage of the+// software, even if provoked by documentation provided together with+// the software.+//+// Any changes to this file according to the GPL as documented in the file+// gpl.txt aside this file in the shipment you received can be done to the+// lines that follows this copyright notice here, but changes must not be+// done inside the copyright notive above. A re-distribution must contain+// the intact and unchanged copyright notice.+// Contributions and changes to the program code must be marked as such.++package de.anomic.plasma;++import java.io.IOException;+import java.io.File;++import de.anomic.yacy.yacyCore;+import de.anomic.yacy.yacySeedDB;+import de.anomic.yacy.yacyClient;+import de.anomic.yacy.yacySeed;+import de.anomic.yacy.yacyVersion;+import de.anomic.server.logging.serverLog;+import de.anomic.server.serverFileUtils;++public final class plasmaRankingDistribution {++ public static final String CR_OWN = "GLOBAL/010_owncr";+ public static final String CR_OTHER = "GLOBAL/014_othercr/";++ private final serverLog log;+ private File sourcePath;++ public plasmaRankingDistribution(serverLog log, File sourcePath) {+ this.log = log;+ this.sourcePath = sourcePath;+ }++ public int size() {+ if ((sourcePath.exists()) && (sourcePath.isDirectory())) return sourcePath.list().length; else return 0;+ }++ public boolean performTransferRanking() {++ if (yacyCore.seedDB == null) {+ log.logFine("no ranking distribution: seedDB == null");+ return false;+ }+ if (yacyCore.seedDB.mySeed == null) {+ log.logFine("no ranking distribution: mySeed == null");+ return false;+ }+ if (yacyCore.seedDB.mySeed.isVirgin()) {+ log.logFine("no ranking distribution: status is virgin");+ return false;+ }++ String[] outfiles = sourcePath.list();++ if (outfiles == null) {+ log.logFine("no ranking distribution: source path does not exist");+ return false;+ }+ if (outfiles.length == 0) {+ log.logFine("no ranking distribution: source path does not contain any file");+ return false;+ }++ yacySeed target = yacyCore.seedDB.anySeedVersion(yacyVersion.YACY_ACCEPTS_RANKING_TRANSMISSION);+ //if (target == null) target = yacyCore.seedDB.getConnected("nAEhLbmYNor"); // only for debugging+ //if (target == null) target = yacyCore.seedDB.lookupByName("G5"); // only for debugging++ if (target == null) {+ log.logFine("no ranking distribution: no target available");+ return false;+ }++ // do the transfer+ long starttime = System.currentTimeMillis();+ File crfile = new File(sourcePath, outfiles[0]);+ String targetaddress = target.getAddress();+ String result = "unknown";+ try {+ byte[] b = serverFileUtils.read(crfile);+ result = yacyClient.transfer(targetaddress, crfile.getName(), b);+ if (result == null) {+ log.logInfo("RankingDistribution - transmitted file " + crfile + " to " + targetaddress + " successfully in " + ((System.currentTimeMillis() - starttime) / 1000) + " seconds");+ crfile.delete(); // the file is not needed any more locally+ } else {+ log.logInfo("RankingDistribution - error transmitting file " + crfile + " to " + targetaddress + ": " + result);+ }+ } catch (IOException e) {+ log.logInfo("RankingDistribution - could not read file " + crfile + ": " + e.getMessage());+ result = "input file error: " + e.getMessage();+ }++ // show success+ return result == null;+ }++}\ No newline at end of filediff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.javaindex 70670b127..9c2b55dbd 100644--- a/source/de/anomic/plasma/plasmaSwitchboard.java+++ b/source/de/anomic/plasma/plasmaSwitchboard.java@@ -51,7 +51,7 @@- configuration: initialized by properties once, then by external functions- job queues: for parsing, condensing, indexing- black/blue/whitelists: controls input and output to the index-+this class is also the core of the http crawling.There are some items that need to be respected when crawling the web:1) respect robots.txt@@ -60,7 +60,7 @@4) priorization of specific links should be possible (hot-lists)5) attributes for crawling (depth, filters, hot/black-lists, priority)6) different crawling jobs with different attributes ('Orders') simultanoulsy-+We implement some specific tasks and use different database to archieve these goals:- a database 'crawlerDisallow.db' contains all url's that shall not be crawled- a database 'crawlerDomain.db' holds all domains and access times, where we loaded the disallow tables@@ -71,7 +71,7 @@- two stacks for new URLS: newText.stack and newMedia.stack- two databases for URL double-check: knownText.db and knownMedia.db- one database with crawling orders: crawlerOrders.db-+The Information flow of a single URL that is crawled is as follows:- a html file is loaded from a specific URL within the module httpdProxyServlet asa process of the proxy.@@ -89,17 +89,17 @@- In plasmaIndexCache the single plasmaIndexEntry'ies are collected and stored into a plasmaIndex - entryThese plasmaIndex - Objects are the true reverse words indexes.- in plasmaIndex the plasmaIndexEntry - objects are stored in a kelondroTree; an indexed file in the file system.-+The information flow of a search request is as follows:- in httpdFileServlet the user enters a search query, which is passed to plasmaSwitchboard- in plasmaSwitchboard, the query is passed to plasmaSearch.- in plasmaSearch, the plasmaSearch.result object is generated by simultanous enumeration ofURL hases in the reverse word indexes plasmaIndex- (future: the plasmaSearch.result - object is used to identify more key words for a new search)----*/++++ */package de.anomic.plasma;@@ -117,6 +117,7 @@ import java.util.Map;import java.util.Set;import java.util.TreeSet;import java.util.logging.Level;+import java.util.WeakHashMap;import de.anomic.data.messageBoard;import de.anomic.data.wikiBoard;import de.anomic.data.userDB;@@ -158,12 +159,13 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serpublic static TreeSet stopwords = null;public static plasmaURLPattern urlBlacklist;- // storage management+ // storage managementpublic File htCachePath;private File plasmaPath;public File listsPath;public File htDocsPath;public File rankingPath;+ public WeakHashMap rankingPermissions;public plasmaURLPool urlPool;public plasmaWordIndex wordIndex;public plasmaHTCache cacheManager;@@ -178,6 +180,8 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serpublic plasmaCrawlProfile.entry defaultProxyProfile;public plasmaCrawlProfile.entry defaultRemoteProfile;public plasmaWordIndexDistribution indexDistribution;+ public plasmaRankingDistribution rankingOwnDistribution;+ public plasmaRankingDistribution rankingOtherDistribution;public HashMap outgoingCookies, incomingCookies;public kelondroTables facilityDB;public plasmaParser parser;@@ -191,35 +195,35 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser/** Remote Proxy configuration*/-// public boolean remoteProxyUse;-// public boolean remoteProxyUse4Yacy;-// public String remoteProxyHost;-// public int remoteProxyPort;-// public String remoteProxyNoProxy = "";-// public String[] remoteProxyNoProxyPatterns = null;+ // public boolean remoteProxyUse;+ // public boolean remoteProxyUse4Yacy;+ // public String remoteProxyHost;+ // public int remoteProxyPort;+ // public String remoteProxyNoProxy = "";+ // public String[] remoteProxyNoProxyPatterns = null;public httpRemoteProxyConfig remoteProxyConfig = null;--++/** Some constants*/private static final String STR_PROXYPROFILE = "defaultProxyProfile";private static final String STR_REMOTEPROFILE = "defaultRemoteProfile";private static final String STR_REMOTECRAWLTRIGGER = "REMOTECRAWLTRIGGER: REMOTE CRAWL TO PEER ";-+private serverSemaphore shutdownSync = new serverSemaphore(0);private boolean terminate = false;private Object crawlingPausedSync = new Object();- private boolean crawlingIsPaused = false;- private static plasmaSwitchboard sb;-+ private boolean crawlingIsPaused = false;+ private static plasmaSwitchboard sb;+public plasmaSwitchboard(String rootPath, String initPath, String configPath) throws IOException {super(rootPath, initPath, configPath);-+// set loglevel and logsetLog(new serverLog("PLASMA"));-+// load values from configsthis.plasmaPath = new File(rootPath, getConfig("dbPath", "DATA/PLASMADB"));this.log.logConfig("Plasma DB Path: " + this.plasmaPath.toString());@@ -229,6 +233,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serthis.log.logConfig("HTDOCS Path: " + this.htDocsPath.toString());this.rankingPath = new File(rootPath, getConfig("rankingPath", "DATA/RANKING"));this.log.logConfig("Ranking Path: " + this.rankingPath.toString());+ this.rankingPermissions = new WeakHashMap(); // mapping of permission - to filename./* ============================================================================* Remote Proxy configuration@@ -236,74 +241,74 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serthis.remoteProxyConfig = httpRemoteProxyConfig.init(this);this.log.logConfig("Remote proxy configuration:\n" + this.remoteProxyConfig.toString());-// // reading the proxy host name-// this.remoteProxyHost = getConfig("remoteProxyHost", "");-//-// // reading the proxy host port-// try {-// this.remoteProxyPort = Integer.parseInt(getConfig("remoteProxyPort", "3128"));-// } catch (NumberFormatException e) {-// this.remoteProxyPort = 3128;-// }-//-// // determining if remote proxy should be used for yacy -> yacy communication-// this.remoteProxyUse4Yacy = getConfig("remoteProxyUse4Yacy", "true").equalsIgnoreCase("true");-//-// // determining addresses for which the remote proxy should not be used-// this.remoteProxyNoProxy = getConfig("remoteProxyNoProxy","");-// this.remoteProxyNoProxyPatterns = this.remoteProxyNoProxy.split(",");-//-// // determining if remote Proxy should be used-// if (getConfig("remoteProxyUse", "false").equalsIgnoreCase("true")) {-// this.remoteProxyUse = true;-// this.log.logConfig("Using remote proxy:" +-// "\n\tHost: " + this.remoteProxyHost +-// "\n\tPort: " + this.remoteProxyPort +-// "\n\tUseProxy4Yacy: " + Boolean.toString(this.remoteProxyUse4Yacy)-// );-// } else {-// this.remoteProxyUse = false;-// this.remoteProxyHost = null;-// this.remoteProxyPort = 0;-// }+ // // reading the proxy host name+ // this.remoteProxyHost = getConfig("remoteProxyHost", "");+ //+ // // reading the proxy host port+ // try {+ // this.remoteProxyPort = Integer.parseInt(getConfig("remoteProxyPort", "3128"));+ // } catch (NumberFormatException e) {+ // this.remoteProxyPort = 3128;+ // }+ //+ // // determining if remote proxy should be used for yacy -> yacy communication+ // this.remoteProxyUse4Yacy = getConfig("remoteProxyUse4Yacy", "true").equalsIgnoreCase("true");+ //+ // // determining addresses for which the remote proxy should not be used+ // this.remoteProxyNoProxy = getConfig("remoteProxyNoProxy","");+ // this.remoteProxyNoProxyPatterns = this.remoteProxyNoProxy.split(",");+ //+ // // determining if remote Proxy should be used+ // if (getConfig("remoteProxyUse", "false").equalsIgnoreCase("true")) {+ // this.remoteProxyUse = true;+ // this.log.logConfig("Using remote proxy:" ++ // "\n\tHost: " + this.remoteProxyHost ++ // "\n\tPort: " + this.remoteProxyPort ++ // "\n\tUseProxy4Yacy: " + Boolean.toString(this.remoteProxyUse4Yacy)+ // );+ // } else {+ // this.remoteProxyUse = false;+ // this.remoteProxyHost = null;+ // this.remoteProxyPort = 0;+ // }this.proxyLastAccess = System.currentTimeMillis() - 60000;crg = new StringBuffer(maxCRGDump);//crl = new StringBuffer(maxCRLDump);// configuring list pathif (!(listsPath.exists())) listsPath.mkdirs();-+// load coloured listsif (blueList == null) {// read only once upon first instantiation of this classString f = getConfig("plasmaBlueList", null);File plasmaBlueListFile = new File(f);if (f != null) blueList = kelondroMSetTools.loadList(plasmaBlueListFile); else blueList= new TreeSet();- this.log.logConfig("loaded blue-list from file " + plasmaBlueListFile.getName() + ", " +- blueList.size() + " entries, " +- ppRamString(plasmaBlueListFile.length()/1024));+ this.log.logConfig("loaded blue-list from file " + plasmaBlueListFile.getName() + ", " ++ blueList.size() + " entries, " ++ ppRamString(plasmaBlueListFile.length()/1024));}-+// load the black-list / inspired by [AS]File ulrBlackListFile = new File(getRootPath(), getConfig("listsPath", "DATA/LISTS"));urlBlacklist = new plasmaURLPattern(ulrBlackListFile);String f = getConfig("proxyBlackListsActive", null);if (f != null) {urlBlacklist.loadLists("black", f, "/");- this.log.logConfig("loaded black-list from file " + ulrBlackListFile.getName() + ", " +- urlBlacklist.size() + " entries, " +- ppRamString(ulrBlackListFile.length()/1024));+ this.log.logConfig("loaded black-list from file " + ulrBlackListFile.getName() + ", " ++ urlBlacklist.size() + " entries, " ++ ppRamString(ulrBlackListFile.length()/1024));}-+// load stopwordsif (stopwords == null) {File stopwordsFile = new File(rootPath, "yacy.stopwords");stopwords = kelondroMSetTools.loadList(stopwordsFile);- this.log.logConfig("loaded stopwords from file " + stopwordsFile.getName() + ", " +- stopwords.size() + " entries, " +- ppRamString(stopwordsFile.length()/1024));+ this.log.logConfig("loaded stopwords from file " + stopwordsFile.getName() + ", " ++ stopwords.size() + " entries, " ++ ppRamString(stopwordsFile.length()/1024));}-+// read memory amountint ramLURL = (int) getConfigLong("ramCacheLURL", 1024) / 1024;int ramNURL = (int) getConfigLong("ramCacheNURL", 1024) / 1024;@@ -331,22 +336,22 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serFile profilesFile = new File(this.plasmaPath, "crawlProfiles0.db");this.profiles = new plasmaCrawlProfile(profilesFile, ramProfiles);initProfiles();- log.logConfig("Loaded profiles from file " + profilesFile.getName() +- ", " + this.profiles.size() + " entries" +- ", " + ppRamString(profilesFile.length()/1024));+ log.logConfig("Loaded profiles from file " + profilesFile.getName() ++ ", " + this.profiles.size() + " entries" ++ ", " + ppRamString(profilesFile.length()/1024));// loading the robots.txt dbthis.log.logConfig("Initializing robots.txt DB");File robotsDBFile = new File(this.plasmaPath, "crawlRobotsTxt.db");robots = new plasmaCrawlRobotsTxt(robotsDBFile, ramRobots);- this.log.logConfig("Loaded robots.txt DB from file " + robotsDBFile.getName() +- ", " + robots.size() + " entries" +- ", " + ppRamString(robotsDBFile.length()/1024));+ this.log.logConfig("Loaded robots.txt DB from file " + robotsDBFile.getName() ++ ", " + robots.size() + " entries" ++ ", " + ppRamString(robotsDBFile.length()/1024));// start indexing managementlog.logConfig("Starting Indexing Management");urlPool = new plasmaURLPool(plasmaPath, ramLURL, ramNURL, ramEURL);-+wordIndex = new plasmaWordIndex(plasmaPath, ramRWI, log);int wordCacheMaxLow = (int) getConfigLong("wordCacheMaxLow", 8000);int wordCacheMaxHigh = (int) getConfigLong("wordCacheMaxHigh", 10000);@@ -354,7 +359,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser// start a cache managerlog.logConfig("Starting HT Cache Manager");-+// create the cache directoryString cache = getConfig("proxyCache", "DATA/HTCACHE");cache = cache.replace('\\', '/');@@ -392,7 +397,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serlog.logConfig("Parser: Initializing Extension Mappings for Media/Parser");plasmaParser.initMediaExt(plasmaParser.extString2extList(getConfig("mediaExt","")));plasmaParser.initSupportedRealtimeFileExt(plasmaParser.extString2extList(getConfig("parseableExt","")));-+// define a realtime parsable mimetype listlog.logConfig("Parser: Initializing Mime Types");plasmaParser.initRealtimeParsableMimeTypes(getConfig("parseableRealtimeMimeTypes","application/xhtml+xml,text/html,text/plain"));@@ -408,43 +413,47 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serthis.crawlingIsPaused = Boolean.valueOf(getConfig("crawler.isPaused", "false")).booleanValue();plasmaCrawlLoader.switchboard = this;this.cacheLoader = new plasmaCrawlLoader(- this.cacheManager,- this.log);-+ this.cacheManager,+ this.log);+// starting message boardthis.log.logConfig("Starting Message Board");File messageDbFile = new File(getRootPath(), "DATA/SETTINGS/message.db");this.messageDB = new messageBoard(messageDbFile, ramMessage);- this.log.logConfig("Loaded Message Board DB from file " + messageDbFile.getName() +- ", " + this.messageDB.size() + " entries" +- ", " + ppRamString(messageDbFile.length()/1024));+ this.log.logConfig("Loaded Message Board DB from file " + messageDbFile.getName() ++ ", " + this.messageDB.size() + " entries" ++ ", " + ppRamString(messageDbFile.length()/1024));// starting wikithis.log.logConfig("Starting Wiki Board");File wikiDbFile = new File(getRootPath(), "DATA/SETTINGS/wiki.db");this.wikiDB = new wikiBoard(wikiDbFile,- new File(getRootPath(), "DATA/SETTINGS/wiki-bkp.db"), ramWiki);- this.log.logConfig("Loaded Wiki Board DB from file " + wikiDbFile.getName() +- ", " + this.wikiDB.size() + " entries" +- ", " + ppRamString(wikiDbFile.length()/1024));+ new File(getRootPath(), "DATA/SETTINGS/wiki-bkp.db"), ramWiki);+ this.log.logConfig("Loaded Wiki Board DB from file " + wikiDbFile.getName() ++ ", " + this.wikiDB.size() + " entries" ++ ", " + ppRamString(wikiDbFile.length()/1024));// Init User DBthis.log.logConfig("Loading User DB");File userDbFile = new File(getRootPath(), "DATA/SETTINGS/user.db");- this.userDB = new userDB(userDbFile, 512);- this.log.logConfig("Loaded User DB from file " + userDbFile.getName() +- ", " + this.userDB.size() + " entries" +- ", " + ppRamString(userDbFile.length()/1024));-+ this.userDB = new userDB(userDbFile, 512);+ this.log.logConfig("Loaded User DB from file " + userDbFile.getName() ++ ", " + this.userDB.size() + " entries" ++ ", " + ppRamString(userDbFile.length()/1024));+// init cookie-Monitorthis.log.logConfig("Starting Cookie Monitor");this.outgoingCookies = new HashMap();this.incomingCookies = new HashMap();-+// clean up profilesthis.log.logConfig("Cleaning Profiles");cleanProfiles();-++ // init ranking transmission+ rankingOwnDistribution = new plasmaRankingDistribution(log, new File(rankingPath, plasmaRankingDistribution.CR_OWN));+ rankingOtherDistribution = new plasmaRankingDistribution(log, new File(rankingPath, plasmaRankingDistribution.CR_OTHER));+// init facility DB/*log.logSystem("Starting Facility Database");@@ -459,7 +468,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serfacilityDB.update("statistik", (new serverDate()).toShortString(false).substring(0, 11), new long[]{1,2,3,4,5,6});long[] testresult = facilityDB.selectLong("statistik", "yyyyMMddHHm");testresult = facilityDB.selectLong("statistik", (new serverDate()).toShortString(false).substring(0, 11));- */+ *//** Initializing httpc@@ -484,13 +493,13 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser//try{Thread.currentThread().sleep(5000);} catch (InterruptedException e) {} // for profilerthis.yc = new yacyCore(this);//log.logSystem("Started YaCy Protocol Core");-// System.gc(); try{Thread.currentThread().sleep(5000);} catch (InterruptedException e) {} // for profiler+ // System.gc(); try{Thread.currentThread().sleep(5000);} catch (InterruptedException e) {} // for profilerserverInstantThread.oneTimeJob(yc, "loadSeeds", yacyCore.log, 3000);// initializing the stackCrawlThreadthis.sbStackCrawlThread = new plasmaCrawlStacker(this,this.plasmaPath,ramPreNURL);//this.sbStackCrawlThread = new plasmaStackCrawlThread(this,this.plasmaPath,ramPreNURL);- //this.sbStackCrawlThread.start();+ //this.sbStackCrawlThread.start();// deploy threadslog.logConfig("Starting Threads");@@ -498,49 +507,49 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serint indexing_cluster = Integer.parseInt(getConfig("80_indexing_cluster", "1"));if (indexing_cluster < 1) indexing_cluster = 1;deployThread("90_cleanup", "Cleanup", "simple cleaning process for monitoring information", null,- new serverInstantThread(this, "cleanupJob", "cleanupJobSize"), 10000); // all 5 Minutes+ new serverInstantThread(this, "cleanupJob", "cleanupJobSize"), 10000); // all 5 MinutesdeployThread("82_crawlstack", "Crawl URL Stacker", "process that checks url for double-occurrences and for allowance/disallowance by robots.txt", null,- new serverInstantThread(sbStackCrawlThread, "job", "size"), 8000);+ new serverInstantThread(sbStackCrawlThread, "job", "size"), 8000);serverInstantThread indexingThread = null;deployThread("80_indexing", "Parsing/Indexing", "thread that performes document parsing and indexing", "/IndexCreateIndexingQueue_p.html",- indexingThread = new serverInstantThread(this, "deQueue", "queueSize"), 10000);+ indexingThread = new serverInstantThread(this, "deQueue", "queueSize"), 10000);for (int i = 1; i < indexing_cluster; i++) {setConfig((i + 80) + "_indexing_idlesleep", getConfig("80_indexing_idlesleep", ""));setConfig((i + 80) + "_indexing_busysleep", getConfig("80_indexing_busysleep", ""));deployThread((i + 80) + "_indexing", "Parsing/Indexing (cluster job)", "thread that performes document parsing and indexing", null,- new serverInstantThread(this, "deQueue", "queueSize"), 10000 + (i * 1000),- Long.parseLong(getConfig("80_indexing_idlesleep" , "5000")),- Long.parseLong(getConfig("80_indexing_busysleep" , "0")),- Long.parseLong(getConfig("80_indexing_memprereq" , "1000000")));+ new serverInstantThread(this, "deQueue", "queueSize"), 10000 + (i * 1000),+ Long.parseLong(getConfig("80_indexing_idlesleep" , "5000")),+ Long.parseLong(getConfig("80_indexing_busysleep" , "0")),+ Long.parseLong(getConfig("80_indexing_memprereq" , "1000000")));}deployThread("70_cachemanager", "Proxy Cache Enqueue", "job takes new proxy files from RAM stack, stores them, and hands over to the Indexing Stack", null,- new serverInstantThread(this, "htEntryStoreJob", "htEntrySize"), 10000);+ new serverInstantThread(this, "htEntryStoreJob", "htEntrySize"), 10000);deployThread("62_remotetriggeredcrawl", "Remote Crawl Job", "thread that performes a single crawl/indexing step triggered by a remote peer", null,- new serverInstantThread(this, "remoteTriggeredCrawlJob", "remoteTriggeredCrawlJobSize"), 30000);+ new serverInstantThread(this, "remoteTriggeredCrawlJob", "remoteTriggeredCrawlJobSize"), 30000);deployThread("61_globalcrawltrigger", "Global Crawl Trigger", "thread that triggeres remote peers for crawling", "/IndexCreateWWWGlobalQueue_p.html",- new serverInstantThread(this, "limitCrawlTriggerJob", "limitCrawlTriggerJobSize"), 30000); // error here?+ new serverInstantThread(this, "limitCrawlTriggerJob", "limitCrawlTriggerJobSize"), 30000); // error here?deployThread("50_localcrawl", "Local Crawl", "thread that performes a single crawl step from the local crawl queue", "/IndexCreateWWWLocalQueue_p.html",- new serverInstantThread(this, "coreCrawlJob", "coreCrawlJobSize"), 10000);+ new serverInstantThread(this, "coreCrawlJob", "coreCrawlJobSize"), 10000);deployThread("40_peerseedcycle", "Seed-List Upload", "task that a principal peer performes to generate and upload a seed-list to a ftp account", null,- new serverInstantThread(yc, "publishSeedList", null), 180000);+ new serverInstantThread(yc, "publishSeedList", null), 180000);serverInstantThread peerPing = null;deployThread("30_peerping", "YaCy Core", "this is the p2p-control and peer-ping task", null,- peerPing = new serverInstantThread(yc, "peerPing", null), 2000);+ peerPing = new serverInstantThread(yc, "peerPing", null), 2000);peerPing.setSyncObject(new Object());this.indexDistribution = new plasmaWordIndexDistribution(- this.urlPool,- this.wordIndex,- this.log,- getConfig("allowDistributeIndex", "false").equalsIgnoreCase("true"),- getConfig("allowDistributeIndexWhileCrawling","false").equalsIgnoreCase("true"),- getConfig("indexDistribution.gzipBody","false").equalsIgnoreCase("true"),- (int)getConfigLong("indexDistribution.timeout",60000),- (int)getConfigLong("indexDistribution.maxOpenFiles",800)+ this.urlPool,+ this.wordIndex,+ this.log,+ getConfig("allowDistributeIndex", "false").equalsIgnoreCase("true"),+ getConfig("allowDistributeIndexWhileCrawling","false").equalsIgnoreCase("true"),+ getConfig("indexDistribution.gzipBody","false").equalsIgnoreCase("true"),+ (int)getConfigLong("indexDistribution.timeout",60000),+ (int)getConfigLong("indexDistribution.maxOpenFiles",800));indexDistribution.setCounts(150, 1, 3, 10000);deployThread("20_dhtdistribution", "DHT Distribution", "selection, transfer and deletion of index entries that are not searched on your peer, but on others", null,- new serverInstantThread(indexDistribution, "job", null), 600000);+ new serverInstantThread(indexDistribution, "job", null), 600000);// test routine for snippet fetch//Set query = new HashSet();@@ -549,15 +558,17 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser//plasmaSnippetCache.result scr = snippetCache.retrieve(new URL("http://www.heise.de/mobil/newsticker/meldung/mail/54980"), query, true);//plasmaSnippetCache.result scr = snippetCache.retrieve(new URL("http://www.heise.de/security/news/foren/go.shtml?read=1&msg_id=7301419&forum_id=72721"), query, true);//plasmaSnippetCache.result scr = snippetCache.retrieve(new URL("http://www.heise.de/kiosk/archiv/ct/2003/4/20"), query, true, 260);-- sb=this;++ sb=this;log.logConfig("Finished Switchboard Initialization");}+++ public static plasmaSwitchboard getSwitchboard(){+ return sb;+ }- public static plasmaSwitchboard getSwitchboard(){- return sb;- }-+/*** This method changes the HTCache size.<br>* @param new cache size in mb@@ -565,7 +576,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serpublic final void setCacheSize(long newCacheSize) {this.cacheManager.setCacheSize(1048576 * newCacheSize);}-+public boolean onlineCaution() {try {return System.currentTimeMillis() - proxyLastAccess < Integer.parseInt(getConfig("onlineCautionDelay", "30000"));@@ -585,8 +596,8 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serprivate void initProfiles() throws IOException {if ((profiles.size() == 0) ||- (getConfig(STR_PROXYPROFILE, "").length() == 0) ||- (profiles.getEntry(getConfig(STR_PROXYPROFILE, "")) == null)) {+ (getConfig(STR_PROXYPROFILE, "").length() == 0) ||+ (profiles.getEntry(getConfig(STR_PROXYPROFILE, "")) == null)) {// generate new default entry for proxy crawlingdefaultProxyProfile = profiles.newEntry("proxy", "", ".*", ".*", Integer.parseInt(getConfig("proxyPrefetchDepth", "0")), Integer.parseInt(getConfig("proxyPrefetchDepth", "0")), false, true, true, true, false, true, true, true);setConfig(STR_PROXYPROFILE, defaultProxyProfile.handle());@@ -594,8 +605,8 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serdefaultProxyProfile = profiles.getEntry(getConfig(STR_PROXYPROFILE, ""));}if ((profiles.size() == 1) ||- (getConfig(STR_REMOTEPROFILE, "").length() == 0) ||- (profiles.getEntry(getConfig(STR_REMOTEPROFILE, "")) == null)) {+ (getConfig(STR_REMOTEPROFILE, "").length() == 0) ||+ (profiles.getEntry(getConfig(STR_REMOTEPROFILE, "")) == null)) {// generate new default entry for remote crawlingdefaultRemoteProfile = profiles.newEntry("remote", "", ".*", ".*", 0, 0, true, false, true, true, false, true, true, false);setConfig(STR_REMOTEPROFILE, defaultRemoteProfile.handle());@@ -631,21 +642,21 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser}return hasDoneSomething;}-+public plasmaHTCache getCacheManager() {- return cacheManager;+ return cacheManager;}synchronized public void htEntryStoreEnqueued(plasmaHTCache.Entry entry) throws IOException {- if (cacheManager.full())- htEntryStoreProcess(entry);- else- cacheManager.push(entry);+ if (cacheManager.full())+ htEntryStoreProcess(entry);+ else+ cacheManager.push(entry);}-+synchronized public boolean htEntryStoreProcess(plasmaHTCache.Entry entry) throws IOException {- if (entry == null) return false;+ if (entry == null) return false;// store response headerif (entry.responseHeader != null) {@@ -661,8 +672,8 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serboolean doIndexing = true;if (entry.requestHeader != null) {if (- (entry.requestHeader.containsKey(httpHeader.X_YACY_INDEX_CONTROL)) &&- (((String) entry.requestHeader.get(httpHeader.X_YACY_INDEX_CONTROL)).toUpperCase().equals("NO-INDEX"))+ (entry.requestHeader.containsKey(httpHeader.X_YACY_INDEX_CONTROL)) &&+ (((String) entry.requestHeader.get(httpHeader.X_YACY_INDEX_CONTROL)).toUpperCase().equals("NO-INDEX"))) {doIndexing = false;}@@ -680,7 +691,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serthis.log.logInfo("WRITE OF FILE " + entry.cacheFile + " FORBIDDEN: " + error);}}-+if ((doIndexing) && plasmaParser.supportedContent(entry.url,entry.responseHeader.mime())){// registering the cachefile as in use@@ -690,11 +701,11 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser// enqueue for further crawlingenQueue(this.sbQueue.newEntry(entry.url, plasmaURL.urlHash(entry.referrerURL()),- entry.requestHeader.ifModifiedSince(), entry.requestHeader.containsKey(httpHeader.COOKIE),- entry.initiator(), entry.depth, entry.profile.handle(),- entry.name()+ entry.requestHeader.ifModifiedSince(), entry.requestHeader.containsKey(httpHeader.COOKIE),+ entry.initiator(), entry.depth, entry.profile.handle(),+ entry.name()));- }+ }return true;}@@ -711,7 +722,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serpublic int htEntrySize() {return cacheManager.size();}-+public void close() {log.logConfig("SWITCHBOARD SHUTDOWN STEP 1: sending termination signal to managed threads:");terminateAllThreads(true);@@ -731,12 +742,12 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serurlPool.close();profiles.close();robots.close();- parser.close();+ parser.close();cacheManager.close();sbQueue.close();//flushCitationReference(crl, "crl");flushCitationReference(crg, "crg");- } catch (IOException e) {}+ } catch (IOException e) {}log.logConfig("SWITCHBOARD SHUTDOWN TERMINATED");}@@ -746,9 +757,9 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser}public int cacheSizeMin() {- return wordIndex.size();+ return wordIndex.size();}-+public void enQueue(Object job) {if (!(job instanceof plasmaSwitchboardQueue.Entry)) {System.out.println("internal error at plasmaSwitchboard.enQueue: wrong job type");@@ -760,7 +771,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serlog.logSevere("IOError in plasmaSwitchboard.enQueue: " + e.getMessage(), e);}}-+public boolean deQueue() {// work off fresh entries from the proxy or from the crawlerif (onlineCaution()) {@@ -770,16 +781,16 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serif (wordIndex.wordCacheRAMSize() + 1000 > (int) getConfigLong("wordCacheMaxLow", 8000)) {log.logFine("deQueue: word index ram cache too full (" + ((int) getConfigLong("wordCacheMaxLow", 8000) - wordIndex.wordCacheRAMSize()) +- " slots left); dismissed to omit ram flush lock");+ " slots left); dismissed to omit ram flush lock");return false;}int stackCrawlQueueSize;if ((stackCrawlQueueSize = sbStackCrawlThread.size()) >= stackCrawlSlots) {log.logFine("deQueue: too many processes in stack crawl thread queue, dismissed to protect emergency case (" +- "stackCrawlQueue=" + stackCrawlQueueSize + ")");+ "stackCrawlQueue=" + stackCrawlQueueSize + ")");return false;- }+ }plasmaSwitchboardQueue.Entry nextentry;synchronized (sbQueue) {@@ -793,10 +804,10 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser// do one processing steplog.logFine("DEQUEUE: sbQueueSize=" + sbQueue.size() +- ", coreStackSize=" + urlPool.noticeURL.stackSize(plasmaCrawlNURL.STACK_TYPE_CORE) +- ", limitStackSize=" + urlPool.noticeURL.stackSize(plasmaCrawlNURL.STACK_TYPE_LIMIT) +- ", overhangStackSize=" + urlPool.noticeURL.stackSize(plasmaCrawlNURL.STACK_TYPE_OVERHANG) +- ", remoteStackSize=" + urlPool.noticeURL.stackSize(plasmaCrawlNURL.STACK_TYPE_REMOTE));+ ", coreStackSize=" + urlPool.noticeURL.stackSize(plasmaCrawlNURL.STACK_TYPE_CORE) ++ ", limitStackSize=" + urlPool.noticeURL.stackSize(plasmaCrawlNURL.STACK_TYPE_LIMIT) ++ ", overhangStackSize=" + urlPool.noticeURL.stackSize(plasmaCrawlNURL.STACK_TYPE_OVERHANG) ++ ", remoteStackSize=" + urlPool.noticeURL.stackSize(plasmaCrawlNURL.STACK_TYPE_REMOTE));try {nextentry = sbQueue.pop();if (nextentry == null) return false;@@ -805,10 +816,10 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serreturn false;}}-+synchronized (this.indexingTasksInProcess) {this.indexingTasksInProcess.put(nextentry.urlHash(),nextentry);- }+ }processResourceStack(nextentry);return true;@@ -818,29 +829,32 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serint c = 0;if ((urlPool.errorURL.stackSize() > 1000)) c++;for (int i = 1; i <= 6; i++) {- if (urlPool.loadedURL.getStackSize(i) > 1000) c++;- }+ if (urlPool.loadedURL.getStackSize(i) > 1000) c++;+ }return c;}public boolean cleanupJob() {-+boolean hasDoneSomething = false;+ // do a transmission+ rankingOwnDistribution.performTransferRanking();+// clean up error stack- if ((urlPool.errorURL.stackSize() > 1000)) {+ if ((urlPool.errorURL.stackSize() > 1000)) {log.logFine("Cleaning Error-URLs report stack, " + urlPool.errorURL.stackSize() + " entries on stack");- urlPool.errorURL.clearStack();+ urlPool.errorURL.clearStack();hasDoneSomething = true;- }- // clean up loadedURL stack- for (int i = 1; i <= 6; i++) {- if (urlPool.loadedURL.getStackSize(i) > 1000) {- log.logFine("Cleaning Loaded-URLs report stack, " + urlPool.loadedURL.getStackSize(i) + " entries on stack " + i);+ }+ // clean up loadedURL stack+ for (int i = 1; i <= 6; i++) {+ if (urlPool.loadedURL.getStackSize(i) > 1000) {+ log.logFine("Cleaning Loaded-URLs report stack, " + urlPool.loadedURL.getStackSize(i) + " entries on stack " + i);urlPool.loadedURL.clearStack(i);hasDoneSomething = true;- }- }+ }+ }// clean up profilesif (cleanProfiles()) hasDoneSomething = true;@@ -852,7 +866,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serreturn hasDoneSomething;}-+/*** Creates a new File instance with absolute path of ours Seed File.<br>* @return a new File instance@@ -860,9 +874,9 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serpublic File getOwnSeedFile() {return new File(getRootPath(), getConfig("yacyOwnSeedFile", "mySeed.txt"));}-+/**- * With this function the crawling process can be paused+ * With this function the crawling process can be paused*/public void pauseCrawling() {synchronized(this.crawlingPausedSync) {@@ -872,10 +886,10 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser}/**- * Continue the previously paused crawling+ * Continue the previously paused crawling*/public void continueCrawling() {- synchronized(this.crawlingPausedSync) {+ synchronized(this.crawlingPausedSync) {if (this.crawlingIsPaused) {this.crawlingIsPaused = false;this.crawlingPausedSync.notifyAll();@@ -891,7 +905,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements sersynchronized(this.crawlingPausedSync) {return this.crawlingIsPaused;}- }+ }public int coreCrawlJobSize() {return urlPool.noticeURL.stackSize(plasmaCrawlNURL.STACK_TYPE_CORE);@@ -904,12 +918,12 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser}if (sbQueue.size() >= indexingSlots) {log.logFine("CoreCrawl: too many processes in indexing queue, dismissed (" +- "sbQueueSize=" + sbQueue.size() + ")");+ "sbQueueSize=" + sbQueue.size() + ")");return false;}if (cacheLoader.size() >= crawlSlots) {log.logFine("CoreCrawl: too many processes in loader queue, dismissed (" +- "cacheLoader=" + cacheLoader.size() + ")");+ "cacheLoader=" + cacheLoader.size() + ")");return false;}if (onlineCaution()) {@@ -927,7 +941,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser}catch (InterruptedException e){ return false;}}- }+ }// do a local crawlplasmaCrawlNURL.Entry urlEntry = urlPool.noticeURL.pop(plasmaCrawlNURL.STACK_TYPE_CORE);@@ -947,10 +961,10 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serlog.logSevere(stats + ": LOST PROFILE HANDLE '" + urlEntry.profileHandle() + "' (must be internal error) for URL " + urlEntry.url());return true;}- log.logFine("LOCALCRAWL: URL=" + urlEntry.url() + ", initiator=" + urlEntry.initiator() +- ", crawlOrder=" + ((profile.remoteIndexing()) ? "true" : "false") + ", depth=" + urlEntry.depth() + ", crawlDepth=" + profile.generalDepth() + ", filter=" + profile.generalFilter() +- ", permission=" + ((yacyCore.seedDB == null) ? "undefined" : (((yacyCore.seedDB.mySeed.isSenior()) || (yacyCore.seedDB.mySeed.isPrincipal())) ? "true" : "false")));-+ log.logFine("LOCALCRAWL: URL=" + urlEntry.url() + ", initiator=" + urlEntry.initiator() ++ ", crawlOrder=" + ((profile.remoteIndexing()) ? "true" : "false") + ", depth=" + urlEntry.depth() + ", crawlDepth=" + profile.generalDepth() + ", filter=" + profile.generalFilter() ++ ", permission=" + ((yacyCore.seedDB == null) ? "undefined" : (((yacyCore.seedDB.mySeed.isSenior()) || (yacyCore.seedDB.mySeed.isPrincipal())) ? "true" : "false")));+processLocalCrawling(urlEntry, profile, stats);return true;}@@ -982,12 +996,12 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serif (sbQueue.size() >= indexingSlots) {log.logFine("LimitCrawl: too many processes in indexing queue, dismissed to protect emergency case (" +- "sbQueueSize=" + sbQueue.size() + ")");+ "sbQueueSize=" + sbQueue.size() + ")");return false;}if (cacheLoader.size() >= crawlSlots) {log.logFine("LimitCrawl: too many processes in loader queue, dismissed to protect emergency case (" +- "cacheLoader=" + cacheLoader.size() + ")");+ "cacheLoader=" + cacheLoader.size() + ")");return false;}@@ -1003,7 +1017,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser}catch (InterruptedException e){ return false;}}- }+ }// start a global crawl, if possibleplasmaCrawlNURL.Entry urlEntry = urlPool.noticeURL.pop(plasmaCrawlNURL.STACK_TYPE_LIMIT);@@ -1019,17 +1033,17 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serlog.logSevere(stats + ": LOST PROFILE HANDLE '" + urlEntry.profileHandle() + "' (must be internal error) for URL " + urlEntry.url());return true;}- log.logFine("plasmaSwitchboard.limitCrawlTriggerJob: url=" + urlEntry.url() + ", initiator=" + urlEntry.initiator() +- ", crawlOrder=" + ((profile.remoteIndexing()) ? "true" : "false") + ", depth=" + urlEntry.depth() + ", crawlDepth=" + profile.generalDepth() + ", filter=" + profile.generalFilter() +- ", permission=" + ((yacyCore.seedDB == null) ? "undefined" : (((yacyCore.seedDB.mySeed.isSenior()) || (yacyCore.seedDB.mySeed.isPrincipal())) ? "true" : "false")));-- boolean tryRemote =- ((urlPool.noticeURL.stackSize(plasmaCrawlNURL.STACK_TYPE_CORE) != 0) || (sbQueue.size() != 0)) /* should do ourself */ &&- (profile.remoteIndexing()) /* granted */ &&- (urlEntry.initiator() != null) && (!(urlEntry.initiator().equals(plasmaURL.dummyHash))) /* not proxy */ &&- ((yacyCore.seedDB.mySeed.isSenior()) ||- (yacyCore.seedDB.mySeed.isPrincipal())) /* qualified */;-+ log.logFine("plasmaSwitchboard.limitCrawlTriggerJob: url=" + urlEntry.url() + ", initiator=" + urlEntry.initiator() ++ ", crawlOrder=" + ((profile.remoteIndexing()) ? "true" : "false") + ", depth=" + urlEntry.depth() + ", crawlDepth=" + profile.generalDepth() + ", filter=" + profile.generalFilter() ++ ", permission=" + ((yacyCore.seedDB == null) ? "undefined" : (((yacyCore.seedDB.mySeed.isSenior()) || (yacyCore.seedDB.mySeed.isPrincipal())) ? "true" : "false")));++ boolean tryRemote =+ ((urlPool.noticeURL.stackSize(plasmaCrawlNURL.STACK_TYPE_CORE) != 0) || (sbQueue.size() != 0)) /* should do ourself */ &&+ (profile.remoteIndexing()) /* granted */ &&+ (urlEntry.initiator() != null) && (!(urlEntry.initiator().equals(plasmaURL.dummyHash))) /* not proxy */ &&+ ((yacyCore.seedDB.mySeed.isSenior()) ||+ (yacyCore.seedDB.mySeed.isPrincipal())) /* qualified */;+if (tryRemote) {boolean success = processRemoteCrawlTrigger(urlEntry);if (success) return true;@@ -1065,7 +1079,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser}catch (InterruptedException e){ return false; }}- }+ }// we don't want to crawl a global URL globally, since WE are the global part. (from this point of view)plasmaCrawlNURL.Entry urlEntry = urlPool.noticeURL.pop(plasmaCrawlNURL.STACK_TYPE_REMOTE);@@ -1082,21 +1096,21 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serlog.logSevere(stats + ": LOST PROFILE HANDLE '" + urlEntry.profileHandle() + "' (must be internal error) for URL " + urlEntry.url());return false;}- log.logFine("plasmaSwitchboard.remoteTriggeredCrawlJob: url=" + urlEntry.url() + ", initiator=" + urlEntry.initiator() +- ", crawlOrder=" + ((profile.remoteIndexing()) ? "true" : "false") + ", depth=" + urlEntry.depth() + ", crawlDepth=" + profile.generalDepth() + ", filter=" + profile.generalFilter() +- ", permission=" + ((yacyCore.seedDB == null) ? "undefined" : (((yacyCore.seedDB.mySeed.isSenior()) || (yacyCore.seedDB.mySeed.isPrincipal())) ? "true" : "false")));-+ log.logFine("plasmaSwitchboard.remoteTriggeredCrawlJob: url=" + urlEntry.url() + ", initiator=" + urlEntry.initiator() ++ ", crawlOrder=" + ((profile.remoteIndexing()) ? "true" : "false") + ", depth=" + urlEntry.depth() + ", crawlDepth=" + profile.generalDepth() + ", filter=" + profile.generalFilter() ++ ", permission=" + ((yacyCore.seedDB == null) ? "undefined" : (((yacyCore.seedDB.mySeed.isSenior()) || (yacyCore.seedDB.mySeed.isPrincipal())) ? "true" : "false")));+processLocalCrawling(urlEntry, profile, stats);return true;}-+private void processResourceStack(plasmaSwitchboardQueue.Entry entry) {// work off one stack entry with a fresh resourcetry {- long stackStartTime = 0, stackEndTime = 0,- parsingStartTime = 0, parsingEndTime = 0,- indexingStartTime = 0, indexingEndTime = 0,- storageStartTime = 0, storageEndTime = 0;+ long stackStartTime = 0, stackEndTime = 0,+ parsingStartTime = 0, parsingEndTime = 0,+ indexingStartTime = 0, indexingEndTime = 0,+ storageStartTime = 0, storageEndTime = 0;// we must distinguish the following cases: resource-load was initiated by// 1) global crawling: the index is extern, not here (not possible here)@@ -1121,12 +1135,12 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser}log.logFine("processResourceStack processCase=" + processCase +- ", depth=" + entry.depth() +- ", maxDepth=" + ((entry.profile() == null) ? "null" : Integer.toString(entry.profile().generalDepth())) +- ", filter=" + ((entry.profile() == null) ? "null" : entry.profile().generalFilter()) +- ", initiatorHash=" + initiatorHash +- ", responseHeader=" + ((entry.responseHeader() == null) ? "null" : entry.responseHeader().toString()) +- ", url=" + entry.url()); // DEBUG+ ", depth=" + entry.depth() ++ ", maxDepth=" + ((entry.profile() == null) ? "null" : Integer.toString(entry.profile().generalDepth())) ++ ", filter=" + ((entry.profile() == null) ? "null" : entry.profile().generalFilter()) ++ ", initiatorHash=" + initiatorHash ++ ", responseHeader=" + ((entry.responseHeader() == null) ? "null" : entry.responseHeader().toString()) ++ ", url=" + entry.url()); // DEBUG// parse contentparsingStartTime = System.currentTimeMillis();@@ -1147,7 +1161,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser}} else {log.logFine("(Parser) '" + entry.normalizedURLString() + "'. Unsupported mimeType '" + ((mimeType == null) ? "null" : mimeType) + "'.");- return;+ return;}parsingEndTime = System.currentTimeMillis();@@ -1161,7 +1175,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser// put anchors on crawl stackstackStartTime = System.currentTimeMillis();if (((processCase == 4) || (processCase == 5)) &&- ((entry.profile() == null) || (entry.depth() < entry.profile().generalDepth()))) {+ ((entry.profile() == null) || (entry.depth() < entry.profile().generalDepth()))) {Map hl = document.getHyperlinks();Iterator i = hl.entrySet().iterator();String nexturlstring;@@ -1172,19 +1186,19 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements sere = (Map.Entry) i.next();nexturlstring = (String) e.getKey();nexturlstring = htmlFilterContentScraper.urlNormalform(null, nexturlstring);-+sbStackCrawlThread.enqueue(nexturlstring, entry.url().toString(), initiatorHash, (String) e.getValue(), docDate, entry.depth() + 1, entry.profile());--// rejectReason = stackCrawl(nexturlstring, entry.normalizedURLString(), initiatorHash, (String) e.getValue(), loadDate, entry.depth() + 1, entry.profile());-// if (rejectReason == null) {-// c++;-// } else {-// urlPool.errorURL.newEntry(new URL(nexturlstring), entry.normalizedURLString(), entry.initiator(), yacyCore.seedDB.mySeed.hash,-// (String) e.getValue(), rejectReason, new bitfield(plasmaURL.urlFlagLength), false);-// }++ // rejectReason = stackCrawl(nexturlstring, entry.normalizedURLString(), initiatorHash, (String) e.getValue(), loadDate, entry.depth() + 1, entry.profile());+ // if (rejectReason == null) {+ // c++;+ // } else {+ // urlPool.errorURL.newEntry(new URL(nexturlstring), entry.normalizedURLString(), entry.initiator(), yacyCore.seedDB.mySeed.hash,+ // (String) e.getValue(), rejectReason, new bitfield(plasmaURL.urlFlagLength), false);+ // }}- log.logInfo("CRAWL: ADDED " + hl.size() + " LINKS FROM " + entry.normalizedURLString() +- ", NEW CRAWL STACK SIZE IS " + urlPool.noticeURL.stackSize(plasmaCrawlNURL.STACK_TYPE_CORE));+ log.logInfo("CRAWL: ADDED " + hl.size() + " LINKS FROM " + entry.normalizedURLString() ++ ", NEW CRAWL STACK SIZE IS " + urlPool.noticeURL.stackSize(plasmaCrawlNURL.STACK_TYPE_CORE));}stackEndTime = System.currentTimeMillis();@@ -1205,7 +1219,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serindexingStartTime = System.currentTimeMillis();log.logFine("Condensing for '" + entry.normalizedURLString() + "'");plasmaCondenser condenser = new plasmaCondenser(new ByteArrayInputStream(document.getText()));-+// generate citation referencegenerateCitationReference(entry.urlHash(), docDate, document, condenser);@@ -1215,18 +1229,18 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser// "responseHeader=" + entry.responseHeader().toString());plasmaCrawlLURL.Entry newEntry = urlPool.loadedURL.addEntry(- entry.url(), descr, docDate, new Date(),- initiatorHash,- yacyCore.seedDB.mySeed.hash,- referrerHash,- 0, true,- condenser.RESULT_INFORMATION_VALUE,- plasmaWordIndexEntry.language(entry.url()),- plasmaWordIndexEntry.docType(document.getMimeType()),- entry.size(),- condenser.RESULT_NUMB_WORDS,- processCase- );+ entry.url(), descr, docDate, new Date(),+ initiatorHash,+ yacyCore.seedDB.mySeed.hash,+ referrerHash,+ 0, true,+ condenser.RESULT_INFORMATION_VALUE,+ plasmaWordIndexEntry.language(entry.url()),+ plasmaWordIndexEntry.docType(document.getMimeType()),+ entry.size(),+ condenser.RESULT_NUMB_WORDS,+ processCase+ );String urlHash = newEntry.hash();@@ -1239,11 +1253,11 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser//log.logDebug("Create Index for '" + entry.normalizedURLString() + "'");storageStartTime = System.currentTimeMillis();int words = 0;- String storagePeerHash;+ String storagePeerHash;yacySeed seed;- if (((storagePeerHash = getConfig("storagePeerHash",null))== null) ||- (storagePeerHash.trim().length() == 0) ||- ((seed = yacyCore.seedDB.getConnected(storagePeerHash))==null)){+ if (((storagePeerHash = getConfig("storagePeerHash",null))== null) ||+ (storagePeerHash.trim().length() == 0) ||+ ((seed = yacyCore.seedDB.getConnected(storagePeerHash))==null)){words = wordIndex.addPageIndex(entry.url(), urlHash, docDate, condenser, plasmaWordIndexEntry.language(entry.url()), plasmaWordIndexEntry.docType(document.getMimeType()));} else {HashMap urlCache = new HashMap(1);@@ -1256,7 +1270,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serquality = condenser.RESULT_INFORMATION_VALUE;} catch (NumberFormatException e) {System.out.println("INTERNAL ERROR WITH CONDENSER.INFORMATION_VALUE: " + e.toString() + ": in URL " + newEntry.url().toString());- }+ }String language = plasmaWordIndexEntry.language(entry.url());char doctype = plasmaWordIndexEntry.docType(document.getMimeType());@@ -1270,13 +1284,13 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serString wordHash = plasmaWordIndexEntry.word2hash(word);plasmaWordIndexEntity wordIdxEntity = new plasmaWordIndexEntity(wordHash);plasmaWordIndexEntry wordIdxEntry = new plasmaWordIndexEntry(urlHash, count, p++, 0, 0,- plasmaWordIndex.microDateDays(docDate), quality, language, doctype, true);+ plasmaWordIndex.microDateDays(docDate), quality, language, doctype, true);wordIdxEntity.addEntry(wordIdxEntry);tmpEntities.add(wordIdxEntity);// wordIndex.addEntries(plasmaWordIndexEntryContainer.instantContainer(wordHash, System.currentTimeMillis(), entry));}//System.out.println("DEBUG: plasmaSearch.addPageIndex: added " + condenser.getWords().size() + " words, flushed " + c + " entries");- words = condenser.getWords().size();+ words = condenser.getWords().size();// transfering the index to the storage peerString error = yacyClient.transferIndex(seed,(plasmaWordIndexEntity[])tmpEntities.toArray(new plasmaWordIndexEntity[tmpEntities.size()]),urlCache,true,120000);@@ -1294,16 +1308,16 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serstorageEndTime = System.currentTimeMillis();if (log.isLoggable(Level.INFO)) {- log.logInfo("*Indexed " + words + " words in URL " + entry.url() +- " [" + entry.urlHash() + "]" +- "\n\tDescription: " + descr +- "\n\tMimeType: " + document.getMimeType() + " | " +- "Size: " + document.text.length + " bytes | " +- "Anchors: " + ((document.anchors==null)?0:document.anchors.size()) +- "\n\tStackingTime: " + (stackEndTime-stackStartTime) + " ms | " +- "ParsingTime: " + (parsingEndTime-parsingStartTime) + " ms | " +- "IndexingTime: " + (indexingEndTime-indexingStartTime) + " ms | " +- "StorageTime: " + (storageEndTime-storageStartTime) + " ms");+ log.logInfo("*Indexed " + words + " words in URL " + entry.url() ++ " [" + entry.urlHash() + "]" ++ "\n\tDescription: " + descr ++ "\n\tMimeType: " + document.getMimeType() + " | " ++ "Size: " + document.text.length + " bytes | " ++ "Anchors: " + ((document.anchors==null)?0:document.anchors.size()) ++ "\n\tStackingTime: " + (stackEndTime-stackStartTime) + " ms | " ++ "ParsingTime: " + (parsingEndTime-parsingStartTime) + " ms | " ++ "IndexingTime: " + (indexingEndTime-indexingStartTime) + " ms | " ++ "StorageTime: " + (storageEndTime-storageStartTime) + " ms");}// if this was performed for a remote crawl request, notify requester@@ -1324,16 +1338,16 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser} else {log.logInfo("Not indexed any word in URL " + entry.url() + "; cause: " + noIndexReason);urlPool.errorURL.newEntry(entry.url(), referrerHash,- ((entry.proxy()) ? plasmaURL.dummyHash : entry.initiator()),- yacyCore.seedDB.mySeed.hash,- descr, noIndexReason, new bitfield(plasmaURL.urlFlagLength), true);+ ((entry.proxy()) ? plasmaURL.dummyHash : entry.initiator()),+ yacyCore.seedDB.mySeed.hash,+ descr, noIndexReason, new bitfield(plasmaURL.urlFlagLength), true);if ((processCase == 6) && (initiator != null)) {yacyClient.crawlReceipt(initiator, "crawl", "rejected", noIndexReason, null, "");}}document = null;-+} catch (IOException e) {log.logSevere("ERROR in plasmaSwitchboard.process(): " + e.toString());} finally {@@ -1356,7 +1370,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serentry = null;}}-+private void generateCitationReference(String baseurlhash, Date docDate, plasmaParserDocument document, plasmaCondenser condenser) {// generate citation referenceMap hl = document.getHyperlinks();@@ -1383,19 +1397,19 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser// append this reference to buffer// generate header infoString head = baseurlhash + "=" +- plasmaWordIndex.microDateHoursStr(docDate.getTime()) + // latest update timestamp of the URL- plasmaWordIndex.microDateHoursStr(System.currentTimeMillis()) + // last visit timestamp of the URL- serverCodings.enhancedCoder.encodeBase64LongSmart(LCount, 2) + // count of links to local resources- serverCodings.enhancedCoder.encodeBase64LongSmart(GCount, 2) + // count of links to global resources- serverCodings.enhancedCoder.encodeBase64LongSmart(document.getImages().size(), 2) + // count of Images in document- serverCodings.enhancedCoder.encodeBase64LongSmart(0, 2) + // count of links to other documents- serverCodings.enhancedCoder.encodeBase64LongSmart(document.getText().length, 3) + // length of plain text in bytes- serverCodings.enhancedCoder.encodeBase64LongSmart(condenser.RESULT_NUMB_WORDS, 3) + // count of all appearing words- serverCodings.enhancedCoder.encodeBase64LongSmart(condenser.RESULT_SIMI_WORDS, 3) + // count of all unique words- serverCodings.enhancedCoder.encodeBase64LongSmart(0, 1); // Flags (update, popularity, attention, vote)-+ plasmaWordIndex.microDateHoursStr(docDate.getTime()) + // latest update timestamp of the URL+ plasmaWordIndex.microDateHoursStr(System.currentTimeMillis()) + // last visit timestamp of the URL+ serverCodings.enhancedCoder.encodeBase64LongSmart(LCount, 2) + // count of links to local resources+ serverCodings.enhancedCoder.encodeBase64LongSmart(GCount, 2) + // count of links to global resources+ serverCodings.enhancedCoder.encodeBase64LongSmart(document.getImages().size(), 2) + // count of Images in document+ serverCodings.enhancedCoder.encodeBase64LongSmart(0, 2) + // count of links to other documents+ serverCodings.enhancedCoder.encodeBase64LongSmart(document.getText().length, 3) + // length of plain text in bytes+ serverCodings.enhancedCoder.encodeBase64LongSmart(condenser.RESULT_NUMB_WORDS, 3) + // count of all appearing words+ serverCodings.enhancedCoder.encodeBase64LongSmart(condenser.RESULT_SIMI_WORDS, 3) + // count of all unique words+ serverCodings.enhancedCoder.encodeBase64LongSmart(0, 1); // Flags (update, popularity, attention, vote)+//crl.append(head); crl.append ('|'); crl.append(cpl); crl.append((char) 13); crl.append((char) 10);- crg.append(head); crg.append ('|'); crg.append(cpg); crg.append((char) 13); crg.append((char) 10);+ crg.append(head); crg.append('|'); crg.append(cpg); crg.append((char) 13); crg.append((char) 10);// if buffer is full, flush it./*@@ -1456,14 +1470,14 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serlog.logInfo("REMOTECRAWLTRIGGER[" + urlPool.noticeURL.stackSize(plasmaCrawlNURL.STACK_TYPE_CORE) + ", " + urlPool.noticeURL.stackSize(plasmaCrawlNURL.STACK_TYPE_REMOTE) + "]: urlEntry=null");return true; // superfluous request; true correct in this context}-+// are we qualified?if ((yacyCore.seedDB.mySeed == null) ||- (yacyCore.seedDB.mySeed.isJunior())) {+ (yacyCore.seedDB.mySeed.isJunior())) {log.logFine("plasmaSwitchboard.processRemoteCrawlTrigger: no permission");return false;}-+// check urlif (urlEntry.url() == null) {log.logFine("ERROR: plasmaSwitchboard.processRemoteCrawlTrigger - url is null. name=" + urlEntry.name());@@ -1476,12 +1490,12 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serif (remoteSeed == null) {log.logFine("plasmaSwitchboard.processRemoteCrawlTrigger: no remote crawl seed available");- return false;+ return false;}// do the requestHashMap page = yacyClient.crawlOrder(remoteSeed, urlEntry.url(), urlPool.getURL(urlEntry.referrerHash()));-+// check success/*@@ -1489,24 +1503,24 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements sernegative cases, no retrydenied - the peer does not want to crawl thatexception - an exception occurred-+negative case, retry possiblerejected - the peer has rejected to process, but a re-try should be possiblepositive case with crawlingstacked - the resource is processed asap-- positive case without crawling++ positive case without crawlingdouble - the resource is already in database, believed to be fresh and not reloadedthe resource is also returned in lurl- */+ */if ((page == null) || (page.get("delay") == null)) {log.logInfo("CRAWL: REMOTE CRAWL TO PEER " + remoteSeed.getName() + " FAILED. CAUSE: unknown (URL=" + urlEntry.url().toString() + ")");if (remoteSeed != null) yacyCore.peerActions.peerDeparture(remoteSeed);return false;} else try {log.logFine("plasmaSwitchboard.processRemoteCrawlTrigger: remoteSeed=" + remoteSeed.getName() + ", url=" + urlEntry.url().toString() + ", response=" + page.toString()); // DEBUG-+int newdelay = Integer.parseInt((String) page.get("delay"));yacyCore.dhtAgent.setCrawlDelay(remoteSeed.hash, newdelay);String response = (String) page.get("response");@@ -1516,11 +1530,11 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser} else if (response.equals("double")) {String lurl = (String) page.get("lurl");if ((lurl != null) && (lurl.length() != 0)) {- String propStr = crypt.simpleDecode(lurl, (String) page.get("key"));+ String propStr = crypt.simpleDecode(lurl, (String) page.get("key"));plasmaCrawlLURL.Entry entry = urlPool.loadedURL.addEntry(- urlPool.loadedURL.newEntry(propStr, true),- yacyCore.seedDB.mySeed.hash, remoteSeed.hash, 1);- urlPool.noticeURL.remove(entry.hash());+ urlPool.loadedURL.newEntry(propStr, true),+ yacyCore.seedDB.mySeed.hash, remoteSeed.hash, 1);+ urlPool.noticeURL.remove(entry.hash());log.logInfo(STR_REMOTECRAWLTRIGGER + remoteSeed.getName() + " SUPERFLUOUS. CAUSE: " + page.get("reason") + " (URL=" + urlEntry.url().toString() + "). URL IS CONSIDERED AS 'LOADED!'");return true;} else {@@ -1540,22 +1554,22 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serprivate static SimpleDateFormat DateFormatter = new SimpleDateFormat("EEE, dd MMM yyyy");public static String dateString(Date date) {- if (date == null) return ""; else return DateFormatter.format(date);+ if (date == null) return ""; else return DateFormatter.format(date);}//public serverObjects searchFromLocal(Set querywords, String order1, String order2, int count, boolean global, long time /*milliseconds*/, String urlmask) {public serverObjects searchFromLocal(plasmaSearchQuery query) {- // tell all threads to do nothing for a specific time+ // tell all threads to do nothing for a specific time//log.logInfo("A");- wordIndex.intermission(2 * query.maximumTime);- //log.logInfo("B");- intermissionAllThreads(2 * query.maximumTime);+ wordIndex.intermission(2 * query.maximumTime);+ //log.logInfo("B");+ intermissionAllThreads(2 * query.maximumTime);//log.logInfo("C");-+serverObjects prop = new serverObjects();//log.logInfo("D");- try {+ try {// filter out words that appear in bluelist//log.logInfo("E");query.filterOut(blueList);@@ -1624,7 +1638,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serurlname = urlstring;}descr = urlentry.descr();-+// check bluelist again: filter out all links where any bluelisted word// appear either in url, url's description or search word// the search word was sorted out earlier@@ -1646,7 +1660,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serprop.put("results_" + i + "_urlhash", urlhash);prop.put("results_" + i + "_urlname", urlname);prop.put("results_" + i + "_date", dateString(urlentry.moddate()));- prop.put("results_" + i + "_size", Long.toString(urlentry.size()));+ prop.put("results_" + i + "_size", Long.toString(urlentry.size()));prop.put("results_" + i + "_words",URLEncoder.encode(query.queryWords.toString(),"UTF-8"));// adding snippet if availableif (snippet.line == null) {@@ -1661,7 +1675,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser}}log.logFine("SEARCH TIME AFTER RESULT PREPARATION: " + ((System.currentTimeMillis() - timestamp) / 1000) + " seconds");-+// calc some more cross-referencelong remainingTime = query.maximumTime - (System.currentTimeMillis() - timestamp);if (remainingTime < 0) remainingTime = 1000;@@ -1670,7 +1684,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serurlentry = acc.nextElement();urlstring = htmlFilterContentScraper.urlNormalform(urlentry.url());descr = urlentry.descr();-+addScoreForked(ref, gs, descr.split(" "));addScoreForked(ref, gs, urlstring.split("/"));}@@ -1678,7 +1692,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser//Object[] ws = ref.getScores(16, false, 2, Integer.MAX_VALUE);Object[] ws = acc.getReferences(16);log.logFine("SEARCH TIME AFTER XREF PREPARATION: " + ((System.currentTimeMillis() - timestamp) / 1000) + " seconds");-+/*System.out.print("DEBUG WORD-SCORE: ");for (int ii = 0; ii < ws.length; ii++) System.out.print(ws[ii] + ", ");@@ -1693,7 +1707,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serlog.logInfo("EXIT WORD SEARCH: " + query.queryWords + " - " +prop.get("totalcount", "0") + " links found, " +prop.get("orderedcount", "0") + " links ordered, " +- prop.get("linkcount", "?") + " links selected, " ++ prop.get("linkcount", "?") + " links selected, " +((System.currentTimeMillis() - timestamp) / 1000) + " seconds");return prop;} catch (IOException e) {@@ -1702,11 +1716,11 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser}public serverObjects searchFromRemote(plasmaSearchQuery query) {-- // tell all threads to do nothing for a specific time- wordIndex.intermission(2 * query.maximumTime);- intermissionAllThreads(2 * query.maximumTime);-++ // tell all threads to do nothing for a specific time+ wordIndex.intermission(2 * query.maximumTime);+ intermissionAllThreads(2 * query.maximumTime);+query.domType = plasmaSearchQuery.SEARCHDOM_LOCAL;serverObjects prop = new serverObjects();@@ -1764,7 +1778,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser// loglog.logInfo("EXIT HASH SEARCH: " + query.queryHashes + " - " + idxc + " links found, " +- prop.get("linkcount", "?") + " links selected, " ++ prop.get("linkcount", "?") + " links selected, " +((System.currentTimeMillis() - timestamp) / 1000) + " seconds");return prop;} catch (IOException e) {@@ -1774,16 +1788,16 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements serpublic serverObjects action(String actionName, serverObjects actionInput) {- // perform an action. (not used)-- return null;+ // perform an action. (not used)++ return null;}--++public String toString() {- // it is possible to use this method in the cgi pages.- // actually it is used there for testing purpose- return "PROPS: " + super.toString() + "; QUEUE: " + sbQueue.toString();+ // it is possible to use this method in the cgi pages.+ // actually it is used there for testing purpose+ return "PROPS: " + super.toString() + "; QUEUE: " + sbQueue.toString();}// method for index deletiondiff --git a/source/de/anomic/server/serverCodings.java b/source/de/anomic/server/serverCodings.javaindex 2efff5508..d82234209 100644--- a/source/de/anomic/server/serverCodings.java+++ b/source/de/anomic/server/serverCodings.java@@ -41,6 +41,7 @@package de.anomic.server;import java.io.BufferedInputStream;+import java.io.ByteArrayInputStream;import java.io.File;import java.io.FileInputStream;import java.io.InputStream;@@ -254,6 +255,10 @@ public final class serverCodings {return encodeHex(encodeMD5Raw(file));}+ public static String encodeMD5Hex(byte[] b) {+ // generate a hex representation from the md5 of a byte-array+ return encodeHex(encodeMD5Raw(b));+ }private static byte[] encodeMD5Raw(String key) {try {@@ -288,6 +293,25 @@ public final class serverCodings {return null;}+ private static byte[] encodeMD5Raw(byte[] b) {+ try {+ MessageDigest digest = MessageDigest.getInstance("MD5");+ digest.reset();+ InputStream in = new ByteArrayInputStream(b);+ byte[] buf = new byte[2048];+ int n;+ while ((n = in.read(buf)) > 0) digest.update(buf, 0, n);+ in.close();+ // now compute the hex-representation of the md5 digest+ return digest.digest();+ } catch (java.security.NoSuchAlgorithmException e) {+ System.out.println("Internal Error at md5:" + e.getMessage());+ } catch (java.io.IOException e) {+ System.out.println("byte[] error: " + e.getMessage());+ }+ return null;+ }+public static Properties s2p(String s) {Properties p = new Properties();int pos;diff --git a/source/de/anomic/server/serverCore.java b/source/de/anomic/server/serverCore.javaindex 0e995cd06..89de323c4 100644--- a/source/de/anomic/server/serverCore.java+++ b/source/de/anomic/server/serverCore.java@@ -308,23 +308,24 @@ public final class serverCore extends serverAbstractThread implements serverThretry {// if a static IP was configured, we have to return it here ...- plasmaSwitchboard sb = plasmaSwitchboard.getSwitchboard();- if(sb != null){- String staticIP=sb.getConfig("staticIP", "");- if( (!staticIP.equals("")) && sb.getConfig("yacyDebugMode", "false").equals("true") ){- return staticIP;- }- }+ plasmaSwitchboard sb = plasmaSwitchboard.getSwitchboard();+ if(sb != null){+ String staticIP=sb.getConfig("staticIP", "");+ if( (!staticIP.equals("")) && sb.getConfig("yacyDebugMode", "false").equals("true") ){+ return staticIP;+ }+ }- // If port forwarding was enabled we need to return the remote IP Address+ // If port forwarding was enabled we need to return the remote IP Addressif ((serverCore.portForwardingEnabled)&&(serverCore.portForwarding != null)) {- //does not return serverCore.portForwarding.getHost(), because hostnames are not valid, except in DebugMode+ //does not return serverCore.portForwarding.getHost(), because hostnames are not valid, except in DebugModereturn InetAddress.getByName(serverCore.portForwarding.getHost()).getHostAddress();}// otherwise we return the real IP address of this host- return publicLocalIP().getHostAddress();-+ InetAddress pLIP = publicLocalIP();+ if (pLIP != null) return pLIP.getHostAddress();+ return null;} catch (java.net.UnknownHostException e) {System.err.println("ERROR: (internal) " + e.getMessage());return null;diff --git a/source/de/anomic/server/serverObjects.java b/source/de/anomic/server/serverObjects.javaindex 3be0bb555..440c57ff7 100644--- a/source/de/anomic/server/serverObjects.java+++ b/source/de/anomic/server/serverObjects.java@@ -123,14 +123,14 @@ public final class serverObjects extends Hashtable implements Cloneable {}// new get with default objects- public Object get(Object key, Object dflt) {+ public Object get(String key, Object dflt) {Object result = super.get(key);if (result == null) return dflt; else return result;}// string variantpublic String get(String key, String dflt) {- return (String) this.get((Object) key, (Object) dflt);+ return (String) this.get(key, (Object) dflt);}public int getInt(String key, int dflt) {diff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.javaindex 4b0a40eef..f2029d9e8 100644--- a/source/de/anomic/yacy/yacyClient.java+++ b/source/de/anomic/yacy/yacyClient.java@@ -61,6 +61,7 @@ import de.anomic.plasma.plasmaWordIndex;import de.anomic.plasma.plasmaSearchProfile;import de.anomic.server.serverCore;import de.anomic.server.serverObjects;+import de.anomic.server.serverCodings;import de.anomic.tools.crypt;import de.anomic.tools.nxTools;import de.anomic.yacy.yacySeed;@@ -125,7 +126,8 @@ public final class yacyClient {null,null,(useProxy)?yacyCore.seedDB.sb.remoteProxyConfig:null,- obj+ obj,+ null));} catch (Exception e) {@@ -407,7 +409,8 @@ public final class yacyClient {null,null,(useProxy)?yacyCore.seedDB.sb.remoteProxyConfig:null,- obj+ obj,+ null));@@ -506,18 +509,8 @@ public final class yacyClient {post.put("youare", targetHash);post.put(yacySeed.MYTIME, yacyCore.universalDateShortString(new Date()));- // getting target address- String address;- if (targetHash.equals(yacyCore.seedDB.mySeed.hash)) {- address = yacyCore.seedDB.mySeed.getAddress();- //System.out.println("local address: " + address);- } else {- final yacySeed targetSeed = yacyCore.seedDB.getConnected(targetHash);- if (targetSeed == null) { return null; }- address = targetSeed.getAddress();- //System.out.println("remote address: " + address);- }- if (address == null) { address = "localhost:8080"; }+ // get target address+ String address = targetAddress(targetHash);// sending requesttry {@@ -528,7 +521,8 @@ public final class yacyClient {null,null,(useProxy)?yacyCore.seedDB.sb.remoteProxyConfig:null,- post+ post,+ null));} catch (Exception e) {@@ -557,24 +551,112 @@ public final class yacyClient {post.put(yacySeed.MYTIME, yacyCore.universalDateShortString(new Date()));post.put("message", new String(message));- // getting target address+ // get target address+ String address = targetAddress(targetHash);++ // sending request+ try {+ final ArrayList v = httpc.wput(+ new URL("http://" + address + "/yacy/message.html"),+ 20000,+ null,+ null,+ (useProxy)?yacyCore.seedDB.sb.remoteProxyConfig:null,+ post,+ null+ );++ return nxTools.table(v);+ } catch (Exception e) {+ yacyCore.log.logSevere("yacyClient.postMessage error:" + e.getMessage());+ return null;+ }+ }+++ public static String targetAddress(String targetHash) {+ // find target addressString address;if (targetHash.equals(yacyCore.seedDB.mySeed.hash)) {address = yacyCore.seedDB.mySeed.getAddress();} else {- address = yacyCore.seedDB.getConnected(targetHash).getAddress();+ final yacySeed targetSeed = yacyCore.seedDB.getConnected(targetHash);+ if (targetSeed == null) { return null; }+ address = targetSeed.getAddress();}- if (address == null) { address = "localhost:8080"; }+ if (address == null) address = "localhost:8080";+ return address;+ }++ public static HashMap transferPermission(String targetAddress, long filesize, String filename) {+ // should we use the proxy?+ boolean useProxy = (yacyCore.seedDB != null) &&+ (yacyCore.seedDB.sb.remoteProxyConfig != null) &&+ (yacyCore.seedDB.sb.remoteProxyConfig.useProxy()) &&+ (yacyCore.seedDB.sb.remoteProxyConfig.useProxy4Yacy());++ // add all needed parameters+ final String key = crypt.randomSalt();+ final serverObjects post = new serverObjects();+ post.put("key", key);+ post.put("process", "permission");+ post.put("iam", yacyCore.seedDB.mySeed.hash);+ post.put("purpose", "crcon");+ post.put("filename", filename);+ post.put("filesize", Long.toString(filesize));+ post.put("can-send-protocol", "http");++ // send request+ try {+ return nxTools.table(+ httpc.wput(+ new URL("http://" + targetAddress + "/yacy/transfer.html"),+ 8000,+ null,+ null,+ (useProxy)?yacyCore.seedDB.sb.remoteProxyConfig:null,+ post,+ null+ )+ );+ } catch (Exception e) {+ // most probably a network time-out exception+ yacyCore.log.logSevere("yacyClient.permissionTransfer error:" + e.getMessage());+ return null;+ }+ }++ public static HashMap transferStore(String targetAddress, String access, String filename, byte[] file) {+ // should we use the proxy?+ boolean useProxy = (yacyCore.seedDB != null) &&+ (yacyCore.seedDB.sb.remoteProxyConfig != null) &&+ (yacyCore.seedDB.sb.remoteProxyConfig.useProxy()) &&+ (yacyCore.seedDB.sb.remoteProxyConfig.useProxy4Yacy());++ // adding all needed parameters+ final String key = crypt.randomSalt();+ final serverObjects post = new serverObjects(7);+ post.put("key", key);+ post.put("process", "store");+ post.put("iam", yacyCore.seedDB.mySeed.hash);+ post.put("purpose", "crcon");+ post.put("filename", filename);+ post.put("filesize", Long.toString(file.length));+ post.put("md5", serverCodings.encodeMD5Hex(file));+ post.put("access", access);+ HashMap files = new HashMap();+ files.put("filename", file);// sending requesttry {final ArrayList v = httpc.wput(- new URL("http://" + address + "/yacy/message.html"),+ new URL("http://" + targetAddress + "/yacy/transfer.html"),20000,null,null,(useProxy)?yacyCore.seedDB.sb.remoteProxyConfig:null,- post+ post,+ files);return nxTools.table(v);@@ -583,7 +665,32 @@ public final class yacyClient {return null;}}-++ public static String transfer(String targetAddress, String filename, byte[] file) {+ HashMap phase1 = transferPermission(targetAddress, file.length, filename);+ if (phase1 == null) return "no connection to remote address " + targetAddress + "; phase 1";+ String access = (String) phase1.get("access");+ String nextaddress = (String) phase1.get("address");+ String protocol = (String) phase1.get("protocol");+ String path = (String) phase1.get("path");+ String maxsize = (String) phase1.get("maxsize");+ String response = (String) phase1.get("response");+ if ((response == null) || (protocol == null) || (access == null)) return "wrong return values from other peer; phase 1";+ if (!(response.equals("ok"))) return "remote peer rejected transfer: " + response;+ String accesscode = serverCodings.encodeMD5Hex(serverCodings.standardCoder.encodeBase64String(access));+ if (protocol.equals("http")) {+ HashMap phase2 = transferStore(nextaddress, accesscode, filename, file);+ if (phase2 == null) return "no connection to remote address " + targetAddress + "; phase 2";+ response = (String) phase2.get("response");+ if (response == null) return "wrong return values from other peer; phase 2";+ if (!(response.equals("ok"))) {+ return "remote peer failed with transfer: " + response;+ }+ return null;+ }+ return "wrong protocol: " + protocol;+ }+public static HashMap crawlOrder(yacySeed targetSeed, URL url, URL referrer) {// this post a message to the remote message boardif (targetSeed == null) { return null; }@@ -621,7 +728,8 @@ public final class yacyClient {null,null,(useProxy)?yacyCore.seedDB.sb.remoteProxyConfig:null,- post+ post,+ null));} catch (Exception e) {@@ -797,7 +905,8 @@ public final class yacyClient {null,null,(useProxy)?yacyCore.seedDB.sb.remoteProxyConfig:null,- post+ post,+ null);// this should return a list of urlhashes that are unknwonif (v != null) {@@ -853,7 +962,8 @@ public final class yacyClient {null,null,(useProxy)?yacyCore.seedDB.sb.remoteProxyConfig:null,- post+ post,+ null);if (v != null) {@@ -886,7 +996,8 @@ public final class yacyClient {null,null,(useProxy)?yacyCore.seedDB.sb.remoteProxyConfig:null,- post+ post,+ null);return nxTools.table(v);diff --git a/source/de/anomic/yacy/yacyCore.java b/source/de/anomic/yacy/yacyCore.javaindex b8ded14ca..2721624a4 100644--- a/source/de/anomic/yacy/yacyCore.java+++ b/source/de/anomic/yacy/yacyCore.java@@ -398,7 +398,12 @@ public class yacyCore {} catch (IOException e) {log.logSevere("publishMySeed: problem with news encoding", e);}-+ seedDB.mySeed.setUnusedFlags();++ // include current citation-rank file count+ seedDB.mySeed.put(yacySeed.CRWCNT, Integer.toString(switchboard.rankingOwnDistribution.size()));+ seedDB.mySeed.put(yacySeed.CRTCNT, Integer.toString(switchboard.rankingOtherDistribution.size()));+// holding a reference to all started threadsint contactedSeedCount = 0;final List syncList = Collections.synchronizedList(new LinkedList()); // memory for threadsdiff --git a/source/de/anomic/yacy/yacySeed.java b/source/de/anomic/yacy/yacySeed.javaindex 376b0027f..55db2486f 100644--- a/source/de/anomic/yacy/yacySeed.java+++ b/source/de/anomic/yacy/yacySeed.java@@ -108,7 +108,9 @@ public class yacySeed {public static final String NCOUNT = "NCount";public static final String ICOUNT = "ICount";public static final String SCOUNT = "SCount";- public static final String CCOUNT = "CCount";+ public static final String CCOUNT = "CCount"; // Connection Count+ public static final String CRWCNT = "CRWCnt"; // Citation Rank (Own) - Count+ public static final String CRTCNT = "CRTCnt"; // Citation Rank (Other) - Countpublic static final String IP = "IP";public static final String PORT = "Port";@@ -159,12 +161,16 @@ public class yacySeed {this.dna.put(LASTSEEN, yacyCore.universalDateShortString(new Date())); // for last-seen datethis.dna.put(USPEED, "0"); // the computated uplink speed of the peer+ this.dna.put(CRWCNT, "0");+ this.dna.put(CRTCNT, "0");+// settings that are needed to organize the seed round-tripthis.dna.put(FLAGS, "0000");setFlagDirectConnect(false);setFlagAcceptRemoteCrawl(true);setFlagAcceptRemoteIndex(true);-+ setUnusedFlags();+// index transferthis.dna.put(INDEX_OUT, "0"); // send indexthis.dna.put(INDEX_IN, "0"); // received Index@@ -368,6 +374,9 @@ public class yacySeed {//if (getVersion() < 0.335) return false;return getFlag(2);}+ public void setUnusedFlags() {+ for (int i = 3; i < 24; i++) setFlag(i, true);+ }public boolean isVirgin() {return get(PEERTYPE, "").equals(PEERTYPE_VIRGIN);}@@ -515,6 +524,13 @@ public class yacySeed {return newSeed;}+ public static String randomHash() {+ String hash =+ serverCodings.encodeMD5B64(System.currentTimeMillis() + "a", true).substring(0, 6) ++ serverCodings.encodeMD5B64(System.currentTimeMillis() + "b", true).substring(0, 6);+ return hash;+ }+public static yacySeed genRemoteSeed(String seedStr, String key) {// this method is used to convert the external representation of a seed into a seed object// yacyCore.log.logFinest("genRemoteSeed: seedStr=" + seedStr + " key=" + key);diff --git a/source/de/anomic/yacy/yacySeedDB.java b/source/de/anomic/yacy/yacySeedDB.javaindex 5c26b2716..a8e744c67 100644--- a/source/de/anomic/yacy/yacySeedDB.java+++ b/source/de/anomic/yacy/yacySeedDB.java@@ -224,83 +224,45 @@ public final class yacySeedDB {public Enumeration seedsSortedConnected(boolean up, String field) {// enumerates seed-type objects: all seeds sequentially ordered by field- return new seedEnum(up, field, seedActiveDB);+ return new seedEnum(up, field, seedActiveDB);}public Enumeration seedsSortedDisconnected(boolean up, String field) {// enumerates seed-type objects: all seeds sequentially ordered by field- return new seedEnum(up, field, seedPassiveDB);+ return new seedEnum(up, field, seedPassiveDB);}public Enumeration seedsSortedPotential(boolean up, String field) {// enumerates seed-type objects: all seeds sequentially ordered by field- return new seedEnum(up, field, seedPotentialDB);+ return new seedEnum(up, field, seedPotentialDB);}-+public Enumeration seedsConnected(boolean up, boolean rot, String firstHash) {// enumerates seed-type objects: all seeds sequentially without order- return new seedEnum(up, rot, (firstHash == null) ? null : firstHash.getBytes(), seedActiveDB);+ return new seedEnum(up, rot, (firstHash == null) ? null : firstHash.getBytes(), seedActiveDB);}public Enumeration seedsDisconnected(boolean up, boolean rot, String firstHash) {// enumerates seed-type objects: all seeds sequentially without order- return new seedEnum(up, rot, (firstHash == null) ? null : firstHash.getBytes(), seedPassiveDB);+ return new seedEnum(up, rot, (firstHash == null) ? null : firstHash.getBytes(), seedPassiveDB);}-+public Enumeration seedsPotential(boolean up, boolean rot, String firstHash) {// enumerates seed-type objects: all seeds sequentially without order- return new seedEnum(up, rot, (firstHash == null) ? null : firstHash.getBytes(), seedPotentialDB);+ return new seedEnum(up, rot, (firstHash == null) ? null : firstHash.getBytes(), seedPotentialDB);}- public yacySeed anySeed() {- // return just any probe candidate- yacySeed seed;- if ((seedQueue == null) || (seedQueue.size() == 0)) {- if (seedActiveDB.size() <= 0) return null;-- // fill up the queue- seedQueue = new disorderHeap();- Iterator keyIt;- try {- keyIt = seedActiveDB.keys(true, false); // iteration of String - Objects- } catch (IOException e) {- yacyCore.log.logSevere("yacySeedCache.anySeed: seed.db not available: " + e.getMessage());- keyIt = (new HashSet()).iterator();- }- String seedHash;- String myIP = (mySeed == null) ? "" : ((String) mySeed.get(yacySeed.IP, "127.0.0.1"));- while (keyIt.hasNext()) {- seedHash = (String) keyIt.next();- try {- seed = new yacySeed(seedHash, seedActiveDB.get(seedHash));- // check here if the seed is equal to the own seed- // this should never be the case, but it happens if a redistribution circle exists- if ((mySeed != null) && (seedHash.equals(mySeed.hash))) {- // this seed should not be in the database- seedActiveDB.remove(seedHash);- } else {- // add to queue- seedQueue.add(seed);- }- } catch (IOException e) {}+ public yacySeed anySeedVersion(float minVersion) {+ // return just any seed that has a specific minimum version number+ yacySeed seed;+ Enumeration e = seedsConnected(true, true, yacySeed.randomHash());+ int maxtry = seedActiveDB.size();+ for (int i = 0; i < maxtry; i++) {+ seed = (yacySeed) e.nextElement();+ System.out.println("ENUMSEED: " + ((seed == null) ? "NULL" : seed.getName()));+ if ((seed != null) && (seed.getVersion() >= minVersion)) return seed;}- // the queue is filled up!- }- if ((seedQueue == null) || (seedQueue.size() == 0)) return null;- return (yacySeed) seedQueue.remove();- }-- public yacySeed anySeedType(String type) {- // this returns any seed that has a special PeerType- yacySeed ys;- String t;- for (int i = 0; i < seedActiveDB.size(); i++) {- ys = anySeed();- if (ys == null) return null;- t = (String) ys.get(yacySeed.PEERTYPE, "");- if ((t != null) && (t.equals(type))) return ys;- }- return null;+ return null;}public yacySeed[] seedsByAge(boolean up, int count) {@@ -648,8 +610,9 @@ public final class yacySeedDB {// store other seedsyacySeed ys;- for (int i = 0; i < seedActiveDB.size(); i++) {- ys = anySeed();+ Enumeration se = seedsConnected(true, false, null);+ while (se.hasMoreElements()) {+ ys = (yacySeed) se.nextElement();if (ys != null) {line = ys.genSeedStr(null);v.add(line);diff --git a/source/de/anomic/yacy/yacyVersion.java b/source/de/anomic/yacy/yacyVersion.javaindex 8ee1c898b..b4f671743 100644--- a/source/de/anomic/yacy/yacyVersion.java+++ b/source/de/anomic/yacy/yacyVersion.java@@ -3,4 +3,5 @@ package de.anomic.yacy;public final class yacyVersion {public static final float YACY_SUPPORTS_PORT_FORWARDING = (float) 0.383;public static final float YACY_SUPPORTS_GZIP_POST_REQUESTS = (float) 0.40300772;+ public static final float YACY_ACCEPTS_RANKING_TRANSMISSION = (float) 0.414;}diff --git a/source/yacy.java b/source/yacy.javaindex c9e3cc81f..ab8388517 100644--- a/source/yacy.java+++ b/source/yacy.java@@ -83,6 +83,7 @@ import de.anomic.server.serverSystem;import de.anomic.server.logging.serverLog;import de.anomic.tools.enumerateFiles;import de.anomic.yacy.yacyCore;+import de.anomic.yacy.yacyClient;/*** This is the main class of the proxy. Several threads are started from here:@@ -1069,6 +1070,20 @@ public final class yacy {serverLog.logConfig("DELETE-STOPWORDS", "FINISHED");}+ private static void transferCR(String targetaddress, String crfile) {+ File f = new File(crfile);+ try {+ byte[] b = serverFileUtils.read(f);+ String result = yacyClient.transfer(targetaddress, f.getName(), b);+ if (result == null)+ serverLog.logInfo("TRANSFER-CR", "transmitted file " + crfile + " to " + targetaddress + " successfully");+ else+ serverLog.logInfo("TRANSFER-CR", "error transmitting file " + crfile + " to " + targetaddress + ": " + result);+ } catch (IOException e) {+ serverLog.logInfo("TRANSFER-CR", "could not read file " + crfile);+ }+ }+/*** Main-method which is started by java. Checks for special arguments or* starts up the application.@@ -1134,6 +1149,11 @@ public final class yacy {int minlength = Integer.parseInt(args[2]);int maxlength = Integer.parseInt(args[3]);cleanwordlist(args[1], minlength, maxlength);+ } else if ((args.length >= 1) && (args[0].equals("-transfercr"))) {+ // transfer a single cr file to a remote peer+ String targetaddress = args[1];+ String crfile = args[2];+ transferCR(targetaddress, crfile);} else {if (args.length == 1) applicationRoot= args[0];startup(applicationRoot, startupMemFree, startupMemTotal);diff --git a/yacy.init b/yacy.initindex 4a3da59fe..008fef66d 100644--- a/yacy.init+++ b/yacy.init@@ -490,10 +490,10 @@ ramCachePreNURL = 4194304# is only valid in unix/shell environments and# not for first startup of YaCy-# -Xms<size> set initial Java heap size+# -Xmx<size> set maximum Java heap sizejavastart_Xmx=Xmx64m-# -Xmx<size> set maximum Java heap size+# -Xms<size> set initial Java heap sizejavastart_Xms=Xms10m