Skip to content

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

- refactoring of robots parser - no more keep-order parameter in remove (it was not possible to make this strict, and not useful) - some small enhancements in balancer - robots parser without references in switchboard - changes synchronization in robots

orbitera6719dfd2ba4
diff --git a/htroot/IndexControlRWIs_p.java b/htroot/IndexControlRWIs_p.java
index a316e7147..5bcf4a7f6 100644
--- a/htroot/IndexControlRWIs_p.java
+++ b/htroot/IndexControlRWIs_p.java
@@ -115,7 +115,7 @@ public class IndexControlRWIs_p {
e.printStackTrace();
}
try {
- plasmaSwitchboard.robots.clear();
+ sb.robots.clear();
} catch (IOException e) {
e.printStackTrace();
}
diff --git a/htroot/Network.java b/htroot/Network.java
index 9db82acb0..7027c8b53 100644
--- a/htroot/Network.java
+++ b/htroot/Network.java
@@ -56,7 +56,6 @@ import java.util.regex.PatternSyntaxException;
import de.anomic.crawler.HTTPLoader;
import de.anomic.http.HttpClient;
-import de.anomic.http.JakartaCommonsHttpClient;
import de.anomic.http.httpHeader;
import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverCodings;
diff --git a/htroot/Statistics.html b/htroot/Statistics.html
deleted file mode 100644
index 8da379b19..000000000
--- a/htroot/Statistics.html
+++ /dev/null
@@ -1,49 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
-<html>
-<head>
-<title>YaCy '#[clientname]#': Statistics</title>
-#%env/templates/metas.template%#
-</head>
-<body marginheight="0" marginwidth="0" leftmargin="0" topmargin="0">
-#%env/templates/header.template%#
-<table width="100%" border="0" cellpadding="0" cellspacing="0" class="SubMenu">
-<tr height="10"><td colspan="7" class="MenuHeader">&nbsp;Statistics Menu</td></tr>
-<tr height="2"><td colspan="7"></td></tr>
-<tr class="TableHeader">
-<td width="50%" class="MenuSubItem">&nbsp;&nbsp;<a href="/Statistics.html" class="MenuItemLink">Backlinks</a>&nbsp;</td>
-<td class="MenuSubSpacer"></td>
-<td width="50%" class="MenuSubItem">&nbsp;&nbsp;<a href="/Statistics.html?page=1" class="MenuItemLink">Zeitgeist</a>&nbsp;</td>
-</tr>
-</table>
-<br>
-#(page)#
-<h2>Backlinks</h2>
-#(backlinks)#
-<p>no backlinks so far (another web page must link to your peer's search page
-and someone must have clicked on that link; then the referrer pages appears here).</p>
-::
-<p>Showing #[num]# entries from a total of #[total]# backlinks:<br>
-<table border="0" cellpadding="2" cellspacing="1">
-<tr class="TableHeader" valign="bottom">
-<td class="small">Url<br>&nbsp;</td>
-<td class="small">Time<br>&nbsp;</td>
-<td class="small">Client IP<br>&nbsp;</td>
-<td class="small">Client User Agent<br>&nbsp;</td>
-</tr>
-#{list}#
-<tr class="TableCell#(dark)#Light::Dark#(/dark)#">
-<td class="small" align="right"><a href="#[url]#">#[url]#</a></td>
-<td class="small" align="right">#[date]#</td>
-<td class="small" align="right">#[clientip]#</td>
-<td class="small" align="right">#[useragent]#</td>
-</tr>
-#{/list}#
-</table>
-</p>
-#(/backlinks)#
-::
-<h2>Zeitgeist</h2>
-#(/page)#
-#%env/templates/footer.template%#
-</body>
-</html>
diff --git a/htroot/Statistics.java b/htroot/Statistics.java
deleted file mode 100644
index 81a7bc12c..000000000
--- a/htroot/Statistics.java
+++ /dev/null
@@ -1,105 +0,0 @@
-// Statistics.java
-// -----------------------
-// part of YaCy
-// (C) by Michael Peter Christen; [email protected]
-// first published on http://www.anomic.de
-// Frankfurt, Germany, 2004, 2005
-// last major change: 16.02.2005
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// Using this software in any meaning (reading, learning, copying, compiling,
-// running) means that you agree that the Author(s) is (are) not responsible
-// for cost, loss of data or any harm that may be caused directly or indirectly
-// by usage of this softare or this documentation. The usage of this software
-// is on your own risk. The installation and usage (starting/running) of this
-// software may allow other people or application to access your computer and
-// any attached devices and is highly dependent on the configuration of the
-// software which must be done by the user of the software; the author(s) is
-// (are) also not responsible for proper configuration and usage of the
-// software, even if provoked by documentation provided together with
-// the software.
-//
-// Any changes to this file according to the GPL as documented in the file
-// gpl.txt aside this file in the shipment you received can be done to the
-// lines that follows this copyright notice here, but changes must not be
-// done inside the copyright notive above. A re-distribution must contain
-// the intact and unchanged copyright notice.
-// Contributions and changes to the program code must be marked as such.
-
-// You must compile this file with
-// javac -classpath .:../classes Network.java
-// if the shell's current path is HTROOT
-
-import java.net.MalformedURLException;
-import java.util.HashMap;
-
-import de.anomic.http.httpHeader;
-import de.anomic.kelondro.kelondroMapObjects;
-import de.anomic.plasma.plasmaSwitchboard;
-import de.anomic.server.serverObjects;
-import de.anomic.server.serverSwitch;
-import de.anomic.yacy.yacyURL;
-
-public class Statistics {
-
- public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch<?> sb) {
- // return variable that accumulates replacements
- plasmaSwitchboard switchboard = (plasmaSwitchboard) sb;
- serverObjects prop = new serverObjects();
- if (null == switchboard.facilityDB)
- return prop;
-
- int page = (post == null) ? 0 : post.getInt("page", 0);
-
- prop.put("page", page);
- switch (page) {
- case 0:
- if (switchboard.facilityDB.size("backlinks") == 0) {
- prop.put("page_backlinks", "0");
- } else {
- prop.put("page_backlinks", "1");
- kelondroMapObjects.mapIterator it = switchboard.facilityDB.maps("backlinks", false, "date");
- int count = 0;
- int maxCount = 100;
- boolean dark = true;
- HashMap<String, String> map;
- String urlString;
- yacyURL url;
- while ((it.hasNext()) && (count < maxCount)) {
- map = it.next();
- if (count >= maxCount) break;
- urlString = map.get("key");
- try { url = new yacyURL(urlString, null); } catch (MalformedURLException e) { url = null; }
- if ((url != null) && (!url.isLocal())) {
- prop.put("page_backlinks_list_" + count + "_dark", dark ? "1" : "0");
- dark =! dark;
- prop.put("page_backlinks_list_" + count + "_url", urlString);
- prop.put("page_backlinks_list_" + count + "_date", map.get("date"));
- prop.put("page_backlinks_list_" + count + "_clientip", map.get("clientip"));
- prop.put("page_backlinks_list_" + count + "_useragent", map.get("useragent"));
- count++;
- }
- }//while
- prop.putNum("page_backlinks_list", count);
- prop.putNum("page_backlinks_num", count);
- prop.putNum("page_backlinks_total", switchboard.facilityDB.size("backlinks"));
- }
- break;
- }
- // return rewrite properties
- return prop;
- }
-}
diff --git a/htroot/xml/util/getpageinfo_p.java b/htroot/xml/util/getpageinfo_p.java
index da20ae5bf..7115318f7 100644
--- a/htroot/xml/util/getpageinfo_p.java
+++ b/htroot/xml/util/getpageinfo_p.java
@@ -50,11 +50,11 @@ import java.io.Writer;
import java.net.MalformedURLException;
import de.anomic.crawler.HTTPLoader;
-import de.anomic.data.robotsParser;
import de.anomic.htmlFilter.htmlFilterContentScraper;
import de.anomic.htmlFilter.htmlFilterWriter;
import de.anomic.http.HttpClient;
import de.anomic.http.httpHeader;
+import de.anomic.plasma.plasmaSwitchboard;
import de.anomic.server.serverFileUtils;
import de.anomic.server.serverObjects;
import de.anomic.server.serverSwitch;
@@ -63,6 +63,7 @@ import de.anomic.yacy.yacyURL;
public class getpageinfo_p {
public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch<?> env) {
+ plasmaSwitchboard sb = (plasmaSwitchboard) env;
serverObjects prop = new serverObjects();
prop.put("sitemap", "");
prop.put("title", "");
@@ -84,7 +85,7 @@ public class getpageinfo_p {
try {
yacyURL u = new yacyURL(url, null);
httpHeader reqHeader = new httpHeader();
- reqHeader.put(httpHeader.USER_AGENT, HTTPLoader.crawlerUserAgent);
+ reqHeader.put(httpHeader.USER_AGENT, HTTPLoader.yacyUserAgent); // do not set the crawler user agent, because this page was loaded by manual entering of the url
byte[] r = HttpClient.wget(u.toString(), reqHeader, 5000);
if (r == null) return prop;
String contentString=new String(r);
@@ -126,10 +127,10 @@ public class getpageinfo_p {
yacyURL theURL = new yacyURL(url, null);
// determine if crawling of the current URL is allowed
- prop.put("robots-allowed", robotsParser.isDisallowed(theURL) ? "0" : "1");
+ prop.put("robots-allowed", sb.robots.isDisallowed(theURL) ? "0" : "1");
// get the sitemap URL of the domain
- yacyURL sitemapURL = robotsParser.getSitemapURL(theURL);
+ yacyURL sitemapURL = sb.robots.getSitemapURL(theURL);
prop.putHTML("sitemap", (sitemapURL==null)?"":sitemapURL.toString(), true);
} catch (MalformedURLException e) {}
}
diff --git a/htroot/yacy/user/ysearch.java b/htroot/yacy/user/ysearch.java
index 92f00ae1f..0662fd64a 100644
--- a/htroot/yacy/user/ysearch.java
+++ b/htroot/yacy/user/ysearch.java
@@ -105,7 +105,6 @@ public class ysearch {
querystring = querystring.substring(1, querystring.length() - 1).trim();
maxDistance = 1;
}
- if (sb.facilityDB != null) try { sb.facilityDB.update("zeitgeist", querystring, post); } catch (Exception e) {}
int itemsPerPage = Math.min((authenticated) ? 1000 : 10, post.getInt("maximumRecords", post.getInt("count", 10))); // SRU syntax with old property as alternative
int offset = post.getInt("startRecord", post.getInt("offset", 0));
diff --git a/htroot/yacysearch.java b/htroot/yacysearch.java
index c0c8c2e3a..4cb9583ac 100644
--- a/htroot/yacysearch.java
+++ b/htroot/yacysearch.java
@@ -141,7 +141,6 @@ public class yacysearch {
querystring = querystring.substring(1, querystring.length() - 1).trim();
maxDistance = 1;
}
- if (sb.facilityDB != null) try { sb.facilityDB.update("zeitgeist", querystring, post); } catch (Exception e) {}
int itemsPerPage = Math.min((authenticated) ? 1000 : 10, post.getInt("maximumRecords", post.getInt("count", 10))); // SRU syntax with old property as alternative
int offset = post.getInt("startRecord", post.getInt("offset", 0));
diff --git a/source/dbtest.java b/source/dbtest.java
index 1af844322..c4c11b335 100644
--- a/source/dbtest.java
+++ b/source/dbtest.java
@@ -146,8 +146,8 @@ public class dbtest {
final STEntry entry = new STEntry(this.getSource());
System.out.println("remove: " + serverLog.arrayList(entry.getKey(), 0, entry.getKey().length));
try {
- getTable_test().remove(entry.getKey(), false);
- if (getTable_reference() != null) getTable_reference().remove(entry.getKey(), false);
+ getTable_test().remove(entry.getKey());
+ if (getTable_reference() != null) getTable_reference().remove(entry.getKey());
} catch (IOException e) {
System.err.println(e);
e.printStackTrace();
@@ -391,7 +391,7 @@ public class dbtest {
start = System.currentTimeMillis();
for (int i = 0; i < count; i++) {
key = randomHash(random);
- table_test.remove(key, false);
+ table_test.remove(key);
}
remove = System.currentTimeMillis() - start;
diff --git a/source/de/anomic/crawler/Balancer.java b/source/de/anomic/crawler/Balancer.java
index c6da2cd4c..9b0ba7808 100644
--- a/source/de/anomic/crawler/Balancer.java
+++ b/source/de/anomic/crawler/Balancer.java
@@ -218,7 +218,7 @@ public class Balancer {
int s = urlFileIndex.size();
int removedCounter = 0;
for (String urlhash: urlHashes) {
- kelondroRow.Entry entry = urlFileIndex.remove(urlhash.getBytes(), false);
+ kelondroRow.Entry entry = urlFileIndex.remove(urlhash.getBytes());
if (entry != null) removedCounter++;
}
if (removedCounter == 0) return 0;
@@ -431,7 +431,7 @@ public class Balancer {
hitlist.put(new Integer(domlist.size() * 100 + count++), domhash);
}
- // now iterate in descending order an fetch that one,
+ // now iterate in descending order and fetch that one,
// that is acceptable by the minimumDelta constraint
long delta;
String maxhash = null;
@@ -491,7 +491,7 @@ public class Balancer {
long delta = lastAccessDelta(result);
assert delta >= 0: "delta = " + delta;
int s = urlFileIndex.size();
- kelondroRow.Entry rowEntry = urlFileIndex.remove(result.getBytes(), false);
+ kelondroRow.Entry rowEntry = urlFileIndex.remove(result.getBytes());
assert (rowEntry == null) || (urlFileIndex.size() + 1 == s) : "urlFileIndex.size() = " + urlFileIndex.size() + ", s = " + s + ", result = " + result;
if (rowEntry == null) {
serverLog.logSevere("PLASMA BALANCER", "get() found a valid urlhash, but failed to fetch the corresponding url entry - total size = " + size() + ", fileStack.size() = " + urlFileStack.size() + ", ramStack.size() = " + urlRAMStack.size() + ", domainStacks.size() = " + domainStacks.size());
@@ -500,11 +500,12 @@ public class Balancer {
assert urlFileIndex.size() + 1 == s : "urlFileIndex.size() = " + urlFileIndex.size() + ", s = " + s + ", result = " + result;
}
CrawlEntry crawlEntry = new CrawlEntry(rowEntry);
- long minimumDelta = (crawlEntry.url().isLocal()) ? minimumLocalDelta : minimumGlobalDelta;
- RobotsTxt.Entry robotsEntry = plasmaSwitchboard.robots.getEntry(crawlEntry.url().getHost());
- Integer hostDelay = (robotsEntry == null) ? null : robotsEntry.getCrawlDelay();
- long genericDelta = ((robotsEntry == null) || (hostDelay == null)) ? minimumDelta : Math.max(minimumDelta, hostDelay.intValue() * 1000);
- genericDelta = Math.min(10000, genericDelta); // prevent that ta robots file can stop our indexer completely
+ long genericDelta = Math.min(
+ 15000,
+ Math.max(
+ (crawlEntry.url().isLocal()) ? minimumLocalDelta : minimumGlobalDelta,
+ plasmaSwitchboard.getSwitchboard().robots.crawlDelay(crawlEntry.url().getHost()) * 1000)
+ ); // prevent that that robots file can stop our indexer completely
if (delta < genericDelta) {
// force a busy waiting here
// in best case, this should never happen if the balancer works propertly
@@ -540,9 +541,15 @@ public class Balancer {
while ((urlFileStack != null) && (urlRAMStack.size() <= count) && (urlFileStack.size() > 0)) {
// flush some entries from disc to ram stack
try {
+ // one from the top:
kelondroRow.Entry t = urlFileStack.pop();
if (t == null) break;
urlRAMStack.add(new String(t.getColBytes(0)));
+ if (urlFileStack.size() == 0) break;
+ // one from the bottom:
+ t = urlFileStack.pot();
+ if (t == null) break;
+ urlRAMStack.add(new String(t.getColBytes(0)));
} catch (IOException e) {
break;
}
diff --git a/source/de/anomic/crawler/CrawlQueues.java b/source/de/anomic/crawler/CrawlQueues.java
index bdd077bbc..105cdf5c6 100644
--- a/source/de/anomic/crawler/CrawlQueues.java
+++ b/source/de/anomic/crawler/CrawlQueues.java
@@ -36,7 +36,6 @@ import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import de.anomic.data.robotsParser;
import de.anomic.kelondro.kelondroFlexWidthArray;
import de.anomic.plasma.plasmaHTCache;
import de.anomic.plasma.plasmaParser;
@@ -516,7 +515,7 @@ public class CrawlQueues {
try {
// checking robots.txt for http(s) resources
this.entry.setStatus("worker-checkingrobots");
- if ((entry.url().getProtocol().equals("http") || entry.url().getProtocol().equals("https")) && robotsParser.isDisallowed(entry.url())) {
+ if ((entry.url().getProtocol().equals("http") || entry.url().getProtocol().equals("https")) && sb.robots.isDisallowed(entry.url())) {
if (log.isFine()) log.logFine("Crawling of URL '" + entry.url().toString() + "' disallowed by robots.txt.");
ZURL.Entry eentry = errorURL.newEntry(
this.entry,
diff --git a/source/de/anomic/crawler/CrawlStacker.java b/source/de/anomic/crawler/CrawlStacker.java
index fa0a4c05d..9f0fbe9a8 100644
--- a/source/de/anomic/crawler/CrawlStacker.java
+++ b/source/de/anomic/crawler/CrawlStacker.java
@@ -351,7 +351,7 @@ public final class CrawlStacker extends Thread {
synchronized (this.urlEntryHashCache) {
urlHash = this.urlEntryHashCache.removeFirst();
if (urlHash == null) throw new IOException("urlHash is null");
- entry = this.urlEntryCache.remove(urlHash.getBytes(), true);
+ entry = this.urlEntryCache.remove(urlHash.getBytes());
}
if ((urlHash == null) || (entry == null)) return null;
diff --git a/source/de/anomic/crawler/RobotsTxt.java b/source/de/anomic/crawler/RobotsTxt.java
index ab178e231..d15bb8e4b 100644
--- a/source/de/anomic/crawler/RobotsTxt.java
+++ b/source/de/anomic/crawler/RobotsTxt.java
@@ -5,7 +5,8 @@
//first published on http://www.anomic.de
//Frankfurt, Germany, 2004
//
-//This file ist contributed by Martin Thelian
+//This file is contributed by Martin Thelian
+// [MC] moved some methods from robotsParser file that had been created by Alexander Schier to this class
//last major change: $LastChangedDate$ by $LastChangedBy$
//Revision: $LastChangedRevision$
//
@@ -45,8 +46,11 @@
package de.anomic.crawler;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
import java.io.File;
import java.io.IOException;
+import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
@@ -54,10 +58,18 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
+import de.anomic.http.HttpClient;
+import de.anomic.http.JakartaCommonsHttpClient;
+import de.anomic.http.JakartaCommonsHttpResponse;
+import de.anomic.http.httpHeader;
import de.anomic.kelondro.kelondroBLOBTree;
import de.anomic.kelondro.kelondroException;
import de.anomic.kelondro.kelondroMapObjects;
import de.anomic.kelondro.kelondroNaturalOrder;
+import de.anomic.server.serverByteBuffer;
+import de.anomic.server.serverFileUtils;
+import de.anomic.server.logging.serverLog;
+import de.anomic.yacy.yacyURL;
public class RobotsTxt {
@@ -90,19 +102,9 @@ public class RobotsTxt {
public int size() {
return this.robotsTable.size();
- }
-
- public void removeEntry(String hostName) {
- try {
- this.robotsTable.remove(hostName.toLowerCase());
- } catch (IOException e) {
-
- } catch (kelondroException e) {
- resetDatabase();
- }
}
- public Entry getEntry(String hostName) {
+ private Entry getEntry(String hostName) {
try {
HashMap<String, String> record = this.robotsTable.getMap(hostName);
if (record == null) return null;
@@ -111,9 +113,15 @@ public class RobotsTxt {
resetDatabase();
return null;
}
- }
+ }
+
+ public int crawlDelay(String hostname) {
+ RobotsTxt.Entry robotsEntry = getEntry(hostname);
+ Integer hostDelay = (robotsEntry == null) ? null : robotsEntry.getCrawlDelay();
+ if (hostDelay == null) return 0; else return hostDelay.intValue();
+ }
- public Entry addEntry(
+ private Entry addEntry(
String hostName,
ArrayList<String> disallowPathList,
Date loadedDate,
@@ -129,7 +137,7 @@ public class RobotsTxt {
return entry;
}
- public String addEntry(Entry entry) {
+ private String addEntry(Entry entry) {
// writes a new page and returns key
try {
this.robotsTable.set(entry.hostName, entry.mem);
@@ -280,5 +288,254 @@ public class RobotsTxt {
}
+ // methods that had been in robotsParser.java:
+
+ public static final int DOWNLOAD_ACCESS_RESTRICTED = 0;
+ public static final int DOWNLOAD_ROBOTS_TXT = 1;
+ public static final int DOWNLOAD_ETAG = 2;
+ public static final int DOWNLOAD_MODDATE = 3;
+
+ private static final String getHostPort(yacyURL theURL) {
+ String urlHostPort = null;
+ int port = getPort(theURL);
+ urlHostPort = theURL.getHost() + ":" + port;
+ urlHostPort = urlHostPort.toLowerCase().intern();
+
+ return urlHostPort;
+ }
+
+ private static final int getPort(yacyURL theURL) {
+ int port = theURL.getPort();
+ if (port == -1) {
+ if (theURL.getProtocol().equalsIgnoreCase("http")) {
+ port = 80;
+ } else if (theURL.getProtocol().equalsIgnoreCase("https")) {
+ port = 443;
+ }
+
+ }
+ return port;
+ }
+
+ public yacyURL getSitemapURL(yacyURL theURL) {
+ if (theURL == null) throw new IllegalArgumentException();
+ yacyURL sitemapURL = null;
+
+ // generating the hostname:poart string needed to do a DB lookup
+ String urlHostPort = getHostPort(theURL);
+
+ RobotsTxt.Entry robotsTxt4Host = this.getEntry(urlHostPort);
+ if (robotsTxt4Host == null) return null;
+
+ try {
+ String sitemapUrlStr = robotsTxt4Host.getSitemap();
+ if (sitemapUrlStr != null) sitemapURL = new yacyURL(sitemapUrlStr, null);
+ } catch (MalformedURLException e) {/* ignore this */}
+
+ return sitemapURL;
+ }
+
+ public Integer getCrawlDelay(yacyURL theURL) {
+ if (theURL == null) throw new IllegalArgumentException();
+ Integer crawlDelay = null;
+
+ // generating the hostname:poart string needed to do a DB lookup
+ String urlHostPort = getHostPort(theURL);
+
+ RobotsTxt.Entry robotsTxt4Host = getEntry(urlHostPort);
+ if (robotsTxt4Host == null) return null;
+
+ try {
+ crawlDelay = robotsTxt4Host.getCrawlDelay();
+ } catch (NumberFormatException e) {/* ignore this */}
+
+ return crawlDelay;
+ }
+
+ @SuppressWarnings("unchecked")
+ public boolean isDisallowed(yacyURL nexturl) {
+ if (nexturl == null) throw new IllegalArgumentException();
+
+ // generating the hostname:poart string needed to do a DB lookup
+ String urlHostPort = getHostPort(nexturl);
+
+ // do a DB lookup to determine if the robots data is already available
+ RobotsTxt.Entry robotsTxt4Host = getEntry(urlHostPort);
+
+ // if we have not found any data or the data is older than 7 days, we need to load it from the remote server
+ if (
+ (robotsTxt4Host == null) ||
+ (robotsTxt4Host.getLoadedDate() == null) ||
+ (System.currentTimeMillis() - robotsTxt4Host.getLoadedDate().getTime() > 7*24*60*60*1000)
+ ) {
+ synchronized(this) {
+
+ // generating the proper url to download the robots txt
+ yacyURL robotsURL = null;
+ try {
+ robotsURL = new yacyURL(nexturl.getProtocol(),nexturl.getHost(),getPort(nexturl),"/robots.txt");
+ } catch (MalformedURLException e) {
+ serverLog.logSevere("ROBOTS","Unable to generate robots.txt URL for URL '" + nexturl.toString() + "'.");
+ return false;
+ }
+
+ Object[] result = null;
+ boolean accessCompletelyRestricted = false;
+ byte[] robotsTxt = null;
+ String eTag = null;
+ Date modDate = null;
+ try {
+ serverLog.logFine("ROBOTS","Trying to download the robots.txt file from URL '" + robotsURL + "'.");
+ result = downloadRobotsTxt(robotsURL,5,robotsTxt4Host);
+
+ if (result != null) {
+ accessCompletelyRestricted = ((Boolean)result[DOWNLOAD_ACCESS_RESTRICTED]).booleanValue();
+ robotsTxt = (byte[])result[DOWNLOAD_ROBOTS_TXT];
+ eTag = (String) result[DOWNLOAD_ETAG];
+ modDate = (Date) result[DOWNLOAD_MODDATE];
+ } else if (robotsTxt4Host != null) {
+ robotsTxt4Host.setLoadedDate(new Date());
+ addEntry(robotsTxt4Host);
+ }
+ } catch (Exception e) {
+ serverLog.logSevere("ROBOTS","Unable to download the robots.txt file from URL '" + robotsURL + "'. " + e.getMessage());
+ }
+
+ if ((robotsTxt4Host==null)||((robotsTxt4Host!=null)&&(result!=null))) {
+ ArrayList<String> denyPath = null;
+ String sitemap = null;
+ Integer crawlDelay = null;
+ if (accessCompletelyRestricted) {
+ denyPath = new ArrayList<String>();
+ denyPath.add("/");
+ } else {
+ // parsing the robots.txt Data and converting it into an arraylist
+ try {
+ Object[] parserResult = robotsParser.parse(robotsTxt);
+ denyPath = (ArrayList<String>) parserResult[0];
+ sitemap = (String) parserResult[1];
+ crawlDelay = (Integer) parserResult[2];
+ } catch (IOException e) {
+ serverLog.logSevere("ROBOTS","Unable to parse the robots.txt file from URL '" + robotsURL + "'.");
+ }
+ }
+
+ // storing the data into the robots DB
+ robotsTxt4Host = addEntry(urlHostPort,denyPath,new Date(),modDate,eTag,sitemap,crawlDelay);
+ }
+ }
+ }
+
+ if (robotsTxt4Host != null && robotsTxt4Host.isDisallowed(nexturl.getFile())) {
+ return true;
+ }
+ return false;
+ }
+ private static Object[] downloadRobotsTxt(yacyURL robotsURL, int redirectionCount, RobotsTxt.Entry entry) throws Exception {
+
+ if (redirectionCount < 0) return new Object[]{Boolean.FALSE,null,null};
+ redirectionCount--;
+
+ boolean accessCompletelyRestricted = false;
+ byte[] robotsTxt = null;
+ long downloadStart, downloadEnd;
+ String eTag=null, oldEtag = null;
+ Date lastMod=null;
+ downloadStart = System.currentTimeMillis();
+
+ // if we previously have downloaded this robots.txt then we can set the if-modified-since header
+ httpHeader reqHeaders = new httpHeader();
+
+ // add yacybot user agent
+ reqHeaders.put(httpHeader.USER_AGENT, HTTPLoader.crawlerUserAgent);
+
+ // adding referer
+ reqHeaders.put(httpHeader.REFERER, (yacyURL.newURL(robotsURL,"/")).toNormalform(true, true));
+
+ if (entry != null) {
+ oldEtag = entry.getETag();
+ reqHeaders = new httpHeader();
+ Date modDate = entry.getModDate();
+ if (modDate != null) reqHeaders.put(httpHeader.IF_MODIFIED_SINCE,HttpClient.dateString(entry.getModDate()));
+
+ }
+
+ // setup http-client
+ //TODO: adding Traffic statistic for robots download?
+ JakartaCommonsHttpClient client = new JakartaCommonsHttpClient(10000, reqHeaders, null);
+ JakartaCommonsHttpResponse res = null;
+ try {
+ // sending the get request
+ res = client.GET(robotsURL.toString());
+
+ // check for interruption
+ if (Thread.currentThread().isInterrupted()) throw new InterruptedException("Shutdown in progress.");
+
+ // check the response status
+ if (res.getStatusLine().startsWith("2")) {
+ if (!res.getResponseHeader().mime().startsWith("text/plain")) {
+ robotsTxt = null;
+ serverLog.logFinest("ROBOTS","Robots.txt from URL '" + robotsURL + "' has wrong mimetype '" + res.getResponseHeader().mime() + "'.");
+ } else {
+
+ // getting some metadata
+ eTag = res.getResponseHeader().containsKey(httpHeader.ETAG)?(res.getResponseHeader().get(httpHeader.ETAG)).trim():null;
+ lastMod = res.getResponseHeader().lastModified();
+
+ // if the robots.txt file was not changed we break here
+ if ((eTag != null) && (oldEtag != null) && (eTag.equals(oldEtag))) {
+ serverLog.logFinest("ROBOTS","Robots.txt from URL '" + robotsURL + "' was not modified. Abort downloading of new version.");
+ return null;
+ }
+
+ // downloading the content
+ serverByteBuffer sbb = new serverByteBuffer();
+ try {
+ serverFileUtils.copyToStream(new BufferedInputStream(res.getDataAsStream()), new BufferedOutputStream(sbb));
+ } finally {
+ res.closeStream();
+ }
+ robotsTxt = sbb.getBytes();
+
+ downloadEnd = System.currentTimeMillis();
+ serverLog.logFinest("ROBOTS","Robots.txt successfully loaded from URL '" + robotsURL + "' in " + (downloadEnd-downloadStart) + " ms.");
+ }
+ } else if (res.getStatusCode() == 304) {
+ return null;
+ } else if (res.getStatusLine().startsWith("3")) {
+ // getting redirection URL
+ String redirectionUrlString = res.getResponseHeader().get(httpHeader.LOCATION);
+ if (redirectionUrlString==null) {
+ serverLog.logFinest("ROBOTS","robots.txt could not be downloaded from URL '" + robotsURL + "' because of missing redirecton header. [" + res.getStatusLine() + "].");
+ robotsTxt = null;
+ } else {
+
+ redirectionUrlString = redirectionUrlString.trim();
+
+ // generating the new URL object
+ yacyURL redirectionUrl = yacyURL.newURL(robotsURL, redirectionUrlString);
+
+ // following the redirection
+ serverLog.logFinest("ROBOTS","Redirection detected for robots.txt with URL '" + robotsURL + "'." +
+ "\nRedirecting request to: " + redirectionUrl);
+ return downloadRobotsTxt(redirectionUrl,redirectionCount,entry);
+ }
+ } else if (res.getStatusCode() == 401 || res.getStatusCode() == 403) {
+ accessCompletelyRestricted = true;
+ serverLog.logFinest("ROBOTS","Access to Robots.txt not allowed on URL '" + robotsURL + "'.");
+ } else {
+ serverLog.logFinest("ROBOTS","robots.txt could not be downloaded from URL '" + robotsURL + "'. [" + res.getStatusLine() + "].");
+ robotsTxt = null;
+ }
+ } catch (Exception e) {
+ throw e;
+ } finally {
+ if(res != null) {
+ // release connection
+ res.closeStream();
+ }
+ }
+ return new Object[]{new Boolean(accessCompletelyRestricted),robotsTxt,eTag,lastMod};
+ }
}
diff --git a/source/de/anomic/crawler/ZURL.java b/source/de/anomic/crawler/ZURL.java
index 41303cc39..4551da5ef 100755
--- a/source/de/anomic/crawler/ZURL.java
+++ b/source/de/anomic/crawler/ZURL.java
@@ -108,7 +108,7 @@ public class ZURL {
public boolean remove(String hash) {
if (hash == null) return false;
try {
- urlIndex.remove(hash.getBytes(), false);
+ urlIndex.remove(hash.getBytes());
return true;
} catch (IOException e) {
return false;
diff --git a/source/de/anomic/crawler/robotsParser.java b/source/de/anomic/crawler/robotsParser.java
new file mode 100644
index 000000000..a727cfaee
--- /dev/null
+++ b/source/de/anomic/crawler/robotsParser.java
@@ -0,0 +1,216 @@
+//robotsParser.java
+//-------------------------------------
+//part of YACY
+//
+//(C) 2005, 2006 by Alexander Schier
+// Martin Thelian
+//
+//last change: $LastChangedDate$ by $LastChangedBy$
+//Revision: $LastChangedRevision$
+//
+//This program is free software; you can redistribute it and/or modify
+//it under the terms of the GNU General Public License as published by
+//the Free Software Foundation; either version 2 of the License, or
+//(at your option) any later version.
+//
+//This program is distributed in the hope that it will be useful,
+//but WITHOUT ANY WARRANTY; without even the implied warranty of
+//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+//GNU General Public License for more details.
+//
+//You should have received a copy of the GNU General Public License
+//along with this program; if not, write to the Free Software
+//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+//Using this software in any meaning (reading, learning, copying, compiling,
+//running) means that you agree that the Author(s) is (are) not responsible
+//for cost, loss of data or any harm that may be caused directly or indirectly
+//by usage of this softare or this documentation. The usage of this software
+//is on your own risk. The installation and usage (starting/running) of this
+//software may allow other people or application to access your computer and
+//any attached devices and is highly dependent on the configuration of the
+//software which must be done by the user of the software; the author(s) is
+//(are) also not responsible for proper configuration and usage of the
+//software, even if provoked by documentation provided together with
+//the software.
+//
+//Any changes to this file according to the GPL as documented in the file
+//gpl.txt aside this file in the shipment you received can be done to the
+//lines that follows this copyright notice here, but changes must not be
+//done inside the copyright notive above. A re-distribution must contain
+//the intact and unchanged copyright notice.
+//Contributions and changes to the program code must be marked as such.
+
+package de.anomic.crawler;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+
+/*
+ * A class for Parsing robots.txt files.
+ * It only parses the Deny Part, yet.
+ *
+ * Robots RFC
+ * http://www.robotstxt.org/wc/norobots-rfc.html
+ *
+ * TODO:
+ * - On the request attempt resulted in temporary failure a robot
+ * should defer visits to the site until such time as the resource
+ * can be retrieved.
+ *
+ * - Extended Standard for Robot Exclusion
+ * See: http://www.conman.org/people/spc/robots2.html
+ *
+ * - Robot Exclusion Standard Revisited
+ * See: http://www.kollar.com/robots.html
+ */
+public final class robotsParser{
+ public static final String ROBOTS_USER_AGENT = "User-agent:".toUpperCase();
+ public static final String ROBOTS_DISALLOW = "Disallow:".toUpperCase();
+ public static final String ROBOTS_ALLOW = "Allow:".toUpperCase();
+ public static final String ROBOTS_COMMENT = "#";
+ public static final String ROBOTS_SITEMAP = "Sitemap:".toUpperCase();
+ public static final String ROBOTS_CRAWL_DELAY = "Crawl-Delay:".toUpperCase();
+
+ /*public robotsParser(URL robotsUrl){
+ }*/
+ /*
+ * this parses the robots.txt.
+ * at the Moment it only creates a list of Deny Paths
+ */
+
+ public static Object[] parse(File robotsFile) throws IOException {
+ BufferedReader reader = null;
+ try {
+ reader = new BufferedReader(new FileReader(robotsFile));
+ return parse(reader);
+ } finally {
+ if (reader != null) try{reader.close();}catch(Exception e){/* ignore this */}
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public static Object[] parse(byte[] robotsTxt) throws IOException {
+ if ((robotsTxt == null)||(robotsTxt.length == 0)) return new Object[]{new ArrayList(0),null,null};
+ ByteArrayInputStream bin = new ByteArrayInputStream(robotsTxt);
+ BufferedReader reader = new BufferedReader(new InputStreamReader(bin));
+ return parse(reader);
+ }
+
+ public static Object[] parse(BufferedReader reader) throws IOException{
+ ArrayList<String> deny4AllAgents = new ArrayList<String>();
+ ArrayList<String> deny4YaCyAgent = new ArrayList<String>();
+
+ int pos;
+ String line = null, lineUpper = null, sitemap = null;
+ Integer crawlDelay = null;
+ boolean isRuleBlock4AllAgents = false,
+ isRuleBlock4YaCyAgent = false,
+ rule4YaCyFound = false,
+ inBlock = false;
+
+ while ((line = reader.readLine()) != null) {
+ line = line.trim();
+ lineUpper = line.toUpperCase();
+
+ if (line.length() == 0) {
+ // OLD: we have reached the end of the rule block
+ // rule4Yacy = false; inBlock = false;
+
+ // NEW: just ignore it
+ } else if (line.startsWith(ROBOTS_COMMENT)) {
+ // we can ignore this. Just a comment line
+ } else if (lineUpper.startsWith(ROBOTS_SITEMAP)) {
+ pos = line.indexOf(" ");
+ if (pos != -1) {
+ sitemap = line.substring(pos).trim();
+ }
+ } else if (lineUpper.startsWith(ROBOTS_USER_AGENT)) {
+
+ if (inBlock) {
+ // we have detected the start of a new block
+ inBlock = false;
+ isRuleBlock4AllAgents = false;
+ isRuleBlock4YaCyAgent = false;
+ crawlDelay = null; // each block has a separate delay
+ }
+
+ // cutting off comments at the line end
+ pos = line.indexOf(ROBOTS_COMMENT);
+ if (pos != -1) line = line.substring(0,pos).trim();
+
+ // replacing all tabs with spaces
+ line = line.replaceAll("\t"," ");
+
+ // getting out the robots name
+ pos = line.indexOf(" ");
+ if (pos != -1) {
+ String userAgent = line.substring(pos).trim();
+ isRuleBlock4AllAgents |= userAgent.equals("*");
+ isRuleBlock4YaCyAgent |= userAgent.toLowerCase().indexOf("yacy") >=0;
+ if (isRuleBlock4YaCyAgent) rule4YaCyFound = true;
+ }
+ } else if (lineUpper.startsWith(ROBOTS_CRAWL_DELAY)) {
+ pos = line.indexOf(" ");
+ if (pos != -1) {
+ try {
+ crawlDelay = Integer.valueOf(line.substring(pos).trim());
+ } catch (NumberFormatException e) {
+ // invalid crawling delay
+ }
+ }
+ } else if (lineUpper.startsWith(ROBOTS_DISALLOW) ||
+ lineUpper.startsWith(ROBOTS_ALLOW)) {
+ inBlock = true;
+ boolean isDisallowRule = lineUpper.startsWith(ROBOTS_DISALLOW);
+
+ if (isRuleBlock4YaCyAgent || isRuleBlock4AllAgents) {
+ // cutting off comments at the line end
+ pos = line.indexOf(ROBOTS_COMMENT);
+ if (pos != -1) line = line.substring(0,pos).trim();
+
+ // cutting of tailing *
+ if (line.endsWith("*")) line = line.substring(0,line.length()-1);
+
+ // replacing all tabs with spaces
+ line = line.replaceAll("\t"," ");
+
+ // getting the path
+ pos = line.indexOf(" ");
+ if (pos != -1) {
+ // getting the path
+ String path = line.substring(pos).trim();
+
+ // unencoding all special charsx
+ try {
+ path = URLDecoder.decode(path,"UTF-8");
+ } catch (Exception e) {
+ /*
+ * url decoding failed. E.g. because of
+ * "Incomplete trailing escape (%) pattern"
+ */
+ }
+
+ // escaping all occurences of ; because this char is used as special char in the Robots DB
+ path = path.replaceAll(RobotsTxt.ROBOTS_DB_PATH_SEPARATOR,"%3B");
+
+ // adding it to the pathlist
+ if (!isDisallowRule) path = "!" + path;
+ if (isRuleBlock4AllAgents) deny4AllAgents.add(path);
+ if (isRuleBlock4YaCyAgent) deny4YaCyAgent.add(path);
+ }
+ }
+ }
+ }
+
+ ArrayList<String> denyList = (rule4YaCyFound) ? deny4YaCyAgent : deny4AllAgents;
+ return new Object[]{denyList,sitemap,crawlDelay};
+ }
+
+}
diff --git a/source/de/anomic/data/robotsParser.java b/source/de/anomic/data/robotsParser.java
deleted file mode 100644
index 6546b7401..000000000
--- a/source/de/anomic/data/robotsParser.java
+++ /dev/null
@@ -1,488 +0,0 @@
-//robotsParser.java
-//-------------------------------------
-//part of YACY
-//
-//(C) 2005, 2006 by Alexander Schier
-// Martin Thelian
-//
-//last change: $LastChangedDate$ by $LastChangedBy$
-//Revision: $LastChangedRevision$
-//
-//This program is free software; you can redistribute it and/or modify
-//it under the terms of the GNU General Public License as published by
-//the Free Software Foundation; either version 2 of the License, or
-//(at your option) any later version.
-//
-//This program is distributed in the hope that it will be useful,
-//but WITHOUT ANY WARRANTY; without even the implied warranty of
-//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-//GNU General Public License for more details.
-//
-//You should have received a copy of the GNU General Public License
-//along with this program; if not, write to the Free Software
-//Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-//Using this software in any meaning (reading, learning, copying, compiling,
-//running) means that you agree that the Author(s) is (are) not responsible
-//for cost, loss of data or any harm that may be caused directly or indirectly
-//by usage of this softare or this documentation. The usage of this software
-//is on your own risk. The installation and usage (starting/running) of this
-//software may allow other people or application to access your computer and
-//any attached devices and is highly dependent on the configuration of the
-//software which must be done by the user of the software; the author(s) is
-//(are) also not responsible for proper configuration and usage of the
-//software, even if provoked by documentation provided together with
-//the software.
-//
-//Any changes to this file according to the GPL as documented in the file
-//gpl.txt aside this file in the shipment you received can be done to the
-//lines that follows this copyright notice here, but changes must not be
-//done inside the copyright notive above. A re-distribution must contain
-//the intact and unchanged copyright notice.
-//Contributions and changes to the program code must be marked as such.
-
-package de.anomic.data;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.MalformedURLException;
-import java.net.URLDecoder;
-import java.util.ArrayList;
-import java.util.Date;
-
-import de.anomic.crawler.HTTPLoader;
-import de.anomic.crawler.RobotsTxt;
-import de.anomic.http.HttpClient;
-import de.anomic.http.JakartaCommonsHttpClient;
-import de.anomic.http.JakartaCommonsHttpResponse;
-import de.anomic.http.httpHeader;
-import de.anomic.plasma.plasmaSwitchboard;
-import de.anomic.server.serverByteBuffer;
-import de.anomic.server.serverFileUtils;
-import de.anomic.server.logging.serverLog;
-import de.anomic.yacy.yacyURL;
-
-/*
- * A class for Parsing robots.txt files.
- * It only parses the Deny Part, yet.
- *
- * Robots RFC
- * http://www.robotstxt.org/wc/norobots-rfc.html
- *
- * TODO:
- * - On the request attempt resulted in temporary failure a robot
- * should defer visits to the site until such time as the resource
- * can be retrieved.
- *
- * - Extended Standard for Robot Exclusion
- * See: http://www.conman.org/people/spc/robots2.html
- *
- * - Robot Exclusion Standard Revisited
- * See: http://www.kollar.com/robots.html
- */
-public final class robotsParser{
- public static final int DOWNLOAD_ACCESS_RESTRICTED = 0;
- public static final int DOWNLOAD_ROBOTS_TXT = 1;
- public static final int DOWNLOAD_ETAG = 2;
- public static final int DOWNLOAD_MODDATE = 3;
-
- public static final String ROBOTS_USER_AGENT = "User-agent:".toUpperCase();
- public static final String ROBOTS_DISALLOW = "Disallow:".toUpperCase();
- public static final String ROBOTS_ALLOW = "Allow:".toUpperCase();
- public static final String ROBOTS_COMMENT = "#";
- public static final String ROBOTS_SITEMAP = "Sitemap:".toUpperCase();
- public static final String ROBOTS_CRAWL_DELAY = "Crawl-Delay:".toUpperCase();
-
- /*public robotsParser(URL robotsUrl){
- }*/
- /*
- * this parses the robots.txt.
- * at the Moment it only creates a list of Deny Paths
- */
-
- public static Object[] parse(File robotsFile) throws IOException {
- BufferedReader reader = null;
- try {
- reader = new BufferedReader(new FileReader(robotsFile));
- return parse(reader);
- } finally {
- if (reader != null) try{reader.close();}catch(Exception e){/* ignore this */}
- }
- }
-
- @SuppressWarnings("unchecked")
- public static Object[] parse(byte[] robotsTxt) throws IOException {
- if ((robotsTxt == null)||(robotsTxt.length == 0)) return new Object[]{new ArrayList(0),null,null};
- ByteArrayInputStream bin = new ByteArrayInputStream(robotsTxt);
- BufferedReader reader = new BufferedReader(new InputStreamReader(bin));
- return parse(reader);
- }
-
- public static Object[] parse(BufferedReader reader) throws IOException{
- ArrayList<String> deny4AllAgents = new ArrayList<String>();
- ArrayList<String> deny4YaCyAgent = new ArrayList<String>();
-
- int pos;
- String line = null, lineUpper = null, sitemap = null;
- Integer crawlDelay = null;
- boolean isRuleBlock4AllAgents = false,
- isRuleBlock4YaCyAgent = false,
- rule4YaCyFound = false,
- inBlock = false;
-
- while ((line = reader.readLine()) != null) {
- line = line.trim();
- lineUpper = line.toUpperCase();
-
- if (line.length() == 0) {
- // OLD: we have reached the end of the rule block
- // rule4Yacy = false; inBlock = false;
-
- // NEW: just ignore it
- } else if (line.startsWith(ROBOTS_COMMENT)) {
- // we can ignore this. Just a comment line
- } else if (lineUpper.startsWith(ROBOTS_SITEMAP)) {
- pos = line.indexOf(" ");
- if (pos != -1) {
- sitemap = line.substring(pos).trim();
- }
- } else if (lineUpper.startsWith(ROBOTS_USER_AGENT)) {
-
- if (inBlock) {
- // we have detected the start of a new block
- inBlock = false;
- isRuleBlock4AllAgents = false;
- isRuleBlock4YaCyAgent = false;
- crawlDelay = null; // each block has a separate delay
- }
-
- // cutting off comments at the line end
- pos = line.indexOf(ROBOTS_COMMENT);
- if (pos != -1) line = line.substring(0,pos).trim();
-
- // replacing all tabs with spaces
- line = line.replaceAll("\t"," ");
-
- // getting out the robots name
- pos = line.indexOf(" ");
- if (pos != -1) {
- String userAgent = line.substring(pos).trim();
- isRuleBlock4AllAgents |= userAgent.equals("*");
- isRuleBlock4YaCyAgent |= userAgent.toLowerCase().indexOf("yacy") >=0;
- if (isRuleBlock4YaCyAgent) rule4YaCyFound = true;
- }
- } else if (lineUpper.startsWith(ROBOTS_CRAWL_DELAY)) {
- pos = line.indexOf(" ");
- if (pos != -1) {
- try {
- crawlDelay = Integer.valueOf(line.substring(pos).trim());
- } catch (NumberFormatException e) {
- // invalid crawling delay
- }
- }
- } else if (lineUpper.startsWith(ROBOTS_DISALLOW) ||
- lineUpper.startsWith(ROBOTS_ALLOW)) {
- inBlock = true;
- boolean isDisallowRule = lineUpper.startsWith(ROBOTS_DISALLOW);
-
- if (isRuleBlock4YaCyAgent || isRuleBlock4AllAgents) {
- // cutting off comments at the line end
- pos = line.indexOf(ROBOTS_COMMENT);
- if (pos != -1) line = line.substring(0,pos).trim();
-
- // cutting of tailing *
- if (line.endsWith("*")) line = line.substring(0,line.length()-1);
-
- // replacing all tabs with spaces
- line = line.replaceAll("\t"," ");
-
- // getting the path
- pos = line.indexOf(" ");
- if (pos != -1) {
- // getting the path
- String path = line.substring(pos).trim();
-
- // unencoding all special charsx
- try {
- path = URLDecoder.decode(path,"UTF-8");
- } catch (Exception e) {
- /*
- * url decoding failed. E.g. because of
- * "Incomplete trailing escape (%) pattern"
- */
- }
-
- // escaping all occurences of ; because this char is used as special char in the Robots DB
- path = path.replaceAll(RobotsTxt.ROBOTS_DB_PATH_SEPARATOR,"%3B");
-
- // adding it to the pathlist
- if (!isDisallowRule) path = "!" + path;
- if (isRuleBlock4AllAgents) deny4AllAgents.add(path);
- if (isRuleBlock4YaCyAgent) deny4YaCyAgent.add(path);
- }
- }
- }
- }
-
- ArrayList<String> denyList = (rule4YaCyFound) ? deny4YaCyAgent : deny4AllAgents;
- return new Object[]{denyList,sitemap,crawlDelay};
- }
-
- private static final int getPort(yacyURL theURL) {
- int port = theURL.getPort();
- if (port == -1) {
- if (theURL.getProtocol().equalsIgnoreCase("http")) {
- port = 80;
- } else if (theURL.getProtocol().equalsIgnoreCase("https")) {
- port = 443;
- }
-
- }
- return port;
- }
-
- private static final String getHostPort(yacyURL theURL) {
- String urlHostPort = null;
- int port = getPort(theURL);
- urlHostPort = theURL.getHost() + ":" + port;
- urlHostPort = urlHostPort.toLowerCase().intern();
-
- return urlHostPort;
- }
-
- public static yacyURL getSitemapURL(yacyURL theURL) {
- if (theURL == null) throw new IllegalArgumentException();
- yacyURL sitemapURL = null;
-
- // generating the hostname:poart string needed to do a DB lookup
- String urlHostPort = getHostPort(theURL);
-
- RobotsTxt.Entry robotsTxt4Host = null;
- synchronized(urlHostPort) {
- // doing a DB lookup to determine if the robots data is already available
- robotsTxt4Host = plasmaSwitchboard.robots.getEntry(urlHostPort);
- }
- if (robotsTxt4Host == null) return null;
-
- try {
- String sitemapUrlStr = robotsTxt4Host.getSitemap();
- if (sitemapUrlStr != null) sitemapURL = new yacyURL(sitemapUrlStr, null);
- } catch (MalformedURLException e) {/* ignore this */}
-
- return sitemapURL;
- }
-
- public static Integer getCrawlDelay(yacyURL theURL) {
- if (theURL == null) throw new IllegalArgumentException();
- Integer crawlDelay = null;
-
- // generating the hostname:poart string needed to do a DB lookup
- String urlHostPort = getHostPort(theURL);
-
- RobotsTxt.Entry robotsTxt4Host = null;
- synchronized(urlHostPort) {
- // doing a DB lookup to determine if the robots data is already available
- robotsTxt4Host = plasmaSwitchboard.robots.getEntry(urlHostPort);
- }
- if (robotsTxt4Host == null) return null;
-
- try {
- crawlDelay = robotsTxt4Host.getCrawlDelay();
- } catch (NumberFormatException e) {/* ignore this */}
-
- return crawlDelay;
- }
-
- @SuppressWarnings("unchecked")
- public static boolean isDisallowed(yacyURL nexturl) {
- if (nexturl == null) throw new IllegalArgumentException();
-
- // generating the hostname:poart string needed to do a DB lookup
- String urlHostPort = getHostPort(nexturl);
-
- RobotsTxt.Entry robotsTxt4Host = null;
- synchronized(urlHostPort) {
- // doing a DB lookup to determine if the robots data is already available
- robotsTxt4Host = plasmaSwitchboard.robots.getEntry(urlHostPort);
-
- // if we have not found any data or the data is older than 7 days, we need to load it from the remote server
- if (
- (robotsTxt4Host == null) ||
- (robotsTxt4Host.getLoadedDate() == null) ||
- (System.currentTimeMillis() - robotsTxt4Host.getLoadedDate().getTime() > 7*24*60*60*1000)
- ) {
- yacyURL robotsURL = null;
- // generating the proper url to download the robots txt
- try {
- robotsURL = new yacyURL(nexturl.getProtocol(),nexturl.getHost(),getPort(nexturl),"/robots.txt");
- } catch (MalformedURLException e) {
- serverLog.logSevere("ROBOTS","Unable to generate robots.txt URL for URL '" + nexturl.toString() + "'.");
- return false;
- }
-
- Object[] result = null;
- boolean accessCompletelyRestricted = false;
- byte[] robotsTxt = null;
- String eTag = null;
- Date modDate = null;
- try {
- serverLog.logFine("ROBOTS","Trying to download the robots.txt file from URL '" + robotsURL + "'.");
- result = downloadRobotsTxt(robotsURL,5,robotsTxt4Host);
-
- if (result != null) {
- accessCompletelyRestricted = ((Boolean)result[DOWNLOAD_ACCESS_RESTRICTED]).booleanValue();
- robotsTxt = (byte[])result[DOWNLOAD_ROBOTS_TXT];
- eTag = (String) result[DOWNLOAD_ETAG];
- modDate = (Date) result[DOWNLOAD_MODDATE];
- } else if (robotsTxt4Host != null) {
- robotsTxt4Host.setLoadedDate(new Date());
- plasmaSwitchboard.robots.addEntry(robotsTxt4Host);
- }
- } catch (Exception e) {
- serverLog.logSevere("ROBOTS","Unable to download the robots.txt file from URL '" + robotsURL + "'. " + e.getMessage());
- }
-
- if ((robotsTxt4Host==null)||((robotsTxt4Host!=null)&&(result!=null))) {
- ArrayList<String> denyPath = null;
- String sitemap = null;
- Integer crawlDelay = null;
- if (accessCompletelyRestricted) {
- denyPath = new ArrayList<String>();
- denyPath.add("/");
- } else {
- // parsing the robots.txt Data and converting it into an arraylist
- try {
- Object[] parserResult = robotsParser.parse(robotsTxt);
- denyPath = (ArrayList<String>) parserResult[0];
- sitemap = (String) parserResult[1];
- crawlDelay = (Integer) parserResult[2];
- } catch (IOException e) {
- serverLog.logSevere("ROBOTS","Unable to parse the robots.txt file from URL '" + robotsURL + "'.");
- }
- }
-
- // storing the data into the robots DB
- robotsTxt4Host = plasmaSwitchboard.robots.addEntry(urlHostPort,denyPath,new Date(),modDate,eTag,sitemap,crawlDelay);
- }
- }
- }
-
- if (robotsTxt4Host != null && robotsTxt4Host.isDisallowed(nexturl.getFile())) {
- return true;
- }
- return false;
- }
-
- static Object[] downloadRobotsTxt(yacyURL robotsURL, int redirectionCount, RobotsTxt.Entry entry) throws Exception {
-
- if (redirectionCount < 0) return new Object[]{Boolean.FALSE,null,null};
- redirectionCount--;
-
- boolean accessCompletelyRestricted = false;
- byte[] robotsTxt = null;
- long downloadStart, downloadEnd;
- String eTag=null, oldEtag = null;
- Date lastMod=null;
- downloadStart = System.currentTimeMillis();
-
- // if we previously have downloaded this robots.txt then we can set the if-modified-since header
- httpHeader reqHeaders = new httpHeader();
-
- // add yacybot user agent
- reqHeaders.put(httpHeader.USER_AGENT, HTTPLoader.crawlerUserAgent);
-
- // adding referer
- reqHeaders.put(httpHeader.REFERER, (yacyURL.newURL(robotsURL,"/")).toNormalform(true, true));
-
- if (entry != null) {
- oldEtag = entry.getETag();
- reqHeaders = new httpHeader();
- Date modDate = entry.getModDate();
- if (modDate != null) reqHeaders.put(httpHeader.IF_MODIFIED_SINCE,HttpClient.dateString(entry.getModDate()));
-
- }
-
- // setup http-client
- //TODO: adding Traffic statistic for robots download?
- JakartaCommonsHttpClient client = new JakartaCommonsHttpClient(10000, reqHeaders, null);
- JakartaCommonsHttpResponse res = null;
- try {
- // sending the get request
- res = client.GET(robotsURL.toString());
-
- // check for interruption
- if (Thread.currentThread().isInterrupted()) throw new InterruptedException("Shutdown in progress.");
-
- // check the response status
- if (res.getStatusLine().startsWith("2")) {
- if (!res.getResponseHeader().mime().startsWith("text/plain")) {
- robotsTxt = null;
- serverLog.logFinest("ROBOTS","Robots.txt from URL '" + robotsURL + "' has wrong mimetype '" + res.getResponseHeader().mime() + "'.");
- } else {
-
- // getting some metadata
- eTag = res.getResponseHeader().containsKey(httpHeader.ETAG)?(res.getResponseHeader().get(httpHeader.ETAG)).trim():null;
- lastMod = res.getResponseHeader().lastModified();
-
- // if the robots.txt file was not changed we break here
- if ((eTag != null) && (oldEtag != null) && (eTag.equals(oldEtag))) {
- serverLog.logFinest("ROBOTS","Robots.txt from URL '" + robotsURL + "' was not modified. Abort downloading of new version.");
- return null;
- }
-
- // downloading the content
- serverByteBuffer sbb = new serverByteBuffer();
- try {
- serverFileUtils.copyToStream(new BufferedInputStream(res.getDataAsStream()), new BufferedOutputStream(sbb));
- } finally {
- res.closeStream();
- }
- robotsTxt = sbb.getBytes();
-
- downloadEnd = System.currentTimeMillis();
- serverLog.logFinest("ROBOTS","Robots.txt successfully loaded from URL '" + robotsURL + "' in " + (downloadEnd-downloadStart) + " ms.");
- }
- } else if (res.getStatusCode() == 304) {
- return null;
- } else if (res.getStatusLine().startsWith("3")) {
- // getting redirection URL
- String redirectionUrlString = res.getResponseHeader().get(httpHeader.LOCATION);
- if (redirectionUrlString==null) {
- serverLog.logFinest("ROBOTS","robots.txt could not be downloaded from URL '" + robotsURL + "' because of missing redirecton header. [" + res.getStatusLine() + "].");
- robotsTxt = null;
- } else {
-
- redirectionUrlString = redirectionUrlString.trim();
-
- // generating the new URL object
- yacyURL redirectionUrl = yacyURL.newURL(robotsURL, redirectionUrlString);
-
- // following the redirection
- serverLog.logFinest("ROBOTS","Redirection detected for robots.txt with URL '" + robotsURL + "'." +
- "\nRedirecting request to: " + redirectionUrl);
- return downloadRobotsTxt(redirectionUrl,redirectionCount,entry);
- }
- } else if (res.getStatusCode() == 401 || res.getStatusCode() == 403) {
- accessCompletelyRestricted = true;
- serverLog.logFinest("ROBOTS","Access to Robots.txt not allowed on URL '" + robotsURL + "'.");
- } else {
- serverLog.logFinest("ROBOTS","robots.txt could not be downloaded from URL '" + robotsURL + "'. [" + res.getStatusLine() + "].");
- robotsTxt = null;
- }
- } catch (Exception e) {
- throw e;
- } finally {
- if(res != null) {
- // release connection
- res.closeStream();
- }
- }
- return new Object[]{new Boolean(accessCompletelyRestricted),robotsTxt,eTag,lastMod};
- }
-}
diff --git a/source/de/anomic/index/indexContainer.java b/source/de/anomic/index/indexContainer.java
index 8108c814b..c2e898451 100644
--- a/source/de/anomic/index/indexContainer.java
+++ b/source/de/anomic/index/indexContainer.java
@@ -155,7 +155,7 @@ public class indexContainer extends kelondroRowSet {
}
public indexRWIEntry remove(String urlHash) {
- kelondroRow.Entry entry = remove(urlHash.getBytes(), true);
+ kelondroRow.Entry entry = remove(urlHash.getBytes());
if (entry == null) return null;
return new indexRWIRowEntry(entry);
}
@@ -408,7 +408,7 @@ public class indexContainer extends kelondroRowSet {
if ((ie0 != null) && (ie1 != null)) {
assert (ie0.urlHash().length() == keylength) : "ie0.urlHash() = " + ie0.urlHash();
assert (ie1.urlHash().length() == keylength) : "ie1.urlHash() = " + ie1.urlHash();
- if (iterate_pivot) se.remove(); pivot.remove(ie0.urlHash().getBytes(), true);
+ if (iterate_pivot) se.remove(); pivot.remove(ie0.urlHash().getBytes());
}
}
return pivot;
diff --git a/source/de/anomic/index/indexRepositoryReference.java b/source/de/anomic/index/indexRepositoryReference.java
index 2b56e0dbf..a62b92dcc 100644
--- a/source/de/anomic/index/indexRepositoryReference.java
+++ b/source/de/anomic/index/indexRepositoryReference.java
@@ -142,7 +142,7 @@ public final class indexRepositoryReference {
public synchronized boolean remove(String urlHash) {
if (urlHash == null) return false;
try {
- kelondroRow.Entry r = urlIndexFile.remove(urlHash.getBytes(), false);
+ kelondroRow.Entry r = urlIndexFile.remove(urlHash.getBytes());
return r != null;
} catch (IOException e) {
return false;
diff --git a/source/de/anomic/kelondro/kelondroBLOBTree.java b/source/de/anomic/kelondro/kelondroBLOBTree.java
index 396d51aa7..2eeed50fb 100644
--- a/source/de/anomic/kelondro/kelondroBLOBTree.java
+++ b/source/de/anomic/kelondro/kelondroBLOBTree.java
@@ -324,7 +324,7 @@ public class kelondroBLOBTree implements kelondroBLOB {
int recpos = 0;
byte[] k;
while (index.get(k = elementKey(key, recpos)) != null) {
- index.remove(k, false);
+ index.remove(k);
buffer.remove(k);
recpos++;
}
diff --git a/source/de/anomic/kelondro/kelondroBytesIntMap.java b/source/de/anomic/kelondro/kelondroBytesIntMap.java
index 4ecaf260d..eea9c8961 100644
--- a/source/de/anomic/kelondro/kelondroBytesIntMap.java
+++ b/source/de/anomic/kelondro/kelondroBytesIntMap.java
@@ -103,7 +103,7 @@ public class kelondroBytesIntMap {
public synchronized int removei(byte[] key) throws IOException {
assert (key != null);
- kelondroRow.Entry indexentry = index.remove(key, true); // keeping the order will prevent multiple re-sorts
+ kelondroRow.Entry indexentry = index.remove(key);
if (indexentry == null) return -1;
return (int) indexentry.getColLong(1);
}
diff --git a/source/de/anomic/kelondro/kelondroBytesLongMap.java b/source/de/anomic/kelondro/kelondroBytesLongMap.java
index 4b671ec2e..eafda567d 100644
--- a/source/de/anomic/kelondro/kelondroBytesLongMap.java
+++ b/source/de/anomic/kelondro/kelondroBytesLongMap.java
@@ -100,7 +100,7 @@ public class kelondroBytesLongMap {
public synchronized long removel(byte[] key) throws IOException {
assert (key != null);
- kelondroRow.Entry indexentry = index.remove(key, true); // keeping the order will prevent multiple re-sorts
+ kelondroRow.Entry indexentry = index.remove(key);
if (indexentry == null) return -1;
return indexentry.getColLong(1);
}
diff --git a/source/de/anomic/kelondro/kelondroCache.java b/source/de/anomic/kelondro/kelondroCache.java
index 6b2ef94fb..50063590b 100644
--- a/source/de/anomic/kelondro/kelondroCache.java
+++ b/source/de/anomic/kelondro/kelondroCache.java
@@ -276,7 +276,7 @@ public class kelondroCache implements kelondroIndex {
// remove entry from miss- and hit-cache
if (readMissCache != null) {
- if (readMissCache.remove(key, true) != null) {
+ if (readMissCache.remove(key) != null) {
this.hasnotHit++;
// the entry does not exist before
index.put(row); // write to backend
@@ -328,7 +328,7 @@ public class kelondroCache implements kelondroIndex {
// remove entry from miss- and hit-cache
if (readMissCache != null) {
- this.readMissCache.remove(key, true);
+ this.readMissCache.remove(key);
this.hasnotDelete++;
// the entry does not exist before
boolean added = index.addUnique(row); // write to backend
@@ -362,7 +362,7 @@ public class kelondroCache implements kelondroIndex {
// remove entry from miss- and hit-cache
if (readMissCache != null) {
- this.readMissCache.remove(key, true);
+ this.readMissCache.remove(key);
this.hasnotDelete++;
}
@@ -388,7 +388,7 @@ public class kelondroCache implements kelondroIndex {
// todo: remove reported entries from the cache!!!
}
- public synchronized Entry remove(byte[] key, boolean keepOrder) throws IOException {
+ public synchronized Entry remove(byte[] key) throws IOException {
checkMissSpace();
// add entry to miss-cache
@@ -405,7 +405,7 @@ public class kelondroCache implements kelondroIndex {
// remove entry from hit-cache
if (readHitCache != null) {
- Entry entry = readHitCache.remove(key, true);
+ Entry entry = readHitCache.remove(key);
if (entry == null) {
this.readMiss++;
} else {
@@ -414,7 +414,7 @@ public class kelondroCache implements kelondroIndex {
}
}
- return index.remove(key, false);
+ return index.remove(key);
}
public synchronized Entry removeOne() throws IOException {
@@ -429,7 +429,7 @@ public class kelondroCache implements kelondroIndex {
if (dummy == null) this.hasnotUnique++; else this.hasnotDouble++;
}
if (readHitCache != null) {
- kelondroRow.Entry dummy = readHitCache.remove(key, true);
+ kelondroRow.Entry dummy = readHitCache.remove(key);
if (dummy != null) this.cacheDelete++;
}
return entry;
diff --git a/source/de/anomic/kelondro/kelondroCollectionIndex.java b/source/de/anomic/kelondro/kelondroCollectionIndex.java
index 3566b3383..ca7e3512b 100644
--- a/source/de/anomic/kelondro/kelondroCollectionIndex.java
+++ b/source/de/anomic/kelondro/kelondroCollectionIndex.java
@@ -664,7 +664,7 @@ public class kelondroCollectionIndex {
// remove the keys from the set
Iterator<String> i = removekeys.iterator();
while (i.hasNext()) {
- if (oldcollection.remove(i.next().getBytes(), false) != null) removed++;
+ if (oldcollection.remove(i.next().getBytes()) != null) removed++;
}
oldcollection.sort();
oldcollection.trim(false);
@@ -674,7 +674,7 @@ public class kelondroCollectionIndex {
array_remove(
oldPartitionNumber, serialNumber, this.payloadrow.objectsize,
oldrownumber);
- index.remove(key, false);
+ index.remove(key);
return removed;
}
@@ -719,7 +719,7 @@ public class kelondroCollectionIndex {
public synchronized kelondroRowSet delete(byte[] key) throws IOException {
// find an entry, if one exists
- kelondroRow.Entry indexrow = index.remove(key, false);
+ kelondroRow.Entry indexrow = index.remove(key);
if (indexrow == null) return null;
kelondroRowSet removedCollection = getdelete(indexrow, true);
assert (removedCollection != null);
@@ -751,7 +751,7 @@ public class kelondroCollectionIndex {
byte[] arraykey = arrayrow.getColBytes(0);
if (!(index.row().objectOrder.wellformed(arraykey))) {
// cleanup for a bad bug that corrupted the database
- index.remove(indexkey, false); // the RowCollection must be considered lost
+ index.remove(indexkey); // the RowCollection must be considered lost
array.remove(rownumber); // loose the RowCollection (we don't know how much is lost)
serverLog.logSevere("kelondroCollectionIndex." + array.filename, "lost a RowCollection because of a bad arraykey");
return new kelondroRowSet(this.payloadrow, 0);
@@ -759,7 +759,7 @@ public class kelondroCollectionIndex {
kelondroRowSet collection = new kelondroRowSet(this.payloadrow, arrayrow, 1); // FIXME: this does not yet work with different rowdef in case of several rowdef.objectsize()
if ((!(index.row().objectOrder.wellformed(indexkey))) || (index.row().objectOrder.compare(arraykey, indexkey) != 0)) {
// check if we got the right row; this row is wrong. Fix it:
- index.remove(indexkey, false); // the wrong row cannot be fixed
+ index.remove(indexkey); // the wrong row cannot be fixed
// store the row number in the index; this may be a double-entry, but better than nothing
kelondroRow.Entry indexEntry = index.row().newEntry();
indexEntry.setCol(idx_col_key, arrayrow.getColBytes(0));
diff --git a/source/de/anomic/kelondro/kelondroEcoTable.java b/source/de/anomic/kelondro/kelondroEcoTable.java
index bea6779ff..4dcf369c0 100644
--- a/source/de/anomic/kelondro/kelondroEcoTable.java
+++ b/source/de/anomic/kelondro/kelondroEcoTable.java
@@ -462,10 +462,9 @@ public class kelondroEcoTable implements kelondroIndex {
}
}
- public synchronized Entry remove(byte[] key, boolean keepOrder) throws IOException {
+ public synchronized Entry remove(byte[] key) throws IOException {
assert file.size() == index.size() + fail : "file.size() = " + file.size() + ", index.size() = " + index.size();
assert ((table == null) || (table.size() == index.size()));
- assert keepOrder == false; // this class cannot keep the order during a remove
assert key.length == rowdef.primaryKeyLength;
int i = index.geti(key);
if (i == -1) return null; // nothing to do
@@ -679,7 +678,7 @@ public class kelondroEcoTable implements kelondroIndex {
tt = testTable(testFile, s[i], testcase);
// delete by permutation j
for (int elt = 0; elt < s[j].length(); elt++) {
- tt.remove(kelondroTree.testWord(s[j].charAt(elt)), false);
+ tt.remove(kelondroTree.testWord(s[j].charAt(elt)));
if (kelondroTree.countElements(tt) != tt.size()) {
System.out.println("ERROR! wrong size for probe tree " + s[i] + "; probe delete " + s[j] + "; position " + elt);
}
diff --git a/source/de/anomic/kelondro/kelondroFlexTable.java b/source/de/anomic/kelondro/kelondroFlexTable.java
index 53ad9d18e..549e0acb5 100644
--- a/source/de/anomic/kelondro/kelondroFlexTable.java
+++ b/source/de/anomic/kelondro/kelondroFlexTable.java
@@ -343,8 +343,8 @@ public class kelondroFlexTable extends kelondroFlexWidthArray implements kelondr
return report;
}
- public synchronized kelondroRow.Entry remove(byte[] key, boolean keepOrder) throws IOException {
- assert keepOrder == false; // the underlying data structure is a file, where the order cannot be maintained. Gaps are filled with new values.
+ public synchronized kelondroRow.Entry remove(byte[] key) throws IOException {
+ // the underlying data structure is a file, where the order cannot be maintained. Gaps are filled with new values.
int i = index.removei(key);
assert (index.geti(key) < 0); // must be deleted
if (i < 0) {
diff --git a/source/de/anomic/kelondro/kelondroIndex.java b/source/de/anomic/kelondro/kelondroIndex.java
index 2c04d975f..fe70efda4 100644
--- a/source/de/anomic/kelondro/kelondroIndex.java
+++ b/source/de/anomic/kelondro/kelondroIndex.java
@@ -69,7 +69,7 @@ public interface kelondroIndex {
public boolean addUnique(kelondroRow.Entry row) throws IOException; // no double-check
public int addUniqueMultiple(List<kelondroRow.Entry> rows) throws IOException; // no double-check
public ArrayList<kelondroRowCollection> removeDoubles() throws IOException; // removes all elements that are double (to be used after all addUnique)
- public kelondroRow.Entry remove(byte[] key, boolean keepOrder) throws IOException;
+ public kelondroRow.Entry remove(byte[] key) throws IOException;
public kelondroRow.Entry removeOne() throws IOException;
public kelondroCloneableIterator<byte[]> keys(boolean up, byte[] firstKey) throws IOException; // iterates only the key
public kelondroCloneableIterator<kelondroRow.Entry> rows(boolean up, byte[] firstKey) throws IOException; // iterates the whole row
diff --git a/source/de/anomic/kelondro/kelondroIntBytesMap.java b/source/de/anomic/kelondro/kelondroIntBytesMap.java
index e6eb5ebf7..d12e90106 100644
--- a/source/de/anomic/kelondro/kelondroIntBytesMap.java
+++ b/source/de/anomic/kelondro/kelondroIntBytesMap.java
@@ -132,7 +132,7 @@ public class kelondroIntBytesMap {
index0.uniq();
index1 = new kelondroRowSet(rowdef, 0);
}
- kelondroRow.Entry indexentry = index0.remove(key, true);
+ kelondroRow.Entry indexentry = index0.remove(key);
if (indexentry != null) {
return indexentry.getColBytes(1);
}
@@ -141,7 +141,7 @@ public class kelondroIntBytesMap {
// at this point index1 cannot be null
assert (index1 != null);
if (index1.size() == 0) return null;
- kelondroRow.Entry indexentry = index1.remove(key, true);
+ kelondroRow.Entry indexentry = index1.remove(key);
if (indexentry == null) return null;
return indexentry.getColBytes(1);
}
diff --git a/source/de/anomic/kelondro/kelondroMapTable.java b/source/de/anomic/kelondro/kelondroMapTable.java
deleted file mode 100644
index 752e6ebd4..000000000
--- a/source/de/anomic/kelondro/kelondroMapTable.java
+++ /dev/null
@@ -1,192 +0,0 @@
-// kelondroapTable.java
-// -----------------------
-// (C) by Michael Peter Christen; [email protected]
-// first published on http://www.anomic.de
-// Frankfurt, Germany, 2005
-// last major change: 13.03.2005
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-//
-// Using this software in any meaning (reading, learning, copying, compiling,
-// running) means that you agree that the Author(s) is (are) not responsible
-// for cost, loss of data or any harm that may be caused directly or indirectly
-// by usage of this softare or this documentation. The usage of this software
-// is on your own risk. The installation and usage (starting/running) of this
-// software may allow other people or application to access your computer and
-// any attached devices and is highly dependent on the configuration of the
-// software which must be done by the user of the software; the author(s) is
-// (are) also not responsible for proper configuration and usage of the
-// software, even if provoked by documentation provided together with
-// the software.
-//
-// Any changes to this file according to the GPL as documented in the file
-// gpl.txt aside this file in the shipment you received can be done to the
-// lines that follows this copyright notice here, but changes must not be
-// done inside the copyright notive above. A re-distribution must contain
-// the intact and unchanged copyright notice.
-// Contributions and changes to the program code must be marked as such.
-
-
-// this is mainly a convenience class to bundle many kelondroMap Objects
-
-package de.anomic.kelondro;
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-public class kelondroMapTable {
-
- private HashMap<String, kelondroMapObjects> mTables;
- private HashMap<String, kelondroIndex> tTables;
- //private HashMap sTables;
- private File tablesPath;
-
- public kelondroMapTable(File tablesPath) {
- this.mTables = new HashMap<String, kelondroMapObjects>();
- this.tTables = new HashMap<String, kelondroIndex>();
- //this.sTables = new HashMap();
- this.tablesPath = tablesPath;
- if (!(tablesPath.exists())) tablesPath.mkdirs();
- }
-
- public void declareMaps(
- String tablename, int keysize, kelondroByteOrder objectOrder, int nodesize, int cacheslots,
- char fillChar, boolean resetOnFail) {
- declareMaps(tablename, keysize, objectOrder, nodesize, cacheslots, null, null, null, fillChar, resetOnFail);
- }
-
- public void declareMaps(
- String tablename, int keysize, kelondroByteOrder objectOrder, int nodesize, int cacheslots,
- String[] sortfields, String[] longaccfields, String[] doubleaccfields, char fillChar,
- boolean resetOnFail) {
- if (mTables.containsKey(tablename)) throw new RuntimeException("kelondroTables.declareMap: table '" + tablename + "' declared twice.");
- if (tTables.containsKey(tablename)) throw new RuntimeException("kelondroTables.declareMap: table '" + tablename + "' declared already in other context.");
- File tablefile = new File(tablesPath, "table." + tablename + ".mdb");
- kelondroBLOBTree dyn;
- if (!(tablefile.exists())) tablefile.getParentFile().mkdirs();
- dyn = new kelondroBLOBTree(tablefile, true, true, keysize, nodesize, fillChar, objectOrder, true, false, resetOnFail);
- kelondroMapObjects map = new kelondroMapObjects(dyn, cacheslots, sortfields, longaccfields, doubleaccfields, null, null);
- mTables.put(tablename, map);
- }
-
- public void declareTree(String tablename, kelondroRow rowdef, long buffersize /*bytes*/, long preloadTime) {
- if (mTables.containsKey(tablename)) throw new RuntimeException("kelondroTables.declareTree: table '" + tablename + "' declared already in other context.");
- if (tTables.containsKey(tablename)) throw new RuntimeException("kelondroTables.declareTree: table '" + tablename + "' declared twice.");
- File tablefile = new File(tablesPath, "table." + tablename + ".tdb");
- kelondroIndex Tree = new kelondroCache(kelondroTree.open(tablefile, true, preloadTime, rowdef));
- tTables.put(tablename, Tree);
- }
-
- public synchronized void update(String tablename, String key, HashMap<String, String> map) throws IOException {
- kelondroMapObjects table = mTables.get(tablename);
- if (table == null) throw new RuntimeException("kelondroTables.update: map table '" + tablename + "' does not exist.");
- if (key.length() > table.keySize()) key = key.substring(0, table.keySize());
- table.set(key, map);
- mTables.put(tablename, table);
- }
-
- public synchronized void update(String tablename, kelondroRow.Entry row /* first element is the unique key = index */) throws IOException {
- kelondroIndex tree = tTables.get(tablename);
- if (tree == null) throw new RuntimeException("kelondroTables.update: tree table '" + tablename + "' does not exist.");
- tree.put(row);
- tTables.put(tablename, tree);
- }
-
- public synchronized Map<String, String> selectMap(String tablename, String key) {
- kelondroMapObjects table = mTables.get(tablename);
- if (table == null) throw new RuntimeException("kelondroTables.selectMap: map table '" + tablename + "' does not exist.");
- if (key.length() > table.keySize()) key = key.substring(0, table.keySize());
- return table.getMap(key);
- }
-
- public synchronized kelondroRow.Entry selectByte(String tablename, String key) throws IOException {
- kelondroIndex tree = tTables.get(tablename);
- if (tree == null) throw new RuntimeException("kelondroTables.selectByte: tree table '" + tablename + "' does not exist.");
- return tree.get(key.getBytes());
- }
-
- public synchronized kelondroMapObjects.mapIterator /* of Map-Elements */ maps(String tablename, boolean up, boolean rotating) throws IOException {
- kelondroMapObjects table = mTables.get(tablename);
- if (table == null) throw new RuntimeException("kelondroTables.maps: map table '" + tablename + "' does not exist.");
- return table.maps(up, rotating);
- }
-
- public synchronized kelondroMapObjects.mapIterator /* of Map-Elements */ maps(String tablename, boolean up, boolean rotating, byte[] firstKey, byte[] secondKey) throws IOException {
- kelondroMapObjects table = mTables.get(tablename);
- if (table == null) throw new RuntimeException("kelondroTables.maps: map table '" + tablename + "' does not exist.");
- return table.maps(up, rotating, firstKey, secondKey);
- }
-
- public synchronized kelondroMapObjects.mapIterator /* of Map-Elements */ maps(String tablename, boolean up, String field) {
- kelondroMapObjects table = mTables.get(tablename);
- if (table == null) throw new RuntimeException("kelondroTables.maps: map table '" + tablename + "' does not exist.");
- return table.maps(up, field);
- }
-
- public synchronized kelondroCloneableIterator<kelondroRow.Entry> /* of kelondroRow.Entry-Elements */ rows(String tablename, boolean up, boolean rotating, byte[] firstKey, byte[] secondKey) throws IOException {
- kelondroIndex tree = tTables.get(tablename);
- if (tree == null) throw new RuntimeException("kelondroTables.bytes: tree table '" + tablename + "' does not exist.");
- kelondroCloneableIterator<kelondroRow.Entry> i = tree.rows(up, firstKey);
- if (rotating) return new kelondroRotateIterator<kelondroRow.Entry>(i, secondKey, tree.size()); else return i;
- }
-
- // if you need the long-values from a row-iteration, please use kelondroRecords.bytes2long to convert from byte[] to long
-
- public synchronized void delete(String tablename, String key) throws IOException {
- kelondroMapObjects table = mTables.get(tablename);
- if (key.length() > table.keySize()) key = key.substring(0, table.keySize());
- if (table != null) {table.remove(key); mTables.put(tablename, table); return;}
-
- kelondroIndex Tree = tTables.get(tablename);
- if (Tree != null) {Tree.remove(key.getBytes(), false); tTables.put(tablename, Tree); return;}
-
- throw new RuntimeException("kelondroTables.delete: table '" + tablename + "' does not exist.");
- }
-
- public synchronized long longAccumulator(String tablename, String field) {
- kelondroMapObjects table = mTables.get(tablename);
- if (table == null) throw new RuntimeException("kelondroTables.accumulator: map table '" + tablename + "' does not exist.");
- return table.getLongAcc(field);
- }
-
- public synchronized double doubleAccumulator(String tablename, String field) {
- kelondroMapObjects table = mTables.get(tablename);
- if (table == null) throw new RuntimeException("kelondroTables.accumulator: map table '" + tablename + "' does not exist.");
- return table.getDoubleAcc(field);
- }
-
- public synchronized int size(String tablename) {
- kelondroMapObjects table = mTables.get(tablename);
- if (table != null) return table.size();
-
- kelondroIndex Tree = tTables.get(tablename);
- if (Tree != null) return Tree.size();
-
- throw new RuntimeException("kelondroTables.accumulator: table '" + tablename + "' does not exist.");
- }
-
- public void close() {
- Iterator<kelondroMapObjects> tablesIt = mTables.values().iterator();
- while (tablesIt.hasNext()) (tablesIt.next()).close();
- mTables = null;
-
- Iterator<kelondroIndex> TreeIt = tTables.values().iterator();
- while (TreeIt.hasNext()) (TreeIt.next()).close();
- tTables = null;
- }
-
-}
diff --git a/source/de/anomic/kelondro/kelondroRAMIndex.java b/source/de/anomic/kelondro/kelondroRAMIndex.java
index ca1cb5e48..d5c0741ee 100644
--- a/source/de/anomic/kelondro/kelondroRAMIndex.java
+++ b/source/de/anomic/kelondro/kelondroRAMIndex.java
@@ -131,17 +131,16 @@ public class kelondroRAMIndex implements kelondroIndex {
return index0.removeDoubles();
}
- public synchronized kelondroRow.Entry remove(byte[] key, boolean keepOrder) {
- assert keepOrder == true; // if this is false, the index must be re-ordered so many times which will cause a major CPU usage
- finishInitialization();
+ public synchronized kelondroRow.Entry remove(byte[] key) {
+ finishInitialization();
// if the new entry is within the initialization part, just delete it
- kelondroRow.Entry indexentry = index0.remove(key, keepOrder);
+ kelondroRow.Entry indexentry = index0.remove(key);
if (indexentry != null) {
assert index0.get(key) == null; // check if remove worked
return indexentry;
}
// else remove it from the index1
- kelondroRow.Entry removed = index1.remove(key, keepOrder);
+ kelondroRow.Entry removed = index1.remove(key);
assert index1.get(key) == null : "removed " + ((removed == null) ? " is null" : " is not null") + ", and index entry still exists"; // check if remove worked
return removed;
}
diff --git a/source/de/anomic/kelondro/kelondroRelations.java b/source/de/anomic/kelondro/kelondroRelations.java
index 421e88e6d..afe8edc81 100755
--- a/source/de/anomic/kelondro/kelondroRelations.java
+++ b/source/de/anomic/kelondro/kelondroRelations.java
@@ -148,7 +148,7 @@ public class kelondroRelations {
public byte[] removeRelation(String name, byte[] key) throws IOException {
kelondroIndex table = getRelation(name);
if (table == null) return null;
- kelondroRow.Entry entry = table.remove(key, false);
+ kelondroRow.Entry entry = table.remove(key);
if (entry == null) return null;
return entry.getColBytes(3);
}
diff --git a/source/de/anomic/kelondro/kelondroRowSet.java b/source/de/anomic/kelondro/kelondroRowSet.java
index 46efd9303..25103ee88 100644
--- a/source/de/anomic/kelondro/kelondroRowSet.java
+++ b/source/de/anomic/kelondro/kelondroRowSet.java
@@ -158,12 +158,12 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd
return oldentry;
}
- private synchronized kelondroRow.Entry remove(byte[] a, int start, int length, boolean keepOrder) {
+ private synchronized kelondroRow.Entry remove(byte[] a, int start, int length) {
int index = find(a, start, length);
if (index < 0) return null;
//System.out.println("remove: chunk found at index position (before remove) " + index + ", inset=" + serverLog.arrayList(super.chunkcache, super.rowdef.objectsize() * index, length + 10) + ", searchkey=" + serverLog.arrayList(a, start, length));
kelondroRow.Entry entry = super.get(index, true);
- super.removeRow(index, keepOrder);
+ super.removeRow(index, true);
//System.out.println("remove: chunk found at index position (after remove) " + index + ", inset=" + serverLog.arrayList(super.chunkcache, super.rowdef.objectsize() * index, length) + ", searchkey=" + serverLog.arrayList(a, start, length));
int findagainindex = 0;
//System.out.println("kelondroRowSet.remove");
@@ -171,8 +171,8 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd
return entry;
}
- public kelondroRow.Entry remove(byte[] a, boolean keepOrder) {
- return remove(a, 0, a.length, keepOrder);
+ public kelondroRow.Entry remove(byte[] a) {
+ return remove(a, 0, a.length);
}
private int find(byte[] a, int astart, int alength) {
@@ -420,7 +420,7 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd
for (int ii = 0; ii < test.length; ii++) d.add(test[ii].getBytes());
for (int ii = 0; ii < test.length; ii++) d.add(test[ii].getBytes());
d.sort();
- d.remove("fuenf".getBytes(), 0, 5, false);
+ d.remove("fuenf".getBytes(), 0, 5);
Iterator<kelondroRow.Entry> ii = d.rows();
String s;
System.out.print("INPUT-ITERATOR: ");
@@ -518,11 +518,11 @@ public class kelondroRowSet extends kelondroRowCollection implements kelondroInd
key = randomHash(random);
c.put(c.rowdef.newEntry(new byte[][]{key, key}));
if (i % 1000 == 0) {
- for (int j = 0; j < delkeys.length; j++) c.remove(delkeys[j], true);
+ for (int j = 0; j < delkeys.length; j++) c.remove(delkeys[j]);
c.sort();
}
}
- for (int j = 0; j < delkeys.length; j++) c.remove(delkeys[j], true);
+ for (int j = 0; j < delkeys.length; j++) c.remove(delkeys[j]);
c.sort();
random = new Random(0);
for (int i = 0; i < testsize; i++) {
diff --git a/source/de/anomic/kelondro/kelondroSQLTable.java b/source/de/anomic/kelondro/kelondroSQLTable.java
index be0c537a2..4ac1506b3 100644
--- a/source/de/anomic/kelondro/kelondroSQLTable.java
+++ b/source/de/anomic/kelondro/kelondroSQLTable.java
@@ -186,7 +186,7 @@ public class kelondroSQLTable implements kelondroIndex {
public kelondroRow.Entry put(kelondroRow.Entry row) throws IOException {
try {
- kelondroRow.Entry oldEntry = remove(row.getColBytes(0), false);
+ kelondroRow.Entry oldEntry = remove(row.getColBytes(0));
String sqlQuery = new String
(
@@ -223,7 +223,7 @@ public class kelondroSQLTable implements kelondroIndex {
throw new UnsupportedOperationException();
}
- public kelondroRow.Entry remove(byte[] key, boolean keepOrder) throws IOException {
+ public kelondroRow.Entry remove(byte[] key) throws IOException {
try {
kelondroRow.Entry entry = this.get(key);
diff --git a/source/de/anomic/kelondro/kelondroSplitTable.java b/source/de/anomic/kelondro/kelondroSplitTable.java
index 72d5c33a3..ef9201548 100644
--- a/source/de/anomic/kelondro/kelondroSplitTable.java
+++ b/source/de/anomic/kelondro/kelondroSplitTable.java
@@ -355,10 +355,10 @@ public class kelondroSplitTable implements kelondroIndex {
return report;
}
- public synchronized kelondroRow.Entry remove(byte[] key, boolean keepOrder) throws IOException {
+ public synchronized kelondroRow.Entry remove(byte[] key) throws IOException {
kelondroIndex table = keeperOf(key);
if (table == null) return null;
- return table.remove(key, keepOrder);
+ return table.remove(key);
}
public synchronized kelondroRow.Entry removeOne() throws IOException {
diff --git a/source/de/anomic/kelondro/kelondroTree.java b/source/de/anomic/kelondro/kelondroTree.java
index 84607011e..b6a2e325e 100644
--- a/source/de/anomic/kelondro/kelondroTree.java
+++ b/source/de/anomic/kelondro/kelondroTree.java
@@ -632,8 +632,8 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
}
// Removes the mapping for this key from this map if present (optional operation).
- public kelondroRow.Entry remove(byte[] key, boolean keepOrder) throws IOException {
- // keepOrder cannot have any effect: the order inside the database file cannot be maintained, but iteration over objects will always maintain the object order
+ public kelondroRow.Entry remove(byte[] key) throws IOException {
+ // the order inside the database file cannot be maintained, but iteration over objects will always maintain the object order
// therefore keepOrder should be true, because the effect is always given, while the data structure does not maintain order
// delete from database
synchronized(writeSearchObj) {
@@ -1106,7 +1106,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
public void remove() {
if (lastKey != null) try {
- kelondroTree.this.remove(lastKey, true);
+ kelondroTree.this.remove(lastKey);
} catch (IOException e) {
// do nothing
}
@@ -1178,7 +1178,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
public void remove() {
if (lastKey != null) try {
- kelondroTree.this.remove(lastKey, true);
+ kelondroTree.this.remove(lastKey);
} catch (IOException e) {
// do nothing
}
@@ -1329,9 +1329,9 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
fm.put("abc3".getBytes(), dummy); fm.put("bcd3".getBytes(), dummy);
fm.put("def3".getBytes(), dummy); fm.put("bab3".getBytes(), dummy);
fm.print();
- fm.remove("def1".getBytes(), true); fm.remove("bab1".getBytes(), true);
- fm.remove("abc2".getBytes(), true); fm.remove("bcd2".getBytes(), true);
- fm.remove("def2".getBytes(), true); fm.remove("bab2".getBytes(), true);
+ fm.remove("def1".getBytes()); fm.remove("bab1".getBytes());
+ fm.remove("abc2".getBytes()); fm.remove("bcd2".getBytes());
+ fm.remove("def2".getBytes()); fm.remove("bab2".getBytes());
fm.put("def1".getBytes(), dummy); fm.put("bab1".getBytes(), dummy);
fm.put("abc2".getBytes(), dummy); fm.put("bcd2".getBytes(), dummy);
fm.put("def2".getBytes(), dummy); fm.put("bab2".getBytes(), dummy);
@@ -1349,7 +1349,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
} else if (args.length == 3) {
if (args[0].equals("-d")) {
kelondroTree fm = new kelondroTree(new File(args[1]), true, 10, new kelondroRow("byte[] a-4, byte[] b-4", kelondroNaturalOrder.naturalOrder, 0));
- fm.remove(args[2].getBytes(), true);
+ fm.remove(args[2].getBytes());
fm.close();
} else if (args[0].equals("-i")) {
kelondroTree fm = new kelondroTree(new File(args[1]), true, 10, new kelondroRow("byte[] a-4, byte[] b-4", kelondroNaturalOrder.naturalOrder, 0));
@@ -1474,7 +1474,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
// delete one
c = d.charAt((int) (System.currentTimeMillis() % d.length()));
b = testWord(c);
- tt.remove(b, true);
+ tt.remove(b);
d = d.substring(0, d.indexOf(c)) + d.substring(d.indexOf(c) + 1);
t = t + c;
System.out.println("removed " + new String(b));
@@ -1528,8 +1528,8 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
b = testWord('C'); tt.put(b, b); //tt.print();
b = testWord('D'); tt.put(b, b); //tt.print();
b = testWord('A'); tt.put(b, b); //tt.print();
- b = testWord('D'); tt.remove(b, true); //tt.print();
- b = testWord('B'); tt.remove(b, true); //tt.print();
+ b = testWord('D'); tt.remove(b); //tt.print();
+ b = testWord('B'); tt.remove(b); //tt.print();
b = testWord('B'); tt.put(b, b); //tt.print();
b = testWord('D'); tt.put(b, b);
b = testWord('E'); tt.put(b, b);
@@ -1618,7 +1618,7 @@ public class kelondroTree extends kelondroCachedRecords implements kelondroIndex
//tt.print();
// delete by permutation j
for (int elt = 0; elt < s[j].length(); elt++) {
- tt.remove(testWord(s[j].charAt(elt)), true);
+ tt.remove(testWord(s[j].charAt(elt)));
//tt.print();
if (countElements(tt) != tt.size()) {
System.out.println("ERROR! wrong size for probe tree " + s[i] + "; probe delete " + s[j] + "; position " + elt);
diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.java
index ec59285f4..bbb1dc27e 100644
--- a/source/de/anomic/plasma/plasmaSwitchboard.java
+++ b/source/de/anomic/plasma/plasmaSwitchboard.java
@@ -142,7 +142,6 @@ import de.anomic.kelondro.kelondroBitfield;
import de.anomic.kelondro.kelondroCache;
import de.anomic.kelondro.kelondroCachedRecords;
import de.anomic.kelondro.kelondroMSetTools;
-import de.anomic.kelondro.kelondroMapTable;
import de.anomic.kelondro.kelondroNaturalOrder;
import de.anomic.plasma.parser.ParserException;
import de.anomic.server.serverAbstractSwitch;
@@ -218,12 +217,11 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
public wikiBoard wikiDB;
public blogBoard blogDB;
public blogBoardComments blogCommentDB;
- public static RobotsTxt robots = null;
+ public RobotsTxt robots;
public boolean rankingOn;
public plasmaRankingDistribution rankingOwnDistribution;
public plasmaRankingDistribution rankingOtherDistribution;
public HashMap<String, Object[]> outgoingCookies, incomingCookies;
- public kelondroMapTable facilityDB;
public plasmaParser parser;
public volatile long proxyLastAccess, localSearchLastAccess, remoteSearchLastAccess;
public yacyCore yc;
@@ -838,7 +836,7 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
// load the network definition
overwriteNetworkDefinition(this);
-
+
// load values from configs
this.plasmaPath = getConfigPath(PLASMA_PATH, PLASMA_PATH_DEFAULT);
this.log.logConfig("Plasma DB Path: " + this.plasmaPath.toString());
@@ -949,7 +947,6 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
plasmaSearchRankingProcess.loadYBR(YBRPath, 15);
}
-
// loading the robots.txt db
this.log.logConfig("Initializing robots.txt DB");
File robotsDBFile = new File(this.plasmaPath, DBFILE_CRAWL_ROBOTS);
@@ -1632,7 +1629,6 @@ public final class plasmaSwitchboard extends serverAbstractSwitch<IndexingStack.
userDB.close();
bookmarksDB.close();
messageDB.close();
- if (facilityDB != null) facilityDB.close();
crawlStacker.close();
robots.close();
parser.close();
diff --git a/source/de/anomic/yacy/yacyNewsDB.java b/source/de/anomic/yacy/yacyNewsDB.java
index 81d90d9a0..42fa9ae24 100644
--- a/source/de/anomic/yacy/yacyNewsDB.java
+++ b/source/de/anomic/yacy/yacyNewsDB.java
@@ -88,7 +88,7 @@ public class yacyNewsDB {
}
public void remove(String id) throws IOException {
- news.remove(id.getBytes(), false);
+ news.remove(id.getBytes());
}
public synchronized yacyNewsRecord put(yacyNewsRecord record) throws IOException {