Apache Nutch is an extensible and scalable web crawler
NUTCH-350: urls incorrectly marked as STATUS_FETCH_GONE when blocked by http.max.delays. Instead the status is set to STATUS_FETCH_RETRY. Since this is an intermittent problem related to the Fetcher implementation, we don't increase the retry counter.
Andrzej Bialecki05e73077753c
diff --git a/CHANGES.txt b/CHANGES.txtindex 43442ad29..ce192ce23 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -32,6 +32,18 @@ Unreleased changes (0.9-dev)11. NUTCH-332 - Fix the problem of doubling scores caused by links pointingto the current page (e.g. anchors). (Stefan Groschupf via ab)+12. NUTCH-365 - Flexible URL normalization (ab)++13. NUTCH-336 - Differentiate between newly discovered pages and newly+ injected pages (Chris Schneider via ab) NOTE: this changes the+ scoring API, filter implementations need to be updated.++14. NUTCH-337 - Fetcher ignores the fetcher.parse value (Stefan Groschupf+ via ab)++15. NUTCH-350 - Urls blocked by http.max.delays incorrectly marked as GONE+ (Stefan Groschupf via ab)+Release 0.8 - 2006-07-25diff --git a/src/java/org/apache/nutch/fetcher/Fetcher.java b/src/java/org/apache/nutch/fetcher/Fetcher.javaindex ecbe1290c..8ca110e7a 100644--- a/src/java/org/apache/nutch/fetcher/Fetcher.java+++ b/src/java/org/apache/nutch/fetcher/Fetcher.java@@ -189,18 +189,24 @@ public class Fetcher extends ToolBase implements MapRunnable {}break;+ // failures - increase the retry countercase ProtocolStatus.EXCEPTION:logError(url, status.getMessage());+ /* FALLTHROUGH */case ProtocolStatus.RETRY: // retrydatum.setRetriesSinceFetch(datum.getRetriesSinceFetch()+1);+ /* FALLTHROUGH */+ // intermittent blocking - retry without increasing the counter+ case ProtocolStatus.WOULDBLOCK:+ case ProtocolStatus.BLOCKED:output(url, datum, null, CrawlDatum.STATUS_FETCH_RETRY);break;+ // permanent failurescase ProtocolStatus.GONE: // gonecase ProtocolStatus.NOTFOUND:case ProtocolStatus.ACCESS_DENIED:case ProtocolStatus.ROBOTS_DENIED:- case ProtocolStatus.WOULDBLOCK:case ProtocolStatus.NOTMODIFIED:output(url, datum, null, CrawlDatum.STATUS_FETCH_GONE);break;diff --git a/src/java/org/apache/nutch/protocol/ProtocolStatus.java b/src/java/org/apache/nutch/protocol/ProtocolStatus.javaindex 30184ca34..bc2bad98d 100644--- a/src/java/org/apache/nutch/protocol/ProtocolStatus.java+++ b/src/java/org/apache/nutch/protocol/ProtocolStatus.java@@ -64,7 +64,9 @@ public class ProtocolStatus extends VersionedWritable {* The expected number of milliseconds to wait before retry may be provided* in args. */public static final int WOULDBLOCK = 22;-+ /** Thread was blocked http.max.delays times during fetching. */+ public static final int BLOCKED = 23;+// Useful static instances for status codes that don't usually require any// additional arguments.public static final ProtocolStatus STATUS_SUCCESS = new ProtocolStatus(SUCCESS);@@ -77,6 +79,7 @@ public class ProtocolStatus extends VersionedWritable {public static final ProtocolStatus STATUS_NOTFETCHING = new ProtocolStatus(NOTFETCHING);public static final ProtocolStatus STATUS_NOTMODIFIED = new ProtocolStatus(NOTMODIFIED);public static final ProtocolStatus STATUS_WOULDBLOCK = new ProtocolStatus(WOULDBLOCK);+ public static final ProtocolStatus STATUS_BLOCKED = new ProtocolStatus(BLOCKED);private int code;private long lastModified;@@ -99,6 +102,7 @@ public class ProtocolStatus extends VersionedWritable {codeToName.put(new Integer(NOTFETCHING), "notfetching");codeToName.put(new Integer(NOTMODIFIED), "notmodified");codeToName.put(new Integer(WOULDBLOCK), "wouldblock");+ codeToName.put(new Integer(BLOCKED), "blocked");}public ProtocolStatus() {diff --git a/src/plugin/lib-http/src/java/org/apache/nutch/protocol/http/api/BlockedException.java b/src/plugin/lib-http/src/java/org/apache/nutch/protocol/http/api/BlockedException.javanew file mode 100644index 000000000..27b7cbd0a--- /dev/null+++ b/src/plugin/lib-http/src/java/org/apache/nutch/protocol/http/api/BlockedException.java@@ -0,0 +1,25 @@+/**+ * Copyright 2006 The Apache Software Foundation+ *+ * Licensed under the Apache License, Version 2.0 (the "License");+ * you may not use this file except in compliance with the License.+ * You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++package org.apache.nutch.protocol.http.api;++public class BlockedException extends HttpException {++ public BlockedException(String msg) {+ super(msg);+ }++}diff --git a/src/plugin/lib-http/src/java/org/apache/nutch/protocol/http/api/HttpBase.java b/src/plugin/lib-http/src/java/org/apache/nutch/protocol/http/api/HttpBase.javaindex 3e68246e7..ea33a78df 100644--- a/src/plugin/lib-http/src/java/org/apache/nutch/protocol/http/api/HttpBase.java+++ b/src/plugin/lib-http/src/java/org/apache/nutch/protocol/http/api/HttpBase.java@@ -197,7 +197,12 @@ public abstract class HttpBase implements Protocol {null, null, this.conf);return new ProtocolOutput(c, ProtocolStatus.STATUS_WOULDBLOCK);}- String host = blockAddr(u, delay);+ String host;+ try {+ host = blockAddr(u, delay);+ } catch (BlockedException be) {+ return new ProtocolOutput(null, ProtocolStatus.STATUS_BLOCKED);+ }Response response;try {response = getResponse(u, datum, false); // make a request@@ -354,7 +359,7 @@ public abstract class HttpBase implements Protocol {}if (delays == maxDelays)- throw new HttpException("Exceeded http.max.delays: retry later.");+ throw new BlockedException("Exceeded http.max.delays: retry later.");long done = time.longValue();long now = System.currentTimeMillis();