Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

- enhanced ybr ranking computation - many speed/performance hacks - added solr charding and new charding web interface - added option to switch off the yacy index when using solr - added new fail-url categories which are used to make a distinction which fail-urls to be sent to solr - refactoring/renaming of some method names to distinguish host/url hashes better - a large number of bug/npe fixes

orbiter10e2f588f8ea
diff --git a/defaults/yacy.init b/defaults/yacy.init
index c35ced020..12ae4652c 100644
--- a/defaults/yacy.init
+++ b/defaults/yacy.init
@@ -1018,6 +1018,8 @@ color_searchurlhover = #008000
# - extract the solr (3.1) package, 'cd example' and start solr with 'java -jar start.jar'
# - start yacy and then start a crawler. The crawler will fill both, YaCy and solr indexes.
# - to check whats in solr after indexing, open http://localhost:8983/solr/admin/
+federated.service.yacy.indexing.enabled = true
federated.service.solr.indexing.enabled = false
federated.service.solr.indexing.url = http://127.0.0.1:8983/solr
+federated.service.solr.indexing.charding = MODULO_HOST_MD5
federated.service.solr.indexing.scheme = SolrCellExtended
diff --git a/htroot/Bookmarks.java b/htroot/Bookmarks.java
index 61c7e2c90..1147c8cc9 100644
--- a/htroot/Bookmarks.java
+++ b/htroot/Bookmarks.java
@@ -370,10 +370,15 @@ public class Bookmarks {
}
private static void printTagList(final String id, final String tagName, final int comp, final int max, final boolean opt){
- int count=0;
-
- final Iterator<BookmarksDB.Tag> it;
+ if (sb.bookmarksDB == null) {
+ prop.put("display_"+id, 0);
+ return;
+ }
+
+ int count=0;
+ final Iterator<BookmarksDB.Tag> it;
+
if ("".equals(tagName)) {
it = sb.bookmarksDB.getTagIterator(isAdmin, comp, max);
} else {
diff --git a/htroot/Crawler_p.java b/htroot/Crawler_p.java
index 49ac31300..d4f46a508 100644
--- a/htroot/Crawler_p.java
+++ b/htroot/Crawler_p.java
@@ -49,6 +49,7 @@ import net.yacy.kelondro.util.FileUtils;
import de.anomic.crawler.CrawlProfile;
import de.anomic.crawler.SitemapImporter;
+import de.anomic.crawler.ZURL.FailCategory;
import de.anomic.crawler.retrieval.Request;
import de.anomic.data.BookmarkHelper;
import de.anomic.data.WorkTables;
@@ -385,6 +386,7 @@ public class Crawler_p {
sb.peers.mySeed().hash.getBytes(),
new Date(),
1,
+ FailCategory.FINAL_LOAD_CONTEXT,
reasonString, -1);
}
} catch (final PatternSyntaxException e) {
diff --git a/htroot/IndexControlRWIs_p.html b/htroot/IndexControlRWIs_p.html
index 8f80f77fb..7e4368b63 100644
--- a/htroot/IndexControlRWIs_p.html
+++ b/htroot/IndexControlRWIs_p.html
@@ -43,7 +43,9 @@
<dd><input type="checkbox" name="deleteIndex" id="deleteIndex"
onclick="x=document.getElementById('deleteIndex').checked;document.getElementById('deleteRobots').checked=x;document.getElementById('deleteCrawlQueues').checked=x;c='disabled';document.getElementById('deleteSearchFl').checked=x;if(x){c='';}document.getElementById('deletecomplete').disabled=c;document.getElementById('deleteCache').disabled=c;document.getElementById('deleteRobots').disabled=c;document.getElementById('deleteCrawlQueues').disabled=c;document.getElementById('deleteSearchFl').disabled=c;"
/><label for="deleteIndex">Delete Search Index</label><br/>
- #(solr)#::<input type="checkbox" name="deleteSolr" id="deleteSolr" /><label for="deleteSolr">Delete Solr Index</label><br/>#(/solr)#
+ #(solr)#::<input type="checkbox" name="deleteSolr" id="deleteSolr"
+ onclick="x=document.getElementById('deleteSolr').checked;document.getElementById('deleteRobots').checked=x;document.getElementById('deleteCrawlQueues').checked=x;c='disabled';document.getElementById('deleteSearchFl').checked=x;if(x){c='';}document.getElementById('deletecomplete').disabled=c;document.getElementById('deleteCache').disabled=c;document.getElementById('deleteRobots').disabled=c;document.getElementById('deleteCrawlQueues').disabled=c;document.getElementById('deleteSearchFl').disabled=c;"
+ /><label for="deleteSolr">Delete Solr Index</label><br/>#(/solr)#
<input type="checkbox" name="deleteCache" id="deleteCache" disabled="disabled" /><label for="deleteCache">Delete HTTP &amp; FTP Cache</label><br/>
<input type="checkbox" name="deleteCrawlQueues" id="deleteCrawlQueues" disabled="disabled" /><label for="deleteCrawlQueues">Stop Crawler and delete Crawl Queues</label><br/>
<input type="checkbox" name="deleteRobots" id="deleteRobots" disabled="disabled" /><label for="deleteRobots">Delete robots.txt Cache</label><br/>
diff --git a/htroot/IndexControlRWIs_p.java b/htroot/IndexControlRWIs_p.java
index 25c534b7c..c7607ebf0 100644
--- a/htroot/IndexControlRWIs_p.java
+++ b/htroot/IndexControlRWIs_p.java
@@ -185,7 +185,7 @@ public class IndexControlRWIs_p {
index = segment.termIndex().get(keyhash, null);
final Iterator<WordReference> en = index.entries();
urlb = new HandleSet(URIMetadataRow.rowdef.primaryKeyLength, URIMetadataRow.rowdef.objectOrder, index.size());
- while (en.hasNext()) try { urlb.put(en.next().metadataHash()); } catch (RowSpaceExceededException e) { Log.logException(e); }
+ while (en.hasNext()) try { urlb.put(en.next().urlhash()); } catch (RowSpaceExceededException e) { Log.logException(e); }
index = null;
}
if (delurlref) {
@@ -266,16 +266,16 @@ public class IndexControlRWIs_p {
URIMetadataRow lurl;
while (urlIter.hasNext()) {
iEntry = urlIter.next();
- lurl = segment.urlMetadata().load(iEntry.metadataHash());
+ lurl = segment.urlMetadata().load(iEntry.urlhash());
if (lurl == null) {
try {
- unknownURLEntries.put(iEntry.metadataHash());
+ unknownURLEntries.put(iEntry.urlhash());
} catch (RowSpaceExceededException e) {
Log.logException(e);
}
urlIter.remove();
} else {
- knownURLs.put(iEntry.metadataHash(), lurl);
+ knownURLs.put(iEntry.urlhash(), lurl);
}
}
@@ -436,7 +436,7 @@ public class IndexControlRWIs_p {
if (rn == -1) rn = entry.ranking();
prop.put("genUrlList_urlList_"+i+"_urlExists", "1");
prop.put("genUrlList_urlList_"+i+"_urlExists_urlhxCount", i);
- prop.putHTML("genUrlList_urlList_"+i+"_urlExists_urlhxValue", entry.word().metadataHash());
+ prop.putHTML("genUrlList_urlList_"+i+"_urlExists_urlhxValue", entry.word().urlhash());
prop.putHTML("genUrlList_urlList_"+i+"_urlExists_keyString", keystring);
prop.put("genUrlList_urlList_"+i+"_urlExists_keyHash", UTF8.String(keyhash));
prop.putHTML("genUrlList_urlList_"+i+"_urlExists_urlString", us);
@@ -472,7 +472,7 @@ public class IndexControlRWIs_p {
((entry.word().flags().get(WordReferenceRow.flag_app_dc_subject)) ? "appears in subject, " : "") +
((entry.word().flags().get(WordReferenceRow.flag_app_dc_description)) ? "appears in description, " : "") +
((entry.word().flags().get(WordReferenceRow.flag_app_emphasized)) ? "appears emphasized, " : "") +
- ((DigestURI.probablyRootURL(entry.word().metadataHash())) ? "probably root url" : "")
+ ((DigestURI.probablyRootURL(entry.word().urlhash())) ? "probably root url" : "")
);
if (Switchboard.urlBlacklist.isListed(Blacklist.BLACKLIST_DHT, url)) {
prop.put("genUrlList_urlList_"+i+"_urlExists_urlhxChecked", "1");
diff --git a/htroot/IndexControlURLs_p.java b/htroot/IndexControlURLs_p.java
index f9d43fad3..74e002fd4 100644
--- a/htroot/IndexControlURLs_p.java
+++ b/htroot/IndexControlURLs_p.java
@@ -287,13 +287,14 @@ public class IndexControlURLs_p {
if (post.containsKey("statistics")) {
int count = post.getInt("lines", 100);
- Iterator<MetadataRepository.hostStat> statsiter;
+ Iterator<MetadataRepository.HostStat> statsiter;
prop.put("statistics_lines", count);
int cnt = 0;
try {
- statsiter = segment.urlMetadata().statistics(count);
+ MetadataRepository metadata = segment.urlMetadata();
+ statsiter = metadata.statistics(count, metadata.urlSampleScores(metadata.domainSampleCollector()));
boolean dark = true;
- MetadataRepository.hostStat hs;
+ MetadataRepository.HostStat hs;
while (statsiter.hasNext() && cnt < count) {
hs = statsiter.next();
prop.put("statisticslines_domains_" + cnt + "_dark", (dark) ? "1" : "0");
diff --git a/htroot/IndexFederated_p.html b/htroot/IndexFederated_p.html
new file mode 100644
index 000000000..6888725db
--- /dev/null
+++ b/htroot/IndexFederated_p.html
@@ -0,0 +1,67 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>YaCy '#[clientname]#': Federated Index</title>
+ #%env/templates/metas.template%#
+ </head>
+ <body id="IndexFederated_p">
+ #%env/templates/header.template%#
+ #%env/templates/submenuIndexControl.template%#
+ <h2>Federated Index</h2>
+ <p>
+ YaCy supports multiple index storage locations. At this time only the YaCy-internal search index can be used for the Yacy search interface
+ A Solr index storage location is optional. The local index storage location can be disabled.
+ </p>
+
+ <form action="IndexFederated_p.html" method="post" enctype="multipart/form-data" accept-charset="UTF-8">
+ <fieldset>
+ <legend>
+ <input type="checkbox" name="yacy.indexing.enabled" id="yacy.indexing.enabled" #(yacy.indexing.enabled.checked)#:: checked="checked"#(/yacy.indexing.enabled.checked)# />
+ <label for="p2p">YaCy Embedded Index Engine</label>
+ </legend>
+ You can just switch on or off this index. If you switch it off, you will not be able to search with YaCy any more.
+ </fieldset>
+
+ <fieldset>
+ <legend>
+ <input type="checkbox" name="solr.indexing.enabled" id="solr.indexing.enabled" #(solr.indexing.enabled.checked)#:: checked="checked"#(/solr.indexing.enabled.checked)# />
+ <label for="p2p">Remote Solr Index</label>
+ </legend>
+ You can set one or more Solr targets here. If you wish to set several targets, then list them in the 'Solr URL' field using a ',' (comma) as separator.
+
+ <div align="left">
+ <dl>
+ #(table)#::
+ <dt class="TableCellDark">Solr Hosts</dt>
+ <dd>
+ <div>
+ <table class="sortable" border="0" cellpadding="2" cellspacing="1">
+ <tr class="TableHeader" valign="bottom">
+ <td><strong>Solr Host Administration Interface</strong><br/></td>
+ <td><strong>Index Size</strong></td>
+ </tr>
+ #{list}#
+ <tr class="TableCell#(dark)#Light::Dark::Summary#(/dark)#">
+ <td><a href="#[url]#">#[url]#</a></td>
+ <td align="right">#[size]#</td>
+ </tr>
+ #{/list}#
+ </table>
+ </div>
+ </dd>
+ #(/table)#
+ <dt class="TableCellDark">Solr URL(s)</dt>
+ <dd><textarea rows="5" cols="80" name="solr.indexing.url" id="solr.indexing.url"/>#[solr.indexing.url]#</textarea></dd>
+ <dt class="TableCellDark">Charding Method</dt>
+ <dd><input type="text" size="50" maxlength="50" value="#[solr.indexing.charding]#" name="solr.indexing.charding" id="solr.indexing.charding" disabled="disabled"/></dd>
+ <dt class="TableCellDark">Scheme</dt>
+ <dd><input type="text" size="50" maxlength="50" value="#[solr.indexing.scheme]#" name="solr.indexing.scheme" id="solr.indexing.scheme" disabled="disabled"/></dd>
+ </dl>
+ </div>
+ </fieldset>
+ <input type="submit" name="set" value="Set" />
+ </form>
+
+ #%env/templates/footer.template%#
+ </body>
+</html>
diff --git a/htroot/IndexFederated_p.java b/htroot/IndexFederated_p.java
new file mode 100644
index 000000000..54b39fe0d
--- /dev/null
+++ b/htroot/IndexFederated_p.java
@@ -0,0 +1,106 @@
+/**
+ * IndexFederated_p
+ * Copyright 2011 by Michael Peter Christen, [email protected], Frankfurt am Main, Germany
+ * First released 25.05.2011 at http://yacy.net
+ *
+ * $LastChangedDate: 2011-04-14 00:04:23 +0200 (Do, 14 Apr 2011) $
+ * $LastChangedRevision: 7653 $
+ * $LastChangedBy: orbiter $
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program in the file lgpl21.txt
+ * If not, see <http://www.gnu.org/licenses/>.
+ */
+
+import java.io.IOException;
+
+import net.yacy.cora.protocol.RequestHeader;
+import net.yacy.cora.services.federated.solr.SolrChardingConnector;
+import net.yacy.cora.services.federated.solr.SolrChardingSelection;
+import net.yacy.cora.services.federated.solr.SolrScheme;
+import net.yacy.kelondro.logging.Log;
+
+import de.anomic.search.Switchboard;
+import de.anomic.server.serverObjects;
+import de.anomic.server.serverSwitch;
+
+public class IndexFederated_p {
+
+ public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {
+ // return variable that accumulates replacements
+ final serverObjects prop = new serverObjects();
+ Switchboard sb = (Switchboard) env;
+
+ if (post != null && post.containsKey("set")) {
+ // yacy
+ env.setConfig("federated.service.yacy.indexing.enabled", post.getBoolean("yacy.indexing.enabled", false));
+
+ // solr
+ boolean solrWasOn = env.getConfigBool("federated.service.solr.indexing.enabled", true);
+ boolean solrIsOnAfterwards = post.getBoolean("solr.indexing.enabled", false);
+ env.setConfig("federated.service.solr.indexing.enabled", solrIsOnAfterwards);
+ env.setConfig("federated.service.solr.indexing.url", post.get("solr.indexing.url", env.getConfig("federated.service.solr.indexing.url", "http://127.0.0.1:8983/solr")));
+ env.setConfig("federated.service.solr.indexing.charding", post.get("solr.indexing.charding", env.getConfig("federated.service.solr.indexing.charding", "modulo-host-md5")));
+ env.setConfig("federated.service.solr.indexing.scheme", post.get("solr.indexing.scheme", env.getConfig("federated.service.solr.indexing.scheme", "SolrCellExtended")));
+
+ if (solrWasOn && !solrIsOnAfterwards) {
+ // switch off
+ sb.solrConnector.close();
+ sb.solrConnector = null;
+ }
+
+ if (!solrWasOn && solrIsOnAfterwards) {
+ // switch on
+ String solrurls = sb.getConfig("federated.service.solr.indexing.url", "http://127.0.0.1:8983/solr");
+ boolean usesolr = sb.getConfigBool("federated.service.solr.indexing.enabled", false) & solrurls.length() > 0;
+ try {
+ sb.solrConnector = (usesolr) ? new SolrChardingConnector(solrurls, SolrScheme.SolrCellExtended, SolrChardingSelection.Method.MODULO_HOST_MD5) : null;
+ } catch (IOException e) {
+ Log.logException(e);
+ sb.solrConnector = null;
+ }
+ }
+ }
+
+ // show solr host table
+ if (sb.solrConnector == null) {
+ prop.put("table", 0);
+ } else {
+ prop.put("table", 1);
+ try {
+ long[] size = sb.solrConnector.getSizeList();
+ String[] urls = sb.solrConnector.getAdminInterfaceList();
+ boolean dark = false;
+ for (int i = 0; i < size.length; i++) {
+ prop.put("table_list_" + i + "_dark", dark ? 1 : 0); dark = !dark;
+ prop.put("table_list_" + i + "_url", urls[i]);
+ prop.put("table_list_" + i + "_size", size[i]);
+ }
+ prop.put("table_list", size.length);
+ } catch (IOException e) {
+ Log.logException(e);
+ prop.put("table", 0);
+ }
+ }
+
+ // fill attribute fields
+ prop.put("yacy.indexing.enabled.checked", env.getConfigBool("federated.service.yacy.indexing.enabled", true) ? 1 : 0);
+ prop.put("solr.indexing.enabled.checked", env.getConfigBool("federated.service.solr.indexing.enabled", false) ? 1 : 0);
+ prop.put("solr.indexing.url", env.getConfig("federated.service.solr.indexing.url", "http://127.0.0.1:8983/solr"));
+ prop.put("solr.indexing.charding", env.getConfig("federated.service.solr.indexing.charding", "modulo-host-md5"));
+ prop.put("solr.indexing.scheme", env.getConfig("federated.service.solr.indexing.scheme", "SolrCellExtended"));
+
+ // return rewrite properties
+ return prop;
+ }
+}
diff --git a/htroot/env/templates/submenuIndexControl.template b/htroot/env/templates/submenuIndexControl.template
index 029c85884..b125e5860 100644
--- a/htroot/env/templates/submenuIndexControl.template
+++ b/htroot/env/templates/submenuIndexControl.template
@@ -5,5 +5,6 @@
<li><a href="/IndexControlURLs_p.html" class="MenuItemLink lock">URL References Database</a></li>
<!--<li><a href="/IndexControlCleaner_p.html" class="MenuItemLink lock">Index Cleaner</a></li>-->
<li><a href="/ViewFile.html?display=1" class="MenuItemLink">URL Viewer</a></li>
+ <li><a href="/IndexFederated_p.html" class="MenuItemLink lock">Federated Index</a></li>
</ul>
</div>
diff --git a/htroot/yacy/crawlReceipt.java b/htroot/yacy/crawlReceipt.java
index a12dcc8ce..131f8f1be 100644
--- a/htroot/yacy/crawlReceipt.java
+++ b/htroot/yacy/crawlReceipt.java
@@ -36,6 +36,7 @@ import net.yacy.kelondro.logging.Log;
import de.anomic.crawler.ResultURLs;
import de.anomic.crawler.ResultURLs.EventOrigin;
+import de.anomic.crawler.ZURL.FailCategory;
import de.anomic.search.Segments;
import de.anomic.search.Switchboard;
import de.anomic.server.serverObjects;
@@ -162,6 +163,7 @@ public final class crawlReceipt {
youare.getBytes(),
null,
0,
+ FailCategory.FINAL_LOAD_CONTEXT,
result + ":" + reason, -1);
//switchboard.noticeURL.remove(receivedUrlhash);
prop.put("delay", "3600");
diff --git a/htroot/yacy/transferRWI.java b/htroot/yacy/transferRWI.java
index de81fbc5f..ac22bce74 100644
--- a/htroot/yacy/transferRWI.java
+++ b/htroot/yacy/transferRWI.java
@@ -163,7 +163,7 @@ public final class transferRWI {
wordHash = estring.substring(0, p);
wordhashes.add(wordHash);
iEntry = new WordReferenceRow(estring.substring(p));
- urlHash = iEntry.metadataHash();
+ urlHash = iEntry.urlhash();
// block blacklisted entries
if ((blockBlacklist) && (Switchboard.urlBlacklist.hashInBlacklistedCache(Blacklist.BLACKLIST_DHT, urlHash))) {
diff --git a/htroot/yacy/urls.java b/htroot/yacy/urls.java
index 76f12bcf6..a0691c187 100644
--- a/htroot/yacy/urls.java
+++ b/htroot/yacy/urls.java
@@ -33,6 +33,7 @@ import net.yacy.cora.protocol.RequestHeader;
import net.yacy.kelondro.data.meta.DigestURI;
import net.yacy.kelondro.data.meta.URIMetadataRow;
import de.anomic.crawler.NoticedURL;
+import de.anomic.crawler.ZURL.FailCategory;
import de.anomic.crawler.retrieval.Request;
import de.anomic.search.Segments;
import de.anomic.search.Switchboard;
@@ -85,6 +86,7 @@ public class urls {
sb.peers.mySeed().hash.getBytes(),
new Date(),
0,
+ FailCategory.FINAL_PROCESS_CONTEXT,
"client=____________",
-1);
diff --git a/source/de/anomic/crawler/CrawlQueues.java b/source/de/anomic/crawler/CrawlQueues.java
index 2d00c4f7f..f465b21e3 100644
--- a/source/de/anomic/crawler/CrawlQueues.java
+++ b/source/de/anomic/crawler/CrawlQueues.java
@@ -46,6 +46,7 @@ import net.yacy.kelondro.util.FileUtils;
import net.yacy.kelondro.workflow.WorkflowJob;
import de.anomic.crawler.NoticedURL.StackType;
+import de.anomic.crawler.ZURL.FailCategory;
import de.anomic.crawler.retrieval.HTTPLoader;
import de.anomic.crawler.retrieval.Request;
import de.anomic.crawler.retrieval.Response;
@@ -581,6 +582,7 @@ public class CrawlQueues {
UTF8.getBytes(sb.peers.mySeed().hash),
new Date(),
1,
+ FailCategory.FINAL_ROBOTS_RULE,
"denied by robots.txt", -1);
this.request.setStatus("worker-disallowed", WorkflowJob.STATUS_FINISHED);
} else {
@@ -617,6 +619,7 @@ public class CrawlQueues {
UTF8.getBytes(sb.peers.mySeed().hash),
new Date(),
1,
+ FailCategory.TEMPORARY_NETWORK_FAILURE,
"cannot load: " + result, -1);
this.request.setStatus("worker-error", WorkflowJob.STATUS_FINISHED);
} else {
@@ -629,6 +632,7 @@ public class CrawlQueues {
UTF8.getBytes(sb.peers.mySeed().hash),
new Date(),
1,
+ FailCategory.TEMPORARY_NETWORK_FAILURE,
e.getMessage() + " - in worker", -1);
Log.logException(e);
// Client.initConnectionManager();
diff --git a/source/de/anomic/crawler/CrawlStacker.java b/source/de/anomic/crawler/CrawlStacker.java
index 6cd3e742d..8061cd476 100644
--- a/source/de/anomic/crawler/CrawlStacker.java
+++ b/source/de/anomic/crawler/CrawlStacker.java
@@ -53,6 +53,7 @@ import net.yacy.repository.Blacklist;
import net.yacy.repository.FilterEngine;
import de.anomic.crawler.ResultURLs.EventOrigin;
+import de.anomic.crawler.ZURL.FailCategory;
import de.anomic.crawler.retrieval.FTPLoader;
import de.anomic.crawler.retrieval.HTTPLoader;
import de.anomic.crawler.retrieval.Request;
@@ -202,7 +203,7 @@ public final class CrawlStacker {
// if the url was rejected we store it into the error URL db
if (rejectReason != null) {
- nextQueue.errorURL.push(entry, UTF8.getBytes(peers.mySeed().hash), new Date(), 1, rejectReason, -1);
+ nextQueue.errorURL.push(entry, UTF8.getBytes(peers.mySeed().hash), new Date(), 1, FailCategory.FINAL_LOAD_CONTEXT, rejectReason, -1);
}
} catch (final Exception e) {
CrawlStacker.this.log.logWarning("Error while processing stackCrawl entry.\n" + "Entry: " + entry.toString() + "Error: " + e.toString(), e);
diff --git a/source/de/anomic/crawler/RobotsTxt.java b/source/de/anomic/crawler/RobotsTxt.java
index 6952e65c8..a9e6d5e4a 100644
--- a/source/de/anomic/crawler/RobotsTxt.java
+++ b/source/de/anomic/crawler/RobotsTxt.java
@@ -143,7 +143,7 @@ public class RobotsTxt {
if (robotsURL != null) {
if (log.isDebugEnabled()) log.debug("Trying to download the robots.txt file from URL '" + robotsURL + "'.");
try {
- result = downloadRobotsTxt(robotsURL, 5, robotsTxt4Host);
+ result = downloadRobotsTxt(robotsURL, 3, robotsTxt4Host);
} catch (final Exception e) {
result = null;
}
diff --git a/source/de/anomic/crawler/ZURL.java b/source/de/anomic/crawler/ZURL.java
index 6daa87756..09ce6fb89 100755
--- a/source/de/anomic/crawler/ZURL.java
+++ b/source/de/anomic/crawler/ZURL.java
@@ -34,7 +34,7 @@ import java.util.Iterator;
import java.util.concurrent.ConcurrentLinkedQueue;
import net.yacy.cora.document.UTF8;
-import net.yacy.cora.services.federated.solr.SolrSingleConnector;
+import net.yacy.cora.services.federated.solr.SolrChardingConnector;
import net.yacy.kelondro.data.meta.DigestURI;
import net.yacy.kelondro.data.word.Word;
import net.yacy.kelondro.index.Index;
@@ -55,9 +55,12 @@ public class ZURL implements Iterable<ZURL.Entry> {
private static final int maxStackSize = 1000;
public enum FailCategory {
- NETWORK_FAILURE, // an entity could not been loaded
- CRAWL_RULE, // the crawler configuration does not want to load the entity
- ROBOTS_RULE; // a remote server denies indexing or loading
+ // TEMPORARY categories are such failure cases that should be tried again
+ // FINAL categories are such failure cases that are final and should not be tried again
+ TEMPORARY_NETWORK_FAILURE, // an entity could not been loaded
+ FINAL_PROCESS_CONTEXT, // because of a processing context we do not want that url again (i.e. remote crawling)
+ FINAL_LOAD_CONTEXT, // the crawler configuration does not want to load the entity
+ FINAL_ROBOTS_RULE; // a remote server denies indexing or loading
}
private final static Row rowdef = new Row(
@@ -73,10 +76,10 @@ public class ZURL implements Iterable<ZURL.Entry> {
// the class object
private Index urlIndex;
private final ConcurrentLinkedQueue<byte[]> stack;
- private final SolrSingleConnector solrConnector;
+ private final SolrChardingConnector solrConnector;
public ZURL(
- final SolrSingleConnector solrConnector,
+ final SolrChardingConnector solrConnector,
final File cachePath,
final String tablename,
final boolean startWithEmptyFile,
@@ -104,7 +107,7 @@ public class ZURL implements Iterable<ZURL.Entry> {
this.stack = new ConcurrentLinkedQueue<byte[]>();
}
- public ZURL(final SolrSingleConnector solrConnector) {
+ public ZURL(final SolrChardingConnector solrConnector) {
this.solrConnector = solrConnector;
// creates a new ZUR in RAM
this.urlIndex = new RowSet(rowdef);
@@ -137,6 +140,7 @@ public class ZURL implements Iterable<ZURL.Entry> {
final byte[] executor,
final Date workdate,
final int workcount,
+ final FailCategory failCategory,
String anycause,
int httpcode) {
// assert executor != null; // null == proxy !
@@ -147,10 +151,10 @@ public class ZURL implements Iterable<ZURL.Entry> {
put(entry);
stack.add(entry.hash());
Log.logInfo("Rejected URL", bentry.url().toNormalform(false, false) + " - " + reason);
- if (this.solrConnector != null) {
+ if (this.solrConnector != null && (failCategory == FailCategory.TEMPORARY_NETWORK_FAILURE || failCategory == FailCategory.FINAL_ROBOTS_RULE)) {
// send the error to solr
try {
- this.solrConnector.err(bentry.url(), reason, httpcode);
+ this.solrConnector.err(bentry.url(), failCategory.name() + " " + reason, httpcode);
} catch (IOException e) {
Log.logWarning("SOLR", "failed to send error " + bentry.url().toNormalform(true, false) + " to solr: " + e.getMessage());
}
diff --git a/source/de/anomic/crawler/retrieval/FTPLoader.java b/source/de/anomic/crawler/retrieval/FTPLoader.java
index 020e05bff..88275f5bb 100644
--- a/source/de/anomic/crawler/retrieval/FTPLoader.java
+++ b/source/de/anomic/crawler/retrieval/FTPLoader.java
@@ -42,6 +42,7 @@ import net.yacy.kelondro.data.meta.DigestURI;
import net.yacy.kelondro.logging.Log;
import de.anomic.crawler.CrawlProfile;
import de.anomic.crawler.Latency;
+import de.anomic.crawler.ZURL.FailCategory;
import de.anomic.search.Segments;
import de.anomic.search.Switchboard;
@@ -152,7 +153,7 @@ public class FTPLoader {
if (berr.size() > 0 || response == null) {
// some error logging
final String detail = (berr.size() > 0) ? "Errorlog: " + berr.toString() : "";
- sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash.getBytes(), new Date(), 1, " ftp server download, " + detail, -1);
+ sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash.getBytes(), new Date(), 1, FailCategory.TEMPORARY_NETWORK_FAILURE, " ftp server download, " + detail, -1);
throw new IOException("FTPLoader: Unable to download URL '" + request.url().toString() + "': " + detail);
}
diff --git a/source/de/anomic/crawler/retrieval/HTTPLoader.java b/source/de/anomic/crawler/retrieval/HTTPLoader.java
index 038607a71..90825d7fa 100644
--- a/source/de/anomic/crawler/retrieval/HTTPLoader.java
+++ b/source/de/anomic/crawler/retrieval/HTTPLoader.java
@@ -40,6 +40,7 @@ import net.yacy.repository.Blacklist;
import de.anomic.crawler.CrawlProfile;
import de.anomic.crawler.Latency;
+import de.anomic.crawler.ZURL.FailCategory;
import de.anomic.http.server.AlternativeDomainNames;
import de.anomic.http.server.HTTPDemon;
import de.anomic.search.Segments;
@@ -78,7 +79,7 @@ public final class HTTPLoader {
private Response load(final Request request, final int retryCount, final long maxFileSize, final boolean checkBlacklist) throws IOException {
if (retryCount < 0) {
- sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash.getBytes(), new Date(), 1, "redirection counter exceeded", -1);
+ sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash.getBytes(), new Date(), 1, FailCategory.TEMPORARY_NETWORK_FAILURE, "redirection counter exceeded", -1);
throw new IOException("Redirection counter exceeded for URL " + request.url().toString() + ". Processing aborted.");
}
@@ -94,7 +95,7 @@ public final class HTTPLoader {
// check if url is in blacklist
final String hostlow = host.toLowerCase();
if (checkBlacklist && Switchboard.urlBlacklist.isListed(Blacklist.BLACKLIST_CRAWLER, hostlow, path)) {
- sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash.getBytes(), new Date(), 1, "url in blacklist", -1);
+ sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash.getBytes(), new Date(), 1, FailCategory.FINAL_LOAD_CONTEXT, "url in blacklist", -1);
throw new IOException("CRAWLER Rejecting URL '" + request.url().toString() + "'. URL is in blacklist.");
}
@@ -138,7 +139,7 @@ public final class HTTPLoader {
redirectionUrlString = redirectionUrlString.trim();
if (redirectionUrlString.length() == 0) {
- sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash.getBytes(), new Date(), 1, "redirection header empy", code);
+ sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash.getBytes(), new Date(), 1, FailCategory.TEMPORARY_NETWORK_FAILURE, "redirection header empy", code);
throw new IOException("CRAWLER Redirection of URL=" + request.url().toString() + " aborted. Location header is empty.");
}
@@ -151,14 +152,14 @@ public final class HTTPLoader {
// if we are already doing a shutdown we don't need to retry crawling
if (Thread.currentThread().isInterrupted()) {
- sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash.getBytes(), new Date(), 1, "server shutdown", code);
+ sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash.getBytes(), new Date(), 1, FailCategory.FINAL_LOAD_CONTEXT, "server shutdown", code);
throw new IOException("CRAWLER Retry of URL=" + request.url().toString() + " aborted because of server shutdown.");
}
// check if the url was already indexed
final String dbname = sb.urlExists(Segments.Process.LOCALCRAWLING, redirectionUrl.hash());
if (dbname != null) {
- sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash.getBytes(), new Date(), 1, "redirection to double content", code);
+ sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash.getBytes(), new Date(), 1, FailCategory.TEMPORARY_NETWORK_FAILURE, "redirection to double content", code);
throw new IOException("CRAWLER Redirection of URL=" + request.url().toString() + " ignored. The url appears already in db " + dbname);
}
@@ -167,12 +168,12 @@ public final class HTTPLoader {
return load(request, retryCount - 1, maxFileSize, checkBlacklist);
} else {
// no redirection url provided
- sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash.getBytes(), new Date(), 1, "no redirection url provided", code);
+ sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash.getBytes(), new Date(), 1, FailCategory.TEMPORARY_NETWORK_FAILURE, "no redirection url provided", code);
throw new IOException("REJECTED EMTPY REDIRECTION '" + client.getHttpResponse().getStatusLine() + "' for URL " + request.url().toString());
}
} else if (responseBody == null) {
// no response, reject file
- sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash.getBytes(), new Date(), 1, "no response body", code);
+ sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash.getBytes(), new Date(), 1, FailCategory.TEMPORARY_NETWORK_FAILURE, "no response body", code);
throw new IOException("REJECTED EMPTY RESPONSE BODY '" + client.getHttpResponse().getStatusLine() + "' for URL " + request.url().toString());
} else if (code == 200 || code == 203) {
// the transfer is ok
@@ -183,7 +184,7 @@ public final class HTTPLoader {
// check length again in case it was not possible to get the length before loading
if (maxFileSize > 0 && contentLength > maxFileSize) {
- sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash.getBytes(), new Date(), 1, "file size limit exceeded", code);
+ sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash.getBytes(), new Date(), 1, FailCategory.FINAL_PROCESS_CONTEXT, "file size limit exceeded", code);
throw new IOException("REJECTED URL " + request.url() + " because file size '" + contentLength + "' exceeds max filesize limit of " + maxFileSize + " bytes. (GET)");
}
@@ -201,7 +202,7 @@ public final class HTTPLoader {
return response;
} else {
// if the response has not the right response type then reject file
- sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash.getBytes(), new Date(), 1, "wrong http status code", code);
+ sb.crawlQueues.errorURL.push(request, sb.peers.mySeed().hash.getBytes(), new Date(), 1, FailCategory.TEMPORARY_NETWORK_FAILURE, "wrong http status code", code);
throw new IOException("REJECTED WRONG STATUS TYPE '" + client.getHttpResponse().getStatusLine() + "' for URL " + request.url().toString());
}
}
diff --git a/source/de/anomic/data/BookmarksDB.java b/source/de/anomic/data/BookmarksDB.java
index 173ee36a0..c73a053dd 100644
--- a/source/de/anomic/data/BookmarksDB.java
+++ b/source/de/anomic/data/BookmarksDB.java
@@ -296,6 +296,7 @@ public class BookmarksDB {
Set<String> tagSet;
while(bit.hasNext()){
bm=getBookmark(bit.next());
+ if (bm == null) continue;
tagSet = bm.getTags();
it = tagSet.iterator();
while (it.hasNext()) {
diff --git a/source/de/anomic/search/BlockRank.java b/source/de/anomic/search/BlockRank.java
index a2ea7a745..2f462e83d 100644
--- a/source/de/anomic/search/BlockRank.java
+++ b/source/de/anomic/search/BlockRank.java
@@ -30,6 +30,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
import net.yacy.cora.document.UTF8;
import net.yacy.cora.storage.OrderedScoreMap;
@@ -44,6 +45,7 @@ import net.yacy.kelondro.rwi.ReferenceContainerCache;
import net.yacy.kelondro.rwi.ReferenceIterator;
import net.yacy.kelondro.util.FileUtils;
+import de.anomic.search.MetadataRepository.HostStat;
import de.anomic.yacy.yacyClient;
import de.anomic.yacy.yacySeed;
import de.anomic.yacy.yacySeedDB;
@@ -149,21 +151,33 @@ public class BlockRank {
return index;
}
- public static BinSearch[] evaluate(final ReferenceContainerCache<HostReference> index, BinSearch[] referenceTable, int recusions) {
+ public static BinSearch[] evaluate(final ReferenceContainerCache<HostReference> index, Map<String, HostStat> hostHashResolver, BinSearch[] referenceTable, int recusions) {
- // first just count the number of references. all other information from the index is not used because they cannot be trusted
+ // first find out the maximum count of the hostHashResolver
+ int maxHostCount = 1;
+ for (HostStat stat: hostHashResolver.values()) {
+ if (stat.count > maxHostCount) maxHostCount = stat.count;
+ }
+
+ // then just count the number of references. all other information from the index is not used because they cannot be trusted
ScoreMap<byte[]> hostScore = new OrderedScoreMap<byte[]>(index.termKeyOrdering());
+ HostStat hostStat;
+ int hostCount;
for (ReferenceContainer<HostReference> container: index) {
if (container.size() == 0) continue;
if (referenceTable == null) {
- hostScore.set(container.getTermHash(), container.size());
+ hostStat = hostHashResolver.get(UTF8.String(container.getTermHash()));
+ hostCount = hostStat == null ? 6 /* high = a penalty for 'i do not know this', this may not be fair*/ : Math.max(1, hostStat.count);
+ hostScore.set(container.getTermHash(), container.size() * maxHostCount / hostCount);
} else {
int score = 0;
Iterator<HostReference> hri = container.entries();
HostReference hr;
while (hri.hasNext()) {
hr = hri.next();
- score += (16 - ranking(hr.metadataHash(), referenceTable));
+ hostStat = hostHashResolver.get(UTF8.String(hr.urlhash()));
+ hostCount = hostStat == null ? 6 /* high = a penalty for 'i do not know this', this may not be fair*/ : Math.max(1, hostStat.count);
+ score += (17 - ranking(hr.urlhash(), referenceTable)) * maxHostCount / hostCount;
}
hostScore.set(container.getTermHash(), score);
}
@@ -192,17 +206,22 @@ public class BlockRank {
// re-use the new table for a recursion
if (recusions == 0) return newTables;
- return evaluate(index, newTables, --recusions); // one recursion step
+ return evaluate(index, hostHashResolver, newTables, --recusions); // one recursion step
}
- public static void analyse(BinSearch[] tables, final WebStructureGraph myGraph) {
+ public static void analyse(BinSearch[] tables, final WebStructureGraph myGraph, final Map<String, HostStat> hostHash2hostName) {
byte[] hosth = new byte[6];
String hosths, hostn;
+ HostStat hs;
for (int ybr = 0; ybr < tables.length; ybr++) {
row: for (int i = 0; i < tables[ybr].size(); i++) {
hosth = tables[ybr].get(i, hosth);
hosths = UTF8.String(hosth);
hostn = myGraph.hostHash2hostName(hosths);
+ if (hostn == null) {
+ hs = hostHash2hostName.get(hostn);
+ if (hs != null) hostn = hs.hostname;
+ }
if (hostn == null) {
//Log.logInfo("BlockRank", "Ranking for Host: ybr = " + ybr + ", hosthash = " + hosths);
continue row;
@@ -271,7 +290,7 @@ public class BlockRank {
}
public static int ranking(final byte[] hash, BinSearch[] rankingTable) {
- if (rankingTable == null) return 15;
+ if (rankingTable == null) return 16;
byte[] hosthash;
if (hash.length == 6) {
hosthash = hash;
@@ -281,10 +300,10 @@ public class BlockRank {
}
final int m = Math.min(16, rankingTable.length);
for (int i = 0; i < m; i++) {
- if ((rankingTable[i] != null) && (rankingTable[i].contains(hosthash))) {
+ if (rankingTable[i] != null && rankingTable[i].contains(hosthash)) {
return i;
}
}
- return 15;
+ return 16;
}
}
diff --git a/source/de/anomic/search/MetadataRepository.java b/source/de/anomic/search/MetadataRepository.java
index 6e7f49e83..b74e4c724 100644
--- a/source/de/anomic/search/MetadataRepository.java
+++ b/source/de/anomic/search/MetadataRepository.java
@@ -66,7 +66,7 @@ public final class MetadataRepository implements Iterable<byte[]> {
protected Index urlIndexFile;
private Export exportthread; // will have a export thread assigned if exporter is running
private File location;
- private ArrayList<hostStat> statsDump;
+ private ArrayList<HostStat> statsDump;
public MetadataRepository(
final File path,
@@ -127,7 +127,7 @@ public final class MetadataRepository implements Iterable<byte[]> {
public URIMetadataRow load(final WeakPriorityBlockingQueue.Element<WordReferenceVars> obrwi) {
if (urlIndexFile == null) return null;
if (obrwi == null) return null; // all time was already wasted in takeRWI to get another element
- byte[] urlHash = obrwi.getElement().metadataHash();
+ byte[] urlHash = obrwi.getElement().urlhash();
if (urlHash == null) return null;
try {
final Row.Entry entry = urlIndexFile.get(urlHash);
@@ -502,7 +502,7 @@ public final class MetadataRepository implements Iterable<byte[]> {
}
if (dom) {
- TreeSet<String> set = domainNameCollector(-1);
+ TreeSet<String> set = domainNameCollector(-1, domainSampleCollector());
for (String host: set) {
if (!host.matches(filter)) continue;
if (format == 0) pw.println(host);
@@ -572,18 +572,25 @@ public final class MetadataRepository implements Iterable<byte[]> {
}
- private Map<String, hashStat> domainSampleCollector() throws IOException {
- Map<String, hashStat> map = new HashMap<String, hashStat>();
+ /**
+ * collect domain samples: all url hashes from the metadata database is listed and the domain part
+ * of the url hashes is used to count how many of these domain hashes appear
+ * @return a map from domain hashes to hash statistics
+ * @throws IOException
+ */
+ public Map<String, URLHashCounter> domainSampleCollector() throws IOException {
+ Map<String, URLHashCounter> map = new HashMap<String, URLHashCounter>();
// first collect all domains and calculate statistics about it
CloneableIterator<byte[]> i = this.urlIndexFile.keys(true, null);
- String urlhash, hosthash;
- hashStat ds;
+ String hosthash;
+ byte[] urlhashb;
+ URLHashCounter ds;
if (i != null) while (i.hasNext()) {
- urlhash = UTF8.String(i.next());
- hosthash = urlhash.substring(6);
+ urlhashb = i.next();
+ hosthash = UTF8.String(urlhashb).substring(6);
ds = map.get(hosthash);
if (ds == null) {
- ds = new hashStat(urlhash);
+ ds = new URLHashCounter(urlhashb);
map.put(hosthash, ds);
} else {
ds.count++;
@@ -592,18 +599,23 @@ public final class MetadataRepository implements Iterable<byte[]> {
return map;
}
- public TreeSet<String> domainNameCollector(int count) throws IOException {
+ /**
+ * create a list of domain names in this database
+ * @param count number of entries or -1 for all
+ * @param domainSamples a map from domain hashes to hash statistics
+ * @return a set of domain names, ordered by name of the domains
+ */
+ public TreeSet<String> domainNameCollector(int count, Map<String, URLHashCounter> domainSamples) {
// collect hashes from all domains
- Map<String, hashStat> map = domainSampleCollector();
// fetch urls from the database to determine the host in clear text
URIMetadataRow urlref;
- if (count < 0 || count > map.size()) count = map.size();
- statsDump = new ArrayList<hostStat>();
+ if (count < 0 || count > domainSamples.size()) count = domainSamples.size();
+ statsDump = new ArrayList<HostStat>();
TreeSet<String> set = new TreeSet<String>();
- for (hashStat hs: map.values()) {
+ for (URLHashCounter hs: domainSamples.values()) {
if (hs == null) continue;
- urlref = this.load(UTF8.getBytes(hs.urlhash));
+ urlref = this.load(hs.urlhashb);
if (urlref == null || urlref.metadata() == null || urlref.metadata().url() == null || urlref.metadata().url().getHost() == null) continue;
set.add(urlref.metadata().url().getHost());
count--;
@@ -611,27 +623,57 @@ public final class MetadataRepository implements Iterable<byte[]> {
}
return set;
}
+
+ /**
+ * calculate a score map for url hash samples: each sample is a single url hash
+ * that stands for all entries for the corresponding domain. The map counts the number
+ * of occurrences of the domain
+ * @param domainSamples a map from domain hashes to hash statistics
+ * @return a map from url hash samples to counters
+ */
+ public ScoreMap<String> urlSampleScores(Map<String, URLHashCounter> domainSamples) {
+ ScoreMap<String> urlSampleScore = new ConcurrentScoreMap<String>();
+ for (Map.Entry<String, URLHashCounter> e: domainSamples.entrySet()) {
+ urlSampleScore.inc(UTF8.String(e.getValue().urlhashb), e.getValue().count);
+ }
+ return urlSampleScore;
+ }
- public Iterator<hostStat> statistics(int count) throws IOException {
- // prevent too heavy IO.
- if (statsDump != null && count <= statsDump.size()) return statsDump.iterator();
-
- // collect hashes from all domains
- Map<String, hashStat> map = domainSampleCollector();
+ /**
+ * calculate all domain names for all domain hashes
+ * @param domainSamples a map from domain hashes to hash statistics
+ * @return a map from domain hashes to host stats including domain names
+ */
+ public Map<String, HostStat> domainHashResolver(Map<String, URLHashCounter> domainSamples) {
+ HashMap<String, HostStat> hostMap = new HashMap<String, HostStat>();
+ URIMetadataRow urlref;
- // order elements by size
- ScoreMap<String> s = new ConcurrentScoreMap<String>();
- for (Map.Entry<String, hashStat> e: map.entrySet()) {
- s.inc(e.getValue().urlhash, e.getValue().count);
+ ScoreMap<String> hosthashScore = new ConcurrentScoreMap<String>();
+ for (Map.Entry<String, URLHashCounter> e: domainSamples.entrySet()) {
+ hosthashScore.inc(UTF8.String(e.getValue().urlhashb).substring(6), e.getValue().count);
}
+ URIMetadataRow.Components comps;
+ DigestURI url;
+ for (Map.Entry<String, URLHashCounter> e: domainSamples.entrySet()) {
+ urlref = this.load(e.getValue().urlhashb);
+ comps = urlref.metadata();
+ url = comps.url();
+ hostMap.put(e.getKey(), new HostStat(url.getHost(), url.getPort(), e.getKey(), hosthashScore.get(e.getKey())));
+ }
+ return hostMap;
+ }
+
+ public Iterator<HostStat> statistics(int count, ScoreMap<String> domainScore) {
+ // prevent too heavy IO.
+ if (statsDump != null && count <= statsDump.size()) return statsDump.iterator();
// fetch urls from the database to determine the host in clear text
- Iterator<String> j = s.keys(false); // iterate urlhash-examples in reverse order (biggest first)
+ Iterator<String> j = domainScore.keys(false); // iterate urlhash-examples in reverse order (biggest first)
URIMetadataRow urlref;
String urlhash;
count += 10; // make some more to prevent that we have to do this again after deletions too soon.
- if (count < 0 || s.sizeSmaller(count)) count = s.size();
- statsDump = new ArrayList<hostStat>();
+ if (count < 0 || domainScore.sizeSmaller(count)) count = domainScore.size();
+ statsDump = new ArrayList<HostStat>();
URIMetadataRow.Components comps;
DigestURI url;
while (j.hasNext()) {
@@ -639,31 +681,31 @@ public final class MetadataRepository implements Iterable<byte[]> {
if (urlhash == null) continue;
urlref = this.load(UTF8.getBytes(urlhash));
if (urlref == null || urlref.metadata() == null || urlref.metadata().url() == null || urlref.metadata().url().getHost() == null) continue;
- if (statsDump == null) return new ArrayList<hostStat>().iterator(); // some other operation has destroyed the object
+ if (statsDump == null) return new ArrayList<HostStat>().iterator(); // some other operation has destroyed the object
comps = urlref.metadata();
url = comps.url();
- statsDump.add(new hostStat(url.getHost(), url.getPort(), urlhash.substring(6), s.get(urlhash)));
+ statsDump.add(new HostStat(url.getHost(), url.getPort(), urlhash.substring(6), domainScore.get(urlhash)));
count--;
if (count == 0) break;
}
// finally return an iterator for the result array
- return (statsDump == null) ? new ArrayList<hostStat>().iterator() : statsDump.iterator();
+ return (statsDump == null) ? new ArrayList<HostStat>().iterator() : statsDump.iterator();
}
- private static class hashStat {
- public String urlhash;
+ private static class URLHashCounter {
+ public byte[] urlhashb;
public int count;
- public hashStat(String urlhash) {
- this.urlhash = urlhash;
+ public URLHashCounter(byte[] urlhashb) {
+ this.urlhashb = urlhashb;
this.count = 1;
}
}
- public static class hostStat {
+ public static class HostStat {
public String hostname, hosthash;
public int port;
public int count;
- public hostStat(String host, int port, String urlhashfragment, int count) {
+ public HostStat(String host, int port, String urlhashfragment, int count) {
assert urlhashfragment.length() == 6;
this.hostname = host;
this.port = port;
@@ -698,8 +740,8 @@ public final class MetadataRepository implements Iterable<byte[]> {
// finally remove the line with statistics
if (statsDump != null) {
- Iterator<hostStat> hsi = statsDump.iterator();
- hostStat hs;
+ Iterator<HostStat> hsi = statsDump.iterator();
+ HostStat hs;
while (hsi.hasNext()) {
hs = hsi.next();
if (hs.hosthash.equals(hosthash)) {
diff --git a/source/de/anomic/search/RankingProcess.java b/source/de/anomic/search/RankingProcess.java
index e3d6a92be..4c114667f 100644
--- a/source/de/anomic/search/RankingProcess.java
+++ b/source/de/anomic/search/RankingProcess.java
@@ -192,7 +192,7 @@ public final class RankingProcess extends Thread {
while (true) {
iEntry = decodedEntries.poll(1, TimeUnit.SECONDS);
if (iEntry == null || iEntry == WordReferenceVars.poison) break;
- assert (iEntry.metadataHash().length == index.row().primaryKeyLength);
+ assert (iEntry.urlhash().length == index.row().primaryKeyLength);
//if (iEntry.urlHash().length() != index.row().primaryKeyLength) continue;
// increase flag counts
@@ -227,15 +227,16 @@ public final class RankingProcess extends Thread {
//this.domZones[DigestURI.domDomain(iEntry.metadataHash())]++;
// check site constraints
- String domhash = UTF8.String(iEntry.metadataHash(), 6, 6);
+ String urlhashs = UTF8.String(iEntry.urlhash());
+ String hosthash = urlhashs.substring(6);
if (query.sitehash == null) {
// no site constraint there; maybe collect host navigation information
if (nav_hosts && query.urlMask_isCatchall) {
- this.hostNavigator.inc(domhash);
- this.hostResolver.put(domhash, UTF8.String(iEntry.metadataHash()));
+ this.hostNavigator.inc(hosthash);
+ this.hostResolver.put(hosthash, urlhashs);
}
} else {
- if (!domhash.equals(query.sitehash)) {
+ if (!hosthash.equals(query.sitehash)) {
// filter out all domains that do not match with the site constraint
this.sortout++;
continue;
@@ -243,7 +244,7 @@ public final class RankingProcess extends Thread {
}
// finally make a double-check and insert result to stack
- if (urlhashes.add(iEntry.metadataHash())) {
+ if (urlhashes.add(iEntry.urlhash())) {
rankingtryloop: while (true) {
try {
stack.put(new ReverseElement<WordReferenceVars>(iEntry, this.order.cardinal(iEntry))); // inserts the element and removes the worst (which is smallest)
@@ -332,7 +333,7 @@ public final class RankingProcess extends Thread {
}
// check doubledom
- final String domhash = UTF8.String(rwi.getElement().metadataHash(), 6, 6);
+ final String domhash = UTF8.String(rwi.getElement().urlhash(), 6, 6);
synchronized (this.doubleDomCache) {
m = this.doubleDomCache.get(domhash);
if (m == null) {
@@ -376,7 +377,7 @@ public final class RankingProcess extends Thread {
if (bestEntry == null) return null;
// finally remove the best entry from the doubledom cache
- m = this.doubleDomCache.get(UTF8.String(bestEntry.getElement().metadataHash()).substring(6));
+ m = this.doubleDomCache.get(UTF8.String(bestEntry.getElement().urlhash()).substring(6));
bestEntry = m.poll();
}
return bestEntry;
@@ -402,7 +403,7 @@ public final class RankingProcess extends Thread {
if (obrwi == null) return null; // all time was already wasted in takeRWI to get another element
final URIMetadataRow page = this.query.getSegment().urlMetadata().load(obrwi);
if (page == null) {
- misses.add(obrwi.getElement().metadataHash());
+ misses.add(obrwi.getElement().urlhash());
continue;
}
diff --git a/source/de/anomic/search/ReferenceOrder.java b/source/de/anomic/search/ReferenceOrder.java
index cd9749c14..dcb81bbad 100644
--- a/source/de/anomic/search/ReferenceOrder.java
+++ b/source/de/anomic/search/ReferenceOrder.java
@@ -163,7 +163,7 @@ public class ReferenceOrder {
if (max == null) max = iEntry.clone(); else max.max(iEntry);
out.put(iEntry); // must be after the min/max check to prevent that min/max is null in cardinal()
// update domcount
- dom = UTF8.String(iEntry.metadataHash(), 6, 6);
+ dom = UTF8.String(iEntry.urlhash(), 6, 6);
count = doms0.get(dom);
if (count == null) {
doms0.put(dom, int1);
@@ -216,8 +216,8 @@ public class ReferenceOrder {
int maxmaxpos = max.maxposition();
int minminpos = min.minposition();
final long r =
- ((256 - DigestURI.domLengthNormalized(t.metadataHash())) << ranking.coeff_domlength)
- + ((ranking.coeff_ybr > 12) ? ((256 - (BlockRank.ranking(t.metadataHash()) << 4)) << ranking.coeff_ybr) : 0)
+ ((256 - DigestURI.domLengthNormalized(t.urlhash())) << ranking.coeff_domlength)
+ + ((ranking.coeff_ybr > 12) ? ((256 - (BlockRank.ranking(t.urlhash()) << 4)) << ranking.coeff_ybr) : 0)
+ ((max.urlcomps() == min.urlcomps() ) ? 0 : (256 - (((t.urlcomps() - min.urlcomps() ) << 8) / (max.urlcomps() - min.urlcomps()) )) << ranking.coeff_urlcomps)
+ ((max.urllength() == min.urllength() ) ? 0 : (256 - (((t.urllength() - min.urllength() ) << 8) / (max.urllength() - min.urllength()) )) << ranking.coeff_urllength)
+ ((maxmaxpos == minminpos ) ? 0 : (256 - (((t.minposition() - minminpos ) << 8) / (maxmaxpos - minminpos) )) << ranking.coeff_posintext)
@@ -232,7 +232,7 @@ public class ReferenceOrder {
+ ((max.lother() == min.lother()) ? 0 : (((t.lother() - min.lother() ) << 8) / (max.lother() - min.lother()) ) << ranking.coeff_lother)
+ ((max.hitcount() == min.hitcount()) ? 0 : (((t.hitcount() - min.hitcount() ) << 8) / (max.hitcount() - min.hitcount()) ) << ranking.coeff_hitcount)
+ tf
- + ((ranking.coeff_authority > 12) ? (authority(t.metadataHash()) << ranking.coeff_authority) : 0)
+ + ((ranking.coeff_authority > 12) ? (authority(t.urlhash()) << ranking.coeff_authority) : 0)
+ ((flags.get(WordReferenceRow.flag_app_dc_identifier)) ? 255 << ranking.coeff_appurl : 0)
+ ((flags.get(WordReferenceRow.flag_app_dc_title)) ? 255 << ranking.coeff_app_dc_title : 0)
+ ((flags.get(WordReferenceRow.flag_app_dc_creator)) ? 255 << ranking.coeff_app_dc_creator : 0)
@@ -245,7 +245,7 @@ public class ReferenceOrder {
+ ((flags.get(Condenser.flag_cat_hasvideo)) ? 255 << ranking.coeff_cathasvideo : 0)
+ ((flags.get(Condenser.flag_cat_hasapp)) ? 255 << ranking.coeff_cathasapp : 0)
+ ((ByteBuffer.equals(t.language, this.language)) ? 255 << ranking.coeff_language : 0)
- + ((DigestURI.probablyRootURL(t.metadataHash())) ? 15 << ranking.coeff_urllength : 0);
+ + ((DigestURI.probablyRootURL(t.urlhash())) ? 15 << ranking.coeff_urllength : 0);
//if (searchWords != null) r += (yacyURL.probablyWordURL(t.urlHash(), searchWords) != null) ? 256 << ranking.coeff_appurl : 0;
diff --git a/source/de/anomic/search/Segment.java b/source/de/anomic/search/Segment.java
index ae9cf459a..036086bfa 100644
--- a/source/de/anomic/search/Segment.java
+++ b/source/de/anomic/search/Segment.java
@@ -481,13 +481,13 @@ public class Segment {
entry = new WordReferenceVars(containerIterator.next());
// System.out.println("Wordhash: "+wordHash+" UrlHash:
// "+entry.getUrlHash());
- final URIMetadataRow ue = urlMetadata.load(entry.metadataHash());
+ final URIMetadataRow ue = urlMetadata.load(entry.urlhash());
if (ue == null) {
- urlHashs.put(entry.metadataHash());
+ urlHashs.put(entry.urlhash());
} else {
url = ue.metadata().url();
if (url == null || Switchboard.urlBlacklist.isListed(Blacklist.BLACKLIST_CRAWLER, url)) {
- urlHashs.put(entry.metadataHash());
+ urlHashs.put(entry.urlhash());
}
}
}
diff --git a/source/de/anomic/search/Switchboard.java b/source/de/anomic/search/Switchboard.java
index 2dc48c362..0dd31254e 100644
--- a/source/de/anomic/search/Switchboard.java
+++ b/source/de/anomic/search/Switchboard.java
@@ -88,8 +88,9 @@ import net.yacy.cora.protocol.RequestHeader;
import net.yacy.cora.protocol.ResponseHeader;
import net.yacy.cora.protocol.http.HTTPClient;
import net.yacy.cora.protocol.http.ProxySettings;
+import net.yacy.cora.services.federated.solr.SolrChardingConnector;
+import net.yacy.cora.services.federated.solr.SolrChardingSelection;
import net.yacy.cora.services.federated.solr.SolrScheme;
-import net.yacy.cora.services.federated.solr.SolrSingleConnector;
import net.yacy.document.Condenser;
import net.yacy.document.Document;
import net.yacy.document.LibraryProvider;
@@ -136,6 +137,7 @@ import de.anomic.crawler.ResultURLs;
import de.anomic.crawler.RobotsTxt;
import de.anomic.crawler.CrawlProfile.CacheStrategy;
import de.anomic.crawler.ResultURLs.EventOrigin;
+import de.anomic.crawler.ZURL.FailCategory;
import de.anomic.crawler.retrieval.Request;
import de.anomic.crawler.retrieval.Response;
import de.anomic.data.WorkTables;
@@ -242,7 +244,7 @@ public final class Switchboard extends serverSwitch {
private final Semaphore shutdownSync = new Semaphore(0);
private boolean terminate = false;
- public SolrSingleConnector solrConnector = null;
+ public SolrChardingConnector solrConnector = null;
//private Object crawlingPausedSync = new Object();
//private boolean crawlingIsPaused = false;
@@ -446,7 +448,7 @@ public final class Switchboard extends serverSwitch {
// load ranking from distribution
final File rankingPath = new File(this.appPath, "ranking/YBR".replace('/', File.separatorChar));
- BlockRank.loadBlockRankTable(rankingPath, 8);
+ BlockRank.loadBlockRankTable(rankingPath, 16);
// load distributed ranking
// very large memory configurations allow to re-compute a ranking table
@@ -461,10 +463,24 @@ public final class Switchboard extends serverSwitch {
} else {
hostIndex = BlockRank.loadHostIndex(hostIndexFile);
}
+
+ // use an index segment to find hosts for given host hashes
+ String segmentName = getConfig(SwitchboardConstants.SEGMENT_PUBLIC, "default");
+ Segment segment = indexSegments.segment(segmentName);
+ MetadataRepository metadata = segment.urlMetadata();
+ Map<String,HostStat> hostHashResolver;
+ try {
+ hostHashResolver = metadata.domainHashResolver(metadata.domainSampleCollector());
+ } catch (IOException e) {
+ hostHashResolver = new HashMap<String, HostStat>();
+ }
+
// recursively compute a new ranking table
- BlockRank.ybrTables = BlockRank.evaluate(hostIndex, null, 0);
+ BlockRank.ybrTables = BlockRank.evaluate(hostIndex, hostHashResolver, null, 0);
hostIndex = null; // we don't need that here any more, so free the memory
- BlockRank.analyse(BlockRank.ybrTables, webStructure);
+
+ // use the web structure and the hostHash resolver to analyse the ranking table
+ BlockRank.analyse(BlockRank.ybrTables, webStructure, hostHashResolver);
// store the new table
//BlockRank.storeBlockRankTable(rankingPath);
}
@@ -545,9 +561,14 @@ public final class Switchboard extends serverSwitch {
TextParser.setDenyMime(getConfig(SwitchboardConstants.PARSER_MIME_DENY, ""));
// set up the solr interface
- String solrurl = this.getConfig("federated.service.solr.indexing.url", "http://127.0.0.1:8983/solr");
- boolean usesolr = this.getConfigBool("federated.service.solr.indexing.enabled", false) & solrurl.length() > 0;
- this.solrConnector = (usesolr) ? new SolrSingleConnector(solrurl, SolrScheme.SolrCellExtended) : null;
+ String solrurls = this.getConfig("federated.service.solr.indexing.url", "http://127.0.0.1:8983/solr");
+ boolean usesolr = this.getConfigBool("federated.service.solr.indexing.enabled", false) & solrurls.length() > 0;
+ try {
+ this.solrConnector = (usesolr) ? new SolrChardingConnector(solrurls, SolrScheme.SolrCellExtended, SolrChardingSelection.Method.MODULO_HOST_MD5) : null;
+ } catch (IOException e) {
+ Log.logException(e);
+ this.solrConnector = null;
+ }
// start a loader
log.logConfig("Starting Crawl Loader");
@@ -1329,7 +1350,7 @@ public final class Switchboard extends serverSwitch {
// log cause and close queue
final DigestURI referrerURL = response.referrerURL();
//if (log.isFine()) log.logFine("deQueue: not indexed any word in URL " + response.url() + "; cause: " + noIndexReason);
- addURLtoErrorDB(response.url(), (referrerURL == null) ? null : referrerURL.hash(), response.initiator(), response.name(), noIndexReason);
+ addURLtoErrorDB(response.url(), (referrerURL == null) ? null : referrerURL.hash(), response.initiator(), response.name(), FailCategory.FINAL_PROCESS_CONTEXT, noIndexReason);
// finish this entry
return "not allowed: " + noIndexReason;
}
@@ -1871,7 +1892,7 @@ public final class Switchboard extends serverSwitch {
b = Cache.getContent(response.url().hash());
if (b == null) {
this.log.logWarning("the resource '" + response.url() + "' is missing in the cache.");
- addURLtoErrorDB(response.url(), response.referrerHash(), response.initiator(), response.name(), "missing in cache");
+ addURLtoErrorDB(response.url(), response.referrerHash(), response.initiator(), response.name(), FailCategory.FINAL_LOAD_CONTEXT, "missing in cache");
return null;
}
}
@@ -1884,7 +1905,7 @@ public final class Switchboard extends serverSwitch {
}
} catch (final Parser.Failure e) {
this.log.logWarning("Unable to parse the resource '" + response.url() + "'. " + e.getMessage());
- addURLtoErrorDB(response.url(), response.referrerHash(), response.initiator(), response.name(), e.getMessage());
+ addURLtoErrorDB(response.url(), response.referrerHash(), response.initiator(), response.name(), FailCategory.FINAL_PROCESS_CONTEXT, e.getMessage());
return null;
}
@@ -1963,6 +1984,14 @@ public final class Switchboard extends serverSwitch {
}
}
}
+
+ // check if we should accept the document for our index
+ if (!this.getConfigBool("federated.service.yacy.indexing.enabled", false)) {
+ if (log.isInfo()) {
+ log.logInfo("Not Condensed Resource '" + in.queueEntry.url().toNormalform(false, true) + "': indexing not wanted by federated rule for YaCy");
+ }
+ return new indexingQueueEntry(in.process, in.queueEntry, in.documents, null);
+ }
if (!in.queueEntry.profile().indexText() && !in.queueEntry.profile().indexMedia()) {
if (log.isInfo()) {
log.logInfo("Not Condensed Resource '" + in.queueEntry.url().toNormalform(false, true) + "': indexing not wanted by crawl profile");
@@ -1977,7 +2006,7 @@ public final class Switchboard extends serverSwitch {
if (log.isInfo()) {
log.logInfo("Not Condensed Resource '" + in.queueEntry.url().toNormalform(false, true) + "': denied by document-attached noindexing rule");
}
- addURLtoErrorDB(in.queueEntry.url(), in.queueEntry.referrerHash(), in.queueEntry.initiator(), in.queueEntry.name(), "denied by document-attached noindexing rule");
+ addURLtoErrorDB(in.queueEntry.url(), in.queueEntry.referrerHash(), in.queueEntry.initiator(), in.queueEntry.name(), FailCategory.FINAL_PROCESS_CONTEXT, "denied by document-attached noindexing rule");
continue;
}
doclist.add(document);
@@ -2037,13 +2066,13 @@ public final class Switchboard extends serverSwitch {
if (condenser == null || document.indexingDenied()) {
//if (this.log.isInfo()) log.logInfo("Not Indexed Resource '" + queueEntry.url().toNormalform(false, true) + "': denied by rule in document, process case=" + processCase);
- addURLtoErrorDB(queueEntry.url(), (referrerURL == null) ? null : referrerURL.hash(), queueEntry.initiator(), dc_title, "denied by rule in document, process case=" + processCase);
+ addURLtoErrorDB(queueEntry.url(), (referrerURL == null) ? null : referrerURL.hash(), queueEntry.initiator(), dc_title, FailCategory.FINAL_PROCESS_CONTEXT, "denied by rule in document, process case=" + processCase);
return;
}
if (!queueEntry.profile().indexText() && !queueEntry.profile().indexMedia()) {
//if (this.log.isInfo()) log.logInfo("Not Indexed Resource '" + queueEntry.url().toNormalform(false, true) + "': denied by profile rule, process case=" + processCase + ", profile name = " + queueEntry.profile().name());
- addURLtoErrorDB(queueEntry.url(), (referrerURL == null) ? null : referrerURL.hash(), queueEntry.initiator(), dc_title, "denied by profile rule, process case=" + processCase + ", profile name = " + queueEntry.profile().name());
+ addURLtoErrorDB(queueEntry.url(), (referrerURL == null) ? null : referrerURL.hash(), queueEntry.initiator(), dc_title, FailCategory.FINAL_LOAD_CONTEXT, "denied by profile rule, process case=" + processCase + ", profile name = " + queueEntry.profile().name());
return;
}
@@ -2066,7 +2095,7 @@ public final class Switchboard extends serverSwitch {
yacyChannel.channels(Base64Order.enhancedCoder.equal(queueEntry.initiator(), UTF8.getBytes(peers.mySeed().hash)) ? yacyChannel.LOCALINDEXING : yacyChannel.REMOTEINDEXING).addMessage(new RSSMessage("Indexed web page", dc_title, queueEntry.url().toNormalform(true, false)));
} catch (final IOException e) {
//if (this.log.isFine()) log.logFine("Not Indexed Resource '" + queueEntry.url().toNormalform(false, true) + "': process case=" + processCase);
- addURLtoErrorDB(queueEntry.url(), (referrerURL == null) ? null : referrerURL.hash(), queueEntry.initiator(), dc_title, "error storing url: " + queueEntry.url().toNormalform(false, true) + "': process case=" + processCase + ", error = " + e.getMessage());
+ addURLtoErrorDB(queueEntry.url(), (referrerURL == null) ? null : referrerURL.hash(), queueEntry.initiator(), dc_title, FailCategory.FINAL_LOAD_CONTEXT, "error storing url: " + queueEntry.url().toNormalform(false, true) + "': process case=" + processCase + ", error = " + e.getMessage());
return;
}
@@ -2448,6 +2477,7 @@ public final class Switchboard extends serverSwitch {
final byte[] referrerHash,
final byte[] initiator,
final String name,
+ final FailCategory failCategory,
final String failreason
) {
// assert initiator != null; // null == proxy
@@ -2463,7 +2493,7 @@ public final class Switchboard extends serverSwitch {
0,
0,
0);
- crawlQueues.errorURL.push(bentry, initiator, new Date(), 0, failreason, -1);
+ crawlQueues.errorURL.push(bentry, initiator, new Date(), 0, failCategory, failreason, -1);
}
public final void heuristicSite(final SearchEvent searchEvent, final String host) {
diff --git a/source/de/anomic/yacy/dht/Dispatcher.java b/source/de/anomic/yacy/dht/Dispatcher.java
index 5fb288052..966059387 100755
--- a/source/de/anomic/yacy/dht/Dispatcher.java
+++ b/source/de/anomic/yacy/dht/Dispatcher.java
@@ -198,7 +198,7 @@ public class Dispatcher {
for (ReferenceContainer<WordReference> c: containers) {
urlHashes.clear();
it = c.entries();
- while (it.hasNext()) try { urlHashes.put(it.next().metadataHash()); } catch (RowSpaceExceededException e) { Log.logException(e); }
+ while (it.hasNext()) try { urlHashes.put(it.next().urlhash()); } catch (RowSpaceExceededException e) { Log.logException(e); }
if (this.log.isFine()) this.log.logFine("selected " + urlHashes.size() + " urls for word '" + UTF8.String(c.getTermHash()) + "'");
if (!urlHashes.isEmpty()) this.segment.termIndex().remove(c.getTermHash(), urlHashes);
}
@@ -250,7 +250,7 @@ public class Dispatcher {
while (i.hasNext()) {
re = i.next();
if (re == null) continue;
- partitionBuffer[this.seeds.scheme.verticalPosition(re.metadataHash())].add(re);
+ partitionBuffer[this.seeds.scheme.verticalPosition(re.urlhash())].add(re);
}
// add the containers to the result vector
diff --git a/source/de/anomic/yacy/dht/Transmission.java b/source/de/anomic/yacy/dht/Transmission.java
index 7b9826fad..00bad6b2a 100644
--- a/source/de/anomic/yacy/dht/Transmission.java
+++ b/source/de/anomic/yacy/dht/Transmission.java
@@ -121,17 +121,17 @@ public class Transmission {
List<byte[]> notFoundx = new ArrayList<byte[]>();
while (i.hasNext()) {
WordReference e = i.next();
- if (references.containsKey(e.metadataHash())) continue;
- if (badReferences.has(e.metadataHash())) {
- notFoundx.add(e.metadataHash());
+ if (references.containsKey(e.urlhash())) continue;
+ if (badReferences.has(e.urlhash())) {
+ notFoundx.add(e.urlhash());
continue;
}
- URIMetadataRow r = segment.urlMetadata().load(e.metadataHash());
+ URIMetadataRow r = segment.urlMetadata().load(e.urlhash());
if (r == null) {
- notFoundx.add(e.metadataHash());
- badReferences.put(e.metadataHash());
+ notFoundx.add(e.urlhash());
+ badReferences.put(e.urlhash());
} else {
- references.put(e.metadataHash(), r);
+ references.put(e.urlhash(), r);
}
}
// now delete all references that were not found
diff --git a/source/de/anomic/yacy/graphics/WebStructureGraph.java b/source/de/anomic/yacy/graphics/WebStructureGraph.java
index 095ce0d28..364a90cb9 100644
--- a/source/de/anomic/yacy/graphics/WebStructureGraph.java
+++ b/source/de/anomic/yacy/graphics/WebStructureGraph.java
@@ -67,7 +67,7 @@ import net.yacy.kelondro.util.LookAheadIterator;
public class WebStructureGraph {
public static int maxref = 300; // maximum number of references, to avoid overflow when a large link farm occurs (i.e. wikipedia)
- public static int maxhosts = 20000; // maximum number of hosts in web structure map
+ public static int maxhosts = 50000; // maximum number of hosts in web structure map
private final static Log log = new Log("WebStructureGraph");
@@ -140,6 +140,7 @@ public class WebStructureGraph {
public void generateCitationReference(final DigestURI url, final Document document, final Condenser condenser) {
// generate citation reference
+ if (url.isLocal()) return; // we do this only for global urls
final Map<MultiProtocolURI, String> hl = document.getHyperlinks();
final Iterator<MultiProtocolURI> it = hl.keySet().iterator();
final HashSet<MultiProtocolURI> globalRefURLs = new HashSet<MultiProtocolURI>();
@@ -344,7 +345,7 @@ public class WebStructureGraph {
return this.entry;
}
- public byte[] metadataHash() {
+ public byte[] urlhash() {
return this.entry.getPrimaryKeyBytes();
}
@@ -576,17 +577,6 @@ public class WebStructureGraph {
}
}
- private void saveWebStructure() {
- joinOldNew();
- try {
- synchronized(structure_old) {
- FileUtils.saveMap(this.structureFile, this.structure_old, "Web Structure Syntax: <b64hash(6)>','<host> to <date-yyyymmdd(8)>{<target-b64hash(6)><target-count-hex(4)>}*");
- }
- } catch (final IOException e) {
- Log.logException(e);
- }
- }
-
public String hostWithMaxReferences() {
// find host with most references
String maxhost = null;
@@ -651,6 +641,7 @@ public class WebStructureGraph {
}
public void close() {
+ // finish dns resolving queue
if (this.publicRefDNSResolvingWorker.isAlive()) {
log.logInfo("Waiting for the DNS Resolving Queue to terminate");
try {
@@ -659,7 +650,22 @@ public class WebStructureGraph {
} catch (InterruptedException e) {
}
}
- log.logInfo("Saving Web Structure File");
- saveWebStructure();
+
+ // save to web structure file
+ log.logInfo("Saving Web Structure File: new = " + this.structure_new.size() + " entries, old = " + this.structure_old.size() + " entries");
+ long time = System.currentTimeMillis();
+ joinOldNew();
+ if (this.structure_old.size() > 0) try {
+ synchronized(structure_old) {
+ if (this.structure_old.size() > 0) {
+ FileUtils.saveMap(this.structureFile, this.structure_old, "Web Structure Syntax: <b64hash(6)>','<host> to <date-yyyymmdd(8)>{<target-b64hash(6)><target-count-hex(4)>}*");
+ long t = Math.max(1, System.currentTimeMillis() - time);
+ log.logInfo("Saved Web Structure File: " + this.structure_old.size() + " entries in " + t + " milliseconds, " + (this.structure_old.size() * 1000 / t) + " entries/second");
+ }
+ this.structure_old.clear();
+ }
+ } catch (final IOException e) {
+ Log.logException(e);
+ }
}
}
diff --git a/source/de/anomic/yacy/yacyClient.java b/source/de/anomic/yacy/yacyClient.java
index 4f54a32b8..dc6e09aa7 100644
--- a/source/de/anomic/yacy/yacyClient.java
+++ b/source/de/anomic/yacy/yacyClient.java
@@ -507,8 +507,8 @@ public final class yacyClient {
}
// the search-result-url transports all the attributes of word indexes
- if (!Base64Order.enhancedCoder.equal(entry.metadataHash(), urlEntry.hash())) {
- yacyCore.log.logInfo("remote search: url-hash " + UTF8.String(urlEntry.hash()) + " does not belong to word-attached-hash " + UTF8.String(entry.metadataHash()) + "; url = " + metadata.url() + " from peer " + target.getName());
+ if (!Base64Order.enhancedCoder.equal(entry.urlhash(), urlEntry.hash())) {
+ yacyCore.log.logInfo("remote search: url-hash " + UTF8.String(urlEntry.hash()) + " does not belong to word-attached-hash " + UTF8.String(entry.urlhash()) + "; url = " + metadata.url() + " from peer " + target.getName());
continue; // spammed
}
@@ -853,8 +853,8 @@ public final class yacyClient {
eenum = ic.entries();
while (eenum.hasNext()) {
entry = eenum.next();
- if (urlCache.get(entry.metadataHash()) == null) {
- if (yacyCore.log.isFine()) yacyCore.log.logFine("DEBUG transferIndex: to-send url hash '" + UTF8.String(entry.metadataHash()) + "' is not contained in urlCache");
+ if (urlCache.get(entry.urlhash()) == null) {
+ if (yacyCore.log.isFine()) yacyCore.log.logFine("DEBUG transferIndex: to-send url hash '" + UTF8.String(entry.urlhash()) + "' is not contained in urlCache");
}
}
}
diff --git a/source/net/yacy/cora/services/federated/solr/SolrChardingConnector.java b/source/net/yacy/cora/services/federated/solr/SolrChardingConnector.java
new file mode 100644
index 000000000..12f79bebb
--- /dev/null
+++ b/source/net/yacy/cora/services/federated/solr/SolrChardingConnector.java
@@ -0,0 +1,180 @@
+/**
+ * SolrChardingConnector
+ * Copyright 2011 by Michael Peter Christen
+ * First released 25.05.2011 at http://yacy.net
+ *
+ * $LastChangedDate: 2011-04-14 22:05:04 +0200 (Do, 14 Apr 2011) $
+ * $LastChangedRevision: 7654 $
+ * $LastChangedBy: orbiter $
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program in the file lgpl21.txt
+ * If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.yacy.cora.services.federated.solr;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import net.yacy.cora.protocol.ResponseHeader;
+import net.yacy.document.Document;
+import net.yacy.kelondro.data.meta.DigestURI;
+
+import org.apache.solr.common.SolrDocument;
+import org.apache.solr.common.SolrDocumentList;
+import org.apache.solr.common.SolrInputDocument;
+
+
+public class SolrChardingConnector {
+
+ private final List<SolrSingleConnector> connectors;
+ private final SolrScheme scheme;
+ private final SolrChardingSelection charding;
+ private final String[] urls;
+
+ public SolrChardingConnector(final String urlList, SolrScheme scheme, SolrChardingSelection.Method method) throws IOException {
+ this.urls = urlList.split(",");
+ this.connectors = new ArrayList<SolrSingleConnector>();
+ for (String u: urls) {
+ this.connectors.add(new SolrSingleConnector(u.trim(), scheme));
+ }
+ this.charding = new SolrChardingSelection(method, urls.length);
+ this.scheme = scheme;
+ }
+
+ public void close() {
+ for (SolrSingleConnector connector: this.connectors) connector.close();
+ }
+
+ /**
+ * delete everything in the solr index
+ * @throws IOException
+ */
+ public void clear() throws IOException {
+ for (SolrSingleConnector connector: this.connectors) connector.clear();
+ }
+
+ /**
+ * delete an entry from solr
+ * @param id the url hash of the entry
+ * @throws IOException
+ */
+ public void delete(String id) throws IOException {
+ for (SolrSingleConnector connector: this.connectors) connector.delete(id);
+ }
+
+ /**
+ * delete a set of entries from solr; entries are identified by their url hash
+ * @param ids a list of url hashes
+ * @throws IOException
+ */
+ public void delete(List<String> ids) throws IOException {
+ for (SolrSingleConnector connector: this.connectors) connector.delete(ids);
+ }
+
+ /**
+ * add a YaCy document. This calls the scheme processor to add the document as solr document
+ * @param id the url hash of the entry
+ * @param header the http response header
+ * @param doc the YaCy document
+ * @throws IOException
+ */
+ public void add(String id, ResponseHeader header, Document doc) throws IOException {
+ add(this.scheme.yacy2solr(id, header, doc));
+ }
+
+ /**
+ * add a Solr document
+ * @param solrdoc
+ * @throws IOException
+ */
+ private void add(SolrInputDocument solrdoc) throws IOException {
+ this.connectors.get(this.charding.select(solrdoc)).add(solrdoc);
+ }
+
+ /**
+ * add a collection of Solr documents
+ * @param docs
+ * @throws IOException
+ */
+ protected void addSolr(Collection<SolrInputDocument> docs) throws IOException {
+ for (SolrInputDocument doc: docs) add(doc);
+ }
+
+ /**
+ * register an entry as error document
+ * @param digestURI
+ * @param failReason
+ * @param httpstatus
+ * @throws IOException
+ */
+ public void err(DigestURI digestURI, String failReason, int httpstatus) throws IOException {
+ this.connectors.get(this.charding.selectURL(digestURI.toNormalform(true, false))).err(digestURI, failReason, httpstatus);
+ }
+
+
+ /**
+ * get a query result from solr
+ * to get all results set the query String to "*:*"
+ * @param querystring
+ * @throws IOException
+ */
+ public SolrDocumentList get(String querystring, int offset, int count) throws IOException {
+ SolrDocumentList list = new SolrDocumentList();
+ for (SolrSingleConnector connector: this.connectors) {
+ SolrDocumentList l = connector.get(querystring, offset, count);
+ for (SolrDocument d: l) {
+ list.add(d);
+ }
+ }
+ return list;
+ }
+
+ public SolrDocumentList[] getList(String querystring, int offset, int count) throws IOException {
+ SolrDocumentList[] list = new SolrDocumentList[this.connectors.size()];
+ int i = 0;
+ for (SolrSingleConnector connector: this.connectors) {
+ list[i++] = connector.get(querystring, offset, count);
+ }
+ return list;
+ }
+
+ public long[] getSizeList() throws IOException {
+ long[] size = new long[this.connectors.size()];
+ int i = 0;
+ for (SolrSingleConnector connector: this.connectors) {
+ SolrDocumentList list = connector.get("*:*", 0, 1);
+ size[i++] = list.getNumFound();
+ }
+ return size;
+ }
+
+ public long getSize() throws IOException {
+ long[] size = getSizeList();
+ long s = 0;
+ for (long l: size) s += l;
+ return s;
+ }
+
+ public String[] getAdminInterfaceList() {
+ String[] urlAdmin = new String[this.connectors.size()];
+ int i = 0;
+ for (String u: this.urls) {
+ urlAdmin[i++] = u + "/admin/";
+ }
+ return urlAdmin;
+ }
+}
diff --git a/source/net/yacy/cora/services/federated/solr/SolrChardingSelection.java b/source/net/yacy/cora/services/federated/solr/SolrChardingSelection.java
new file mode 100644
index 000000000..5c9877ec4
--- /dev/null
+++ b/source/net/yacy/cora/services/federated/solr/SolrChardingSelection.java
@@ -0,0 +1,93 @@
+/**
+ * SolrChardingSelection
+ * Copyright 2011 by Michael Peter Christen
+ * First released 25.05.2011 at http://yacy.net
+ *
+ * $LastChangedDate: 2011-04-14 22:05:04 +0200 (Do, 14 Apr 2011) $
+ * $LastChangedRevision: 7654 $
+ * $LastChangedBy: orbiter $
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program in the file lgpl21.txt
+ * If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.yacy.cora.services.federated.solr;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.nio.charset.Charset;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.solr.common.SolrInputDocument;
+
+public class SolrChardingSelection {
+
+ public final static Charset charsetUTF8;
+ static {
+ charsetUTF8 = Charset.forName("UTF-8");
+ }
+
+ private final Method method; // the charding method
+ private AtomicLong chardID; // the next id that shall be given away
+ private final int dimension; // the number of chards
+ public enum Method {
+ MODULO_HOST_MD5, ROUND_ROBIN;
+ }
+
+ public SolrChardingSelection(Method method, int dimension) {
+ this.method = method;
+ this.dimension = dimension;
+ this.chardID = new AtomicLong(0);
+ }
+
+ private int selectRoundRobin() {
+ return (int) (this.chardID.getAndIncrement() % this.dimension);
+ }
+
+ public int select(SolrInputDocument solrdoc) throws IOException {
+ if (this.method == Method.MODULO_HOST_MD5) {
+ String sku = (String) solrdoc.getField("sku").getValue();
+ return selectURL(sku);
+ }
+
+ // finally if no method matches use ROUND_ROBIN
+ return selectRoundRobin();
+ }
+
+ public int selectURL(String sku) throws IOException {
+ if (this.method == Method.MODULO_HOST_MD5) {
+ try {
+ URL url = new URL(sku);
+ String host = url.getHost();
+ if (host == null) throw new IOException("charding - bad url, host empty: " + sku);
+ try {
+ MessageDigest digest = MessageDigest.getInstance("MD5");
+ digest.update(host.getBytes(charsetUTF8));
+ byte[] md5 = digest.digest();
+ return (0xff & md5[0]) % this.dimension;
+ } catch (NoSuchAlgorithmException e) {
+ throw new IOException("charding - no md5 available: " + e.getMessage());
+ }
+ } catch (MalformedURLException e) {
+ throw new IOException("charding - bad url: " + sku);
+ }
+ }
+
+ // finally if no method matches use ROUND_ROBIN
+ return (int) (this.chardID.getAndIncrement() % this.dimension);
+ }
+}
diff --git a/source/net/yacy/cora/services/federated/solr/SolrScheme.java b/source/net/yacy/cora/services/federated/solr/SolrScheme.java
index 807e9c67a..99a9277be 100644
--- a/source/net/yacy/cora/services/federated/solr/SolrScheme.java
+++ b/source/net/yacy/cora/services/federated/solr/SolrScheme.java
@@ -57,6 +57,7 @@ public enum SolrScheme {
// we user the SolrCell design as index scheme
SolrInputDocument solrdoc = new SolrInputDocument();
DigestURI digestURI = new DigestURI(yacydoc.dc_source());
+ solrdoc.addField("failreason_t", ""); // overwrite a possible fail reason (in case that there was a fail reason before)
solrdoc.addField("id", id);
solrdoc.addField("sku", digestURI.toNormalform(true, false), 3.0f);
InetAddress address = Domains.dnsResolve(digestURI.getHost());
diff --git a/source/net/yacy/cora/services/federated/solr/SolrSingleConnector.java b/source/net/yacy/cora/services/federated/solr/SolrSingleConnector.java
index 426b0bbd9..4b176bbd4 100644
--- a/source/net/yacy/cora/services/federated/solr/SolrSingleConnector.java
+++ b/source/net/yacy/cora/services/federated/solr/SolrSingleConnector.java
@@ -174,7 +174,7 @@ public class SolrSingleConnector {
add(this.scheme.yacy2solr(id, header, doc));
}
- private void add(SolrInputDocument solrdoc) throws IOException {
+ protected void add(SolrInputDocument solrdoc) throws IOException {
int thisrrc = this.transmissionRoundRobinCounter;
int nextrrc = thisrrc++;
if (nextrrc >= transmissionQueueCount) nextrrc = 0;
diff --git a/source/net/yacy/cora/storage/AbstractScoreMap.java b/source/net/yacy/cora/storage/AbstractScoreMap.java
index 0884bc804..c68cd93c0 100644
--- a/source/net/yacy/cora/storage/AbstractScoreMap.java
+++ b/source/net/yacy/cora/storage/AbstractScoreMap.java
@@ -45,6 +45,19 @@ public abstract class AbstractScoreMap<E> implements ScoreMap<E> {
* @return the objects of the smaller entries from at least 1/2 of the list
*/
public List<E> lowerHalf() {
+
+ // first calculate the average of the entries
+ long a = 0;
+ for (E entry: this) a += get(entry);
+ a = a / this.size();
+
+ // then select all entries which are smaller that the average
+
+ ArrayList<E> list = new ArrayList<E>();
+ for (E entry: this) if (get(entry) < a) list.add(entry);
+ return list;
+
+ /*
int half = this.size() >> 1;
int smallestCount = 0;
ArrayList<E> list = new ArrayList<E>();
@@ -55,5 +68,6 @@ public abstract class AbstractScoreMap<E> implements ScoreMap<E> {
smallestCount++;
}
return list;
+ */
}
}
diff --git a/source/net/yacy/document/parser/images/bmpParser.java b/source/net/yacy/document/parser/images/bmpParser.java
index 57a9e63d2..26b8f8a54 100644
--- a/source/net/yacy/document/parser/images/bmpParser.java
+++ b/source/net/yacy/document/parser/images/bmpParser.java
@@ -112,7 +112,7 @@ public class bmpParser {
public COLORTABLE(final byte[] s, final int offset, final INFOHEADER infoheader) {
// read colortable
colorbytes = 0; // for consistency check
- if (infoheader.biClrUsed == 0) {
+ if (infoheader.biClrUsed == 0 || infoheader.biClrUsed > 1024) {
if ((infoheader.biBitCount == 1) || (infoheader.biBitCount == 4) || (infoheader.biBitCount == 8)) {
colorindex = new int[1 << infoheader.biBitCount];
colorbytes = 4 * colorindex.length;
@@ -126,7 +126,7 @@ public class bmpParser {
colorindex = null;
}
} else {
- colorindex = new int[infoheader.biClrUsed];
+ colorindex = new int[infoheader.biClrUsed]; // OOM DANGER!
colorbytes = 4 * colorindex.length;
int color;
for (int i = 0; i < colorindex.length; i++) {
diff --git a/source/net/yacy/kelondro/blob/Compressor.java b/source/net/yacy/kelondro/blob/Compressor.java
index d305a3889..05c6dea71 100644
--- a/source/net/yacy/kelondro/blob/Compressor.java
+++ b/source/net/yacy/kelondro/blob/Compressor.java
@@ -268,8 +268,11 @@ public class Compressor implements BLOB {
return null;
}
- public synchronized boolean containsKey(byte[] key) {
- return this.buffer.containsKey(UTF8.String(key)) || this.backend.containsKey(key);
+ public boolean containsKey(byte[] key) {
+ String keys = UTF8.String(key);
+ synchronized (this) {
+ return this.buffer.containsKey(keys) || this.backend.containsKey(key);
+ }
}
public int keylength() {
@@ -285,16 +288,19 @@ public class Compressor implements BLOB {
}
}
- public synchronized long length(byte[] key) throws IOException {
- byte[] b = buffer.get(UTF8.String(key));
- if (b != null) return b.length;
- try {
- b = this.backend.get(key);
- if (b == null) return 0;
- b = decompress(b);
- return (b == null) ? 0 : b.length;
- } catch (RowSpaceExceededException e) {
- throw new IOException(e.getMessage());
+ public long length(byte[] key) throws IOException {
+ String keys = UTF8.String(key);
+ synchronized (this) {
+ byte[] b = buffer.get(keys);
+ if (b != null) return b.length;
+ try {
+ b = this.backend.get(key);
+ if (b == null) return 0;
+ b = decompress(b);
+ return (b == null) ? 0 : b.length;
+ } catch (RowSpaceExceededException e) {
+ throw new IOException(e.getMessage());
+ }
}
}
diff --git a/source/net/yacy/kelondro/data/citation/CitationReferenceRow.java b/source/net/yacy/kelondro/data/citation/CitationReferenceRow.java
index cd1b7ffc0..45020cb52 100644
--- a/source/net/yacy/kelondro/data/citation/CitationReferenceRow.java
+++ b/source/net/yacy/kelondro/data/citation/CitationReferenceRow.java
@@ -136,7 +136,7 @@ public final class CitationReferenceRow implements Reference /*, Cloneable*/ {
return this.entry;
}
- public byte[] metadataHash() {
+ public byte[] urlhash() {
return this.entry.getColBytes(col_urlhash, true);
}
@@ -185,7 +185,7 @@ public final class CitationReferenceRow implements Reference /*, Cloneable*/ {
@Override
public int hashCode() {
- return ByteArray.hashCode(this.metadataHash());
+ return ByteArray.hashCode(this.urlhash());
}
@Override
@@ -194,7 +194,7 @@ public final class CitationReferenceRow implements Reference /*, Cloneable*/ {
if (obj == null) return false;
if (!(obj instanceof CitationReferenceRow)) return false;
CitationReferenceRow other = (CitationReferenceRow) obj;
- return Base64Order.enhancedCoder.equal(this.metadataHash(), other.metadataHash());
+ return Base64Order.enhancedCoder.equal(this.urlhash(), other.urlhash());
}
public int distance() {
diff --git a/source/net/yacy/kelondro/data/image/ImageReferenceRow.java b/source/net/yacy/kelondro/data/image/ImageReferenceRow.java
index fc2cdcfe3..4b05a5e52 100644
--- a/source/net/yacy/kelondro/data/image/ImageReferenceRow.java
+++ b/source/net/yacy/kelondro/data/image/ImageReferenceRow.java
@@ -211,7 +211,7 @@ public final class ImageReferenceRow extends AbstractReference implements /*Imag
return this.entry;
}
- public byte[] metadataHash() {
+ public byte[] urlhash() {
return this.entry.getColBytes(col_urlhash, true);
}
@@ -278,7 +278,7 @@ public final class ImageReferenceRow extends AbstractReference implements /*Imag
@Override
public int hashCode() {
- return ByteArray.hashCode(this.metadataHash());
+ return ByteArray.hashCode(this.urlhash());
}
public void join(Reference oe) {
diff --git a/source/net/yacy/kelondro/data/image/ImageReferenceVars.java b/source/net/yacy/kelondro/data/image/ImageReferenceVars.java
index 3a2007ac4..7683c7bcc 100644
--- a/source/net/yacy/kelondro/data/image/ImageReferenceVars.java
+++ b/source/net/yacy/kelondro/data/image/ImageReferenceVars.java
@@ -107,7 +107,7 @@ public class ImageReferenceVars extends AbstractReference implements ImageRefere
//this.freshUntil = e.freshUntil();
this.lastModified = e.lastModified();
this.language = e.getLanguage();
- this.urlHash = e.metadataHash();
+ this.urlHash = e.urlhash();
this.type = e.getType();
this.hitcount = e.hitcount();
this.llocal = e.llocal();
@@ -267,7 +267,7 @@ public class ImageReferenceVars extends AbstractReference implements ImageRefere
return toRowEntry().toPropertyForm();
}
- public byte[] metadataHash() {
+ public byte[] urlhash() {
return urlHash;
}
diff --git a/source/net/yacy/kelondro/data/meta/DigestURI.java b/source/net/yacy/kelondro/data/meta/DigestURI.java
index 8fb713956..a031db2e5 100644
--- a/source/net/yacy/kelondro/data/meta/DigestURI.java
+++ b/source/net/yacy/kelondro/data/meta/DigestURI.java
@@ -103,7 +103,7 @@ public class DigestURI extends MultiProtocolURI implements Serializable {
*/
public DigestURI(final MultiProtocolURI baseURL) {
super(baseURL);
- this.hash = null;
+ this.hash = (baseURL instanceof DigestURI) ? ((DigestURI) baseURL).hash : null;
}
/**
diff --git a/source/net/yacy/kelondro/data/navigation/NavigationReference.java b/source/net/yacy/kelondro/data/navigation/NavigationReference.java
index 77927e98c..dff495446 100644
--- a/source/net/yacy/kelondro/data/navigation/NavigationReference.java
+++ b/source/net/yacy/kelondro/data/navigation/NavigationReference.java
@@ -37,7 +37,7 @@ public interface NavigationReference extends Reference {
public String navigationHash();
- public byte[] metadataHash();
+ public byte[] urlhash();
public byte[] termHash();
diff --git a/source/net/yacy/kelondro/data/navigation/NavigationReferenceRow.java b/source/net/yacy/kelondro/data/navigation/NavigationReferenceRow.java
index 2ff10e30c..88b7dd909 100644
--- a/source/net/yacy/kelondro/data/navigation/NavigationReferenceRow.java
+++ b/source/net/yacy/kelondro/data/navigation/NavigationReferenceRow.java
@@ -122,7 +122,7 @@ public final class NavigationReferenceRow extends AbstractReference implements N
return this.entry.getColString(col_navhash);
}
- public byte[] metadataHash() {
+ public byte[] urlhash() {
return UTF8.getBytes(navigationHash().substring(12));
}
diff --git a/source/net/yacy/kelondro/data/navigation/NavigationReferenceVars.java b/source/net/yacy/kelondro/data/navigation/NavigationReferenceVars.java
index f245e603d..07aae0ab4 100644
--- a/source/net/yacy/kelondro/data/navigation/NavigationReferenceVars.java
+++ b/source/net/yacy/kelondro/data/navigation/NavigationReferenceVars.java
@@ -54,7 +54,7 @@ public class NavigationReferenceVars extends AbstractReference implements Navig
}
public NavigationReferenceVars(final NavigationReference e) {
- this.refhash = e.metadataHash();
+ this.refhash = e.urlhash();
this.termhash = e.termHash();
this.hitcount = e.hitcount();
this.position = e.position(0);
@@ -94,7 +94,7 @@ public class NavigationReferenceVars extends AbstractReference implements Navig
return UTF8.String(this.termhash) + UTF8.String(this.refhash);
}
- public byte[] metadataHash() {
+ public byte[] urlhash() {
return this.refhash;
}
diff --git a/source/net/yacy/kelondro/data/word/WordReferenceFactory.java b/source/net/yacy/kelondro/data/word/WordReferenceFactory.java
index 686b3862f..6104d7a4d 100644
--- a/source/net/yacy/kelondro/data/word/WordReferenceFactory.java
+++ b/source/net/yacy/kelondro/data/word/WordReferenceFactory.java
@@ -73,9 +73,9 @@ public class WordReferenceFactory implements ReferenceFactory<WordReference> {
StringBuilder paths;
while (i.hasNext()) {
iEntry = i.next();
- if ((excludeContainer != null) && (excludeContainer.getReference(iEntry.metadataHash()) != null)) continue; // do not include urls that are in excludeContainer
- dom = UTF8.String(iEntry.metadataHash(), 6, 6);
- mod = UTF8.String(iEntry.metadataHash(), 0, 6);
+ if ((excludeContainer != null) && (excludeContainer.getReference(iEntry.urlhash()) != null)) continue; // do not include urls that are in excludeContainer
+ dom = UTF8.String(iEntry.urlhash(), 6, 6);
+ mod = UTF8.String(iEntry.urlhash(), 0, 6);
if ((paths = doms.get(dom)) == null) {
doms.put(dom, new StringBuilder(30).append(mod));
} else {
diff --git a/source/net/yacy/kelondro/data/word/WordReferenceRow.java b/source/net/yacy/kelondro/data/word/WordReferenceRow.java
index 19b20ab2e..212348f1c 100644
--- a/source/net/yacy/kelondro/data/word/WordReferenceRow.java
+++ b/source/net/yacy/kelondro/data/word/WordReferenceRow.java
@@ -236,7 +236,7 @@ public final class WordReferenceRow extends AbstractReference implements WordRef
return this.entry;
}
- public byte[] metadataHash() {
+ public byte[] urlhash() {
return this.entry.getColBytes(col_urlhash, true);
}
@@ -328,12 +328,12 @@ public final class WordReferenceRow extends AbstractReference implements WordRef
if (obj == null) return false;
if (!(obj instanceof WordReferenceRow)) return false;
WordReferenceRow other = (WordReferenceRow) obj;
- return Base64Order.enhancedCoder.equal(this.metadataHash(), other.metadataHash());
+ return Base64Order.enhancedCoder.equal(this.urlhash(), other.urlhash());
}
@Override
public int hashCode() {
- return ByteArray.hashCode(this.metadataHash());
+ return ByteArray.hashCode(this.urlhash());
}
public void join(final Reference oe) {
diff --git a/source/net/yacy/kelondro/data/word/WordReferenceVars.java b/source/net/yacy/kelondro/data/word/WordReferenceVars.java
index 10bfd22a2..ff59353a2 100644
--- a/source/net/yacy/kelondro/data/word/WordReferenceVars.java
+++ b/source/net/yacy/kelondro/data/word/WordReferenceVars.java
@@ -116,7 +116,7 @@ public class WordReferenceVars extends AbstractReference implements WordReferenc
//this.freshUntil = e.freshUntil();
this.lastModified = e.lastModified();
this.language = e.getLanguage();
- this.urlHash = e.metadataHash();
+ this.urlHash = e.urlhash();
this.type = e.getType();
this.hitcount = e.hitcount();
this.llocal = e.llocal();
@@ -267,7 +267,7 @@ public class WordReferenceVars extends AbstractReference implements WordReferenc
return toRowEntry().toPropertyForm();
}
- public byte[] metadataHash() {
+ public byte[] urlhash() {
return urlHash;
}
@@ -369,7 +369,7 @@ public class WordReferenceVars extends AbstractReference implements WordReferenc
}
public int compareTo(final WordReferenceVars o) {
- return Base64Order.enhancedCoder.compare(this.urlHash, o.metadataHash());
+ return Base64Order.enhancedCoder.compare(this.urlHash, o.urlhash());
}
public int compare(WordReferenceVars o1, WordReferenceVars o2) {
diff --git a/source/net/yacy/kelondro/index/BinSearch.java b/source/net/yacy/kelondro/index/BinSearch.java
index 4300005ad..fcebedce8 100644
--- a/source/net/yacy/kelondro/index/BinSearch.java
+++ b/source/net/yacy/kelondro/index/BinSearch.java
@@ -64,19 +64,21 @@ public final class BinSearch {
return contains(t, 0, this.count);
}
- private final synchronized boolean contains(final byte[] t, final int beginPos, final int endPos) {
+ private final boolean contains(final byte[] t, int beginPos, int endPos) {
// the endPos is exclusive, beginPos is inclusive
// this method is synchronized to make the use of the buffer possible
assert t.length == this.chunksize;
- if (beginPos >= endPos) return false;
- final int pivot = (beginPos + endPos) / 2;
- if ((pivot < 0) || (pivot >= this.count)) return false;
- assert this.chunksize == t.length;
- final int c = objectOrder.compare(this.chunks, pivot * this.chunksize, t, 0, this.chunksize);
- if (c == 0) return true;
- if (c < 0) /* buffer < t */ return contains(t, pivot + 1, endPos);
- if (c > 0) /* buffer > t */ return contains(t, beginPos, pivot);
- return false;
+ while (true) {
+ if (beginPos >= endPos) return false;
+ final int pivot = (beginPos + endPos) / 2;
+ if ((pivot < 0) || (pivot >= this.count)) return false;
+ assert this.chunksize == t.length;
+ final int c = objectOrder.compare(this.chunks, pivot * this.chunksize, t, 0, this.chunksize);
+ if (c == 0) return true;
+ if (c < 0) /* buffer < t */ {beginPos = pivot + 1; continue;}
+ if (c > 0) /* buffer > t */ {endPos = pivot; continue;}
+ return false;
+ }
}
public final int size() {
diff --git a/source/net/yacy/kelondro/rwi/Reference.java b/source/net/yacy/kelondro/rwi/Reference.java
index 8293b5fce..b97ac59a8 100644
--- a/source/net/yacy/kelondro/rwi/Reference.java
+++ b/source/net/yacy/kelondro/rwi/Reference.java
@@ -36,7 +36,7 @@ public interface Reference {
public Entry toKelondroEntry();
- public byte[] metadataHash();
+ public byte[] urlhash();
public long lastModified();
diff --git a/source/net/yacy/kelondro/rwi/ReferenceContainer.java b/source/net/yacy/kelondro/rwi/ReferenceContainer.java
index 5f114698e..202172418 100644
--- a/source/net/yacy/kelondro/rwi/ReferenceContainer.java
+++ b/source/net/yacy/kelondro/rwi/ReferenceContainer.java
@@ -364,10 +364,10 @@ public class ReferenceContainer<ReferenceType extends Reference> extends RowSet
ReferenceType ie2;
while (se.hasNext()) {
ie1 = se.next();
- ie2 = large.getReference(ie1.metadataHash());
+ ie2 = large.getReference(ie1.urlhash());
if ((ie1 != null) && (ie2 != null)) {
- assert (ie1.metadataHash().length == keylength) : "ie0.urlHash() = " + UTF8.String(ie1.metadataHash());
- assert (ie2.metadataHash().length == keylength) : "ie1.urlHash() = " + UTF8.String(ie2.metadataHash());
+ assert (ie1.urlhash().length == keylength) : "ie0.urlHash() = " + UTF8.String(ie1.urlhash());
+ assert (ie2.urlhash().length == keylength) : "ie1.urlHash() = " + UTF8.String(ie2.urlhash());
// this is a hit. Calculate word distance:
ie1 = factory.produceFast(ie2);
@@ -400,9 +400,9 @@ public class ReferenceContainer<ReferenceType extends Reference> extends RowSet
ie2 = e2.next();
while (true) {
- assert (ie1.metadataHash().length == keylength) : "ie1.urlHash() = " + UTF8.String(ie1.metadataHash());
- assert (ie2.metadataHash().length == keylength) : "ie2.urlHash() = " + UTF8.String(ie2.metadataHash());
- c = ordering.compare(ie1.metadataHash(), ie2.metadataHash());
+ assert (ie1.urlhash().length == keylength) : "ie1.urlHash() = " + UTF8.String(ie1.urlhash());
+ assert (ie2.urlhash().length == keylength) : "ie2.urlHash() = " + UTF8.String(ie2.urlhash());
+ c = ordering.compare(ie1.urlhash(), ie2.urlhash());
//System.out.println("** '" + ie1.getUrlHash() + "'.compareTo('" + ie2.getUrlHash() + "')="+c);
if (c < 0) {
if (e1.hasNext()) ie1 = e1.next(); else break;
@@ -454,11 +454,11 @@ public class ReferenceContainer<ReferenceType extends Reference> extends RowSet
Reference ie0, ie1;
while (se.hasNext()) {
ie0 = se.next();
- ie1 = excl.getReference(ie0.metadataHash());
+ ie1 = excl.getReference(ie0.urlhash());
if ((ie0 != null) && (ie1 != null)) {
- assert (ie0.metadataHash().length == keylength) : "ie0.urlHash() = " + UTF8.String(ie0.metadataHash());
- assert (ie1.metadataHash().length == keylength) : "ie1.urlHash() = " + UTF8.String(ie1.metadataHash());
- if (iterate_pivot) se.remove(); pivot.delete(ie0.metadataHash());
+ assert (ie0.urlhash().length == keylength) : "ie0.urlHash() = " + UTF8.String(ie0.urlhash());
+ assert (ie1.urlhash().length == keylength) : "ie1.urlHash() = " + UTF8.String(ie1.urlhash());
+ if (iterate_pivot) se.remove(); pivot.delete(ie0.urlhash());
}
}
return pivot;
@@ -482,9 +482,9 @@ public class ReferenceContainer<ReferenceType extends Reference> extends RowSet
ie2 = e2.next();
while (true) {
- assert (ie1.metadataHash().length == keylength) : "ie1.urlHash() = " + UTF8.String(ie1.metadataHash());
- assert (ie2.metadataHash().length == keylength) : "ie2.urlHash() = " + UTF8.String(ie2.metadataHash());
- c = pivot.rowdef.getOrdering().compare(ie1.metadataHash(), ie2.metadataHash());
+ assert (ie1.urlhash().length == keylength) : "ie1.urlHash() = " + UTF8.String(ie1.urlhash());
+ assert (ie2.urlhash().length == keylength) : "ie2.urlHash() = " + UTF8.String(ie2.urlhash());
+ c = pivot.rowdef.getOrdering().compare(ie1.urlhash(), ie2.urlhash());
//System.out.println("** '" + ie1.getUrlHash() + "'.compareTo('" + ie2.getUrlHash() + "')="+c);
if (c < 0) {
if (e1.hasNext()) ie1 = e1.next(); else break;
diff --git a/source/net/yacy/kelondro/rwi/ReferenceContainerArray.java b/source/net/yacy/kelondro/rwi/ReferenceContainerArray.java
index 9dbc380e5..13f8c12c0 100644
--- a/source/net/yacy/kelondro/rwi/ReferenceContainerArray.java
+++ b/source/net/yacy/kelondro/rwi/ReferenceContainerArray.java
@@ -380,7 +380,7 @@ public final class ReferenceContainerArray<ReferenceType extends Reference> {
while (refi.hasNext()) {
reference = refi.next();
if (reference == null) continue;
- mh = reference.metadataHash();
+ mh = reference.urlhash();
if (mh == null) continue;
references.inc(mh);
}
diff --git a/source/net/yacy/kelondro/rwi/ReferenceContainerCache.java b/source/net/yacy/kelondro/rwi/ReferenceContainerCache.java
index ee1c90b17..1026f6976 100644
--- a/source/net/yacy/kelondro/rwi/ReferenceContainerCache.java
+++ b/source/net/yacy/kelondro/rwi/ReferenceContainerCache.java
@@ -316,7 +316,7 @@ public final class ReferenceContainerCache<ReferenceType extends Reference> exte
ReferenceType ee;
while (e.hasNext()) {
ee = e.next();
- if (urlselection.has(ee.metadataHash())) {
+ if (urlselection.has(ee.urlhash())) {
c1.add(ee);
}
}
diff --git a/source/net/yacy/kelondro/util/FileUtils.java b/source/net/yacy/kelondro/util/FileUtils.java
index 295aa02c9..1a4a2b323 100644
--- a/source/net/yacy/kelondro/util/FileUtils.java
+++ b/source/net/yacy/kelondro/util/FileUtils.java
@@ -153,7 +153,8 @@ public final class FileUtils {
dest.flush();
} catch (final Exception e) {
// an "sun.io.MalformedInputException: Missing byte-order mark" - exception may occur here
- throw new IOException(e.getMessage());
+ Log.logException(e);
+ throw new IOException(e.getMessage(), e);
}
return count;
}
diff --git a/source/net/yacy/yacy.java b/source/net/yacy/yacy.java
index b7315cad8..aab9ece7b 100644
--- a/source/net/yacy/yacy.java
+++ b/source/net/yacy/yacy.java
@@ -668,7 +668,7 @@ public final class yacy {
Reference iEntry;
while (wordIdxEntries.hasNext()) {
iEntry = wordIdxEntries.next();
- final byte[] urlHash = iEntry.metadataHash();
+ final byte[] urlHash = iEntry.urlhash();
if ((currentUrlDB.exists(urlHash)) && (!minimizedUrlDB.exists(urlHash))) try {
final URIMetadataRow urlEntry = currentUrlDB.load(urlHash);
urlCounter++;