Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

NUTCH-1177 Generator to select on retry interval

Markus Jelsmaa3d903731b82
diff --git a/CHANGES.txt b/CHANGES.txt
index 9b99d93ae..175b4f400 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,5 +1,7 @@
Nutch Change Log
+* NUTCH-1177 Generator to select on retry interval (markus)
+
* NUTCH-1246 Upgrade to Hadoop 1.0.0 (jnioche)
* NUTCH-1139 Indexer to delete gone documents (markus)
diff --git a/conf/nutch-default.xml b/conf/nutch-default.xml
index c07a2e53d..c83202464 100644
--- a/conf/nutch-default.xml
+++ b/conf/nutch-default.xml
@@ -587,7 +587,22 @@
fetchlist. -1 if unlimited.</description>
</property>
+<property>
+ <name>generate.min.score</name>
+ <value>0</value>
+ <description>Select only entries with a score larger than
+ generate.min.score.</description>
+</property>
+
+<property>
+ <name>generate.min.interval</name>
+ <value>-1</value>
+ <description>Select only entries with a retry interval lower than
+ generate.min.interval. A value of -1 disables this check.</description>
+</property>
+
<!-- urlpartitioner properties -->
+
<property>
<name>partition.url.mode</name>
<value>byHost</value>
diff --git a/src/java/org/apache/nutch/crawl/Generator.java b/src/java/org/apache/nutch/crawl/Generator.java
index a39ab566d..735a16b17 100644
--- a/src/java/org/apache/nutch/crawl/Generator.java
+++ b/src/java/org/apache/nutch/crawl/Generator.java
@@ -61,6 +61,7 @@ public class Generator extends Configured implements Tool {
public static final String GENERATE_UPDATE_CRAWLDB = "generate.update.crawldb";
public static final String GENERATOR_MIN_SCORE = "generate.min.score";
+ public static final String GENERATOR_MIN_INTERVAL = "generate.min.interval";
public static final String GENERATOR_FILTER = "generate.filter";
public static final String GENERATOR_NORMALISE = "generate.normalise";
public static final String GENERATOR_MAX_COUNT = "generate.max.count";
@@ -129,6 +130,7 @@ public class Generator extends Configured implements Tool {
private long genDelay;
private FetchSchedule schedule;
private float scoreThreshold = 0f;
+ private int intervalThreshold = -1;
private int maxNumSegments = 1;
int currentsegmentnum = 1;
@@ -155,6 +157,7 @@ public class Generator extends Configured implements Tool {
if (time > 0) genTime.set(time);
schedule = FetchScheduleFactory.getFetchSchedule(job);
scoreThreshold = job.getFloat(GENERATOR_MIN_SCORE, Float.NaN);
+ intervalThreshold = job.getInt(GENERATOR_MIN_INTERVAL, -1);
maxNumSegments = job.getInt(GENERATOR_MAX_NUM_SEGMENTS, 1);
segCounts = new int[maxNumSegments];
}
@@ -205,6 +208,9 @@ public class Generator extends Configured implements Tool {
// consider only entries with a score superior to the threshold
if (scoreThreshold != Float.NaN && sort < scoreThreshold) return;
+ // consider only entries with a retry (or fetch) interval lower than threshold
+ if (intervalThreshold != -1 && crawlDatum.getFetchInterval() > intervalThreshold) return;
+
// sort by decreasing score, using DecreasingFloatComparator
sortValue.set(sort);
// record generation time