Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

NUTCH-1057 Fetcher thread time out configurable

Markus Jelsma266678bc5842
diff --git a/CHANGES.txt b/CHANGES.txt
index f52dd1baa..40c69e939 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,6 +2,8 @@ Nutch Change Log
Release 1.4 - Current development
+* NUTCH-1057 Fetcher thread time out configurable (markus)
+
* NUTCH-1037 Option to deduplicate anchors prior to indexing (markus)
* NUTCH-1050 Add segmentDir option to WebGraph (markus)
diff --git a/conf/nutch-default.xml b/conf/nutch-default.xml
index 4339ef15a..3f48909c0 100644
--- a/conf/nutch-default.xml
+++ b/conf/nutch-default.xml
@@ -686,6 +686,15 @@
</description>
</property>
+<property>
+ <name>fetcher.threads.timeout.divisor</name>
+ <value>2</value>
+ <description>The thread time-out divisor to use. By default threads have a time-out
+ value of mapred.task.timeout / 2. Increase this setting if the fetcher waits too
+ long before killing hanged threads.
+ </description>
+</property>
+
<!-- moreindexingfilter plugin properties -->
<property>
diff --git a/src/java/org/apache/nutch/fetcher/Fetcher.java b/src/java/org/apache/nutch/fetcher/Fetcher.java
index 074cd6542..1849a45a4 100644
--- a/src/java/org/apache/nutch/fetcher/Fetcher.java
+++ b/src/java/org/apache/nutch/fetcher/Fetcher.java
@@ -1010,6 +1010,9 @@ public class Fetcher extends Configured implements Tool,
int threadCount = getConf().getInt("fetcher.threads.fetch", 10);
if (LOG.isInfoEnabled()) { LOG.info("Fetcher: threads: " + threadCount); }
+ int timeoutDivisor = getConf().getInt("fetcher.threads.timeout.divisor", 2);
+ if (LOG.isInfoEnabled()) { LOG.info("Fetcher: time-out divisor: " + timeoutDivisor); }
+
feeder = new QueueFeeder(input, fetchQueues, threadCount * 50);
//feeder.setPriority((Thread.MAX_PRIORITY + Thread.NORM_PRIORITY) / 2);
@@ -1027,7 +1030,7 @@ public class Fetcher extends Configured implements Tool,
}
// select a timeout that avoids a task timeout
- long timeout = getConf().getInt("mapred.task.timeout", 10*60*1000)/2;
+ long timeout = getConf().getInt("mapred.task.timeout", 10*60*1000)/timeoutDivisor;
do { // wait for threads to exit
try {