Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

Fix NUTCH-108. Log hosts that exceed generate.max.per.host. Contributed by Rod Taylor.

Douglass Cutting5d63d4944392
diff --git a/CHANGES.txt b/CHANGES.txt
index 5c813b8d4..e11673f8d 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -4,6 +4,10 @@ Release 0.8
1. NUTCH-107 - Typo in plugin/urlfilter-*/plugin.xml. (Stephen Cross).
+ 2. NUTCH-108 - Log hosts that exceed generate.max.per.host.
+ (Rod Taylor via cutting)
+
+
Release 0.7 - 2005-08-17
1. Added support for "type:" in queries. Search results are limited/qualified
diff --git a/src/java/org/apache/nutch/crawl/Generator.java b/src/java/org/apache/nutch/crawl/Generator.java
index a226d9f3b..bd86142af 100644
--- a/src/java/org/apache/nutch/crawl/Generator.java
+++ b/src/java/org/apache/nutch/crawl/Generator.java
@@ -127,12 +127,18 @@ public class Generator extends Configured {
if (maxPerHost > 0) { // are we counting hosts?
String host = new URL(url.toString()).getHost();
Integer hostCount = (Integer)hostCounts.get(host);
- if (hostCount != null) {
- if (hostCount.intValue() >= maxPerHost)
- continue; // too many from host
- hostCounts.put(host, new Integer(hostCount.intValue()+1));
- } else { // update host count
- hostCounts.put(host, new Integer(1));
+
+ // increment hostCount
+ hostCount = new Integer(hostCount==null ? 1 : hostCount.intValue()+1);
+ hostCounts.put(host, hostCount);
+
+ // skip URL if above the limit per host.
+ if (hostCount.intValue() > maxPerHost) {
+ if (hostCount.intValue() == maxPerHost + 1) {
+ LOG.info("Host "+ host +" has more than "+ maxPerHost +" URLs."+
+ " Skipping additional.");
+ }
+ continue;
}
}