Apache Nutch is an extensible and scalable web crawler
NUTCH-626 - Fetcher2 breaks out the domain with db.ignore.external.links set at cross domain redirects, contributed by Remco Verhoef, dogacan
Sami Siren79cce738b58b
diff --git a/CHANGES.txt b/CHANGES.txtindex 59fe9621a..e03c9ff8d 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -349,11 +349,14 @@ Unreleased changes (1.0-dev)130. NUTCH-563 - Include custom fields in BasicQueryFilter(Julien Nioche via siren)-131. NUTCH-695 - incorrect mime type detection by MoreIndexingFilter plugin+131. NUTCH-695 - Incorrect mime type detection by MoreIndexingFilter plugin(Dmitry Lihachev via siren)132. NUTCH-694 - Distributed Search Server fails (siren)+133. NUTCH-626 - Fetcher2 breaks out the domain with db.ignore.external.links+ set at cross domain redirects (Remco Verhoef, dogacan via siren)+Release 0.9 - 2007-04-021. Changed log4j confiquration to log to stdout on commandlinediff --git a/src/java/org/apache/nutch/fetcher/Fetcher2.java b/src/java/org/apache/nutch/fetcher/Fetcher2.javaindex 4e906caf7..6a229b127 100644--- a/src/java/org/apache/nutch/fetcher/Fetcher2.java+++ b/src/java/org/apache/nutch/fetcher/Fetcher2.java@@ -94,7 +94,6 @@ public class Fetcher2 extends Configured implementsthrows IOException {FileStatus[] files = listStatus(job);FileSplit[] splits = new FileSplit[files.length];- FileSystem fs = FileSystem.get(job);for (int i = 0; i < files.length; i++) {FileStatus cur = files[i];splits[i] = new FileSplit(cur.getPath(), 0,@@ -443,6 +442,7 @@ public class Fetcher2 extends Configured implementsprivate String reprUrl;private boolean redirecting;private int redirectCount;+ private boolean ignoreExternalLinks;public FetcherThread(Configuration conf) {this.setDaemon(true); // don't hang JVM on exit@@ -457,6 +457,8 @@ public class Fetcher2 extends Configured implements// backward-compatible default settingthis.byIP = conf.getBoolean("fetcher.threads.per.host.by.ip", true);this.maxRedirect = conf.getInt("http.redirect.max", 3);+ this.ignoreExternalLinks =+ conf.getBoolean("db.ignore.external.links", false);}public void run() {@@ -673,6 +675,22 @@ public class Fetcher2 extends Configured implementsthrows MalformedURLException, URLFilterException {newUrl = normalizers.normalize(newUrl, URLNormalizers.SCOPE_FETCHER);newUrl = urlFilters.filter(newUrl);++ if (ignoreExternalLinks) {+ try {+ String origHost = new URL(urlString).getHost().toLowerCase();+ String newHost = new URL(newUrl).getHost().toLowerCase();+ if (!origHost.equals(newHost)) {+ if (LOG.isDebugEnabled()) {+ LOG.debug(" - ignoring redirect " + redirType + " from " ++ urlString + " to " + newUrl ++ " because external links are ignored");+ }+ return null;+ }+ } catch (MalformedURLException e) { }+ }+if (newUrl != null && !newUrl.equals(urlString)) {reprUrl = URLUtil.chooseRepr(reprUrl, newUrl, temp);url = new Text(newUrl);