Apache Nutch is an extensible and scalable web crawler
NUTCH-872 Change the default fetcher.parse to FALSE.
Andrzej Bialeckieff7d5dbbfd8
diff --git a/CHANGES.txt b/CHANGES.txtindex 599aba81a..6203079cf 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -2,6 +2,8 @@ Nutch Change LogRelease 2.0 - Current Development+* NUTCH-872 Change the default fetcher.parse to FALSE (ab).+* NUTCH-861 Renamed HTMLParseFilter into ParseFilter* NUTCH-876 Remove remaining robots/IP blocking code in lib-http (ab)diff --git a/conf/nutch-default.xml b/conf/nutch-default.xmlindex b289105c0..c7f9a31f9 100644--- a/conf/nutch-default.xml+++ b/conf/nutch-default.xml@@ -641,8 +641,9 @@<property><name>fetcher.parse</name>- <value>true</value>- <description>If true, fetcher will parse content.</description>+ <value>false</value>+ <description>If true, fetcher will parse content. NOTE: previous releases would+ default to true. Since 2.0 this is set to false as a safer default.</description></property><property>diff --git a/src/java/org/apache/nutch/fetcher/FetcherJob.java b/src/java/org/apache/nutch/fetcher/FetcherJob.javaindex a2d212522..181691488 100644--- a/src/java/org/apache/nutch/fetcher/FetcherJob.java+++ b/src/java/org/apache/nutch/fetcher/FetcherJob.java@@ -138,7 +138,17 @@ public class FetcherJob implements Tool {return fields;}- public int fetch(int threads, String crawlId, boolean shouldResume, boolean isParsing)+ /**+ * Run fetcher.+ * @param threads number of threads per map task+ * @param crawlId crawlId (obtained from Generator) or null to fetch all generated fetchlists+ * @param shouldResume+ * @param parse if true, then parse content immediately, if false then a separate+ * run of {@link ParserJob} will be needed.+ * @return 0 on success+ * @throws Exception+ */+ public int fetch(int threads, String crawlId, boolean shouldResume, boolean parse)throws Exception {LOG.info("FetcherJob: starting");@@ -148,7 +158,7 @@ public class FetcherJob implements Tool {getConf().setInt(THREADS_KEY, threads);}getConf().set(GeneratorJob.CRAWL_ID, crawlId);- getConf().setBoolean(PARSE_KEY, isParsing);+ getConf().setBoolean(PARSE_KEY, parse);getConf().setBoolean(RESUME_KEY, shouldResume);// set the actual time for the timelimit relative@@ -224,10 +234,10 @@ public class FetcherJob implements Tool {public int run(String[] args) throws Exception {int threads = -1;boolean shouldResume = false;- boolean isParsing = true;+ boolean parse = getConf().getBoolean(PARSE_KEY, false);String crawlId;- String usage = "Usage: FetcherJob (<crawl id> | -all) [-threads N] [-noParsing] [-resume]";+ String usage = "Usage: FetcherJob (<crawl id> | -all) [-threads N] [-parse] [-resume]";if (args.length == 0) {System.err.println(usage);@@ -235,7 +245,7 @@ public class FetcherJob implements Tool {}crawlId = args[0];- if (crawlId.equals("-threads") || crawlId.equals("-resume") || crawlId.equals("-noParsing")) {+ if (crawlId.equals("-threads") || crawlId.equals("-resume") || crawlId.equals("-parse")) {System.err.println(usage);return -1;}@@ -245,12 +255,12 @@ public class FetcherJob implements Tool {threads = Integer.parseInt(args[++i]);} else if ("-resume".equals(args[i])) {shouldResume = true;- } else if ("-noParsing".equals(args[i])) {- isParsing = false;+ } else if ("-parse".equals(args[i])) {+ parse = true;}}- int fetchcode = fetch(threads, crawlId, shouldResume, isParsing); // run the Fetcher+ int fetchcode = fetch(threads, crawlId, shouldResume, parse); // run the Fetcherreturn fetchcode;}diff --git a/src/java/org/apache/nutch/fetcher/FetcherReducer.java b/src/java/org/apache/nutch/fetcher/FetcherReducer.javaindex fe7ef3bde..184a0248c 100644--- a/src/java/org/apache/nutch/fetcher/FetcherReducer.java+++ b/src/java/org/apache/nutch/fetcher/FetcherReducer.java@@ -63,7 +63,7 @@ extends GoraReducer<IntWritable, FetchEntry, String, WebPage> {private FetchItemQueues fetchQueues;- private boolean isParsing;+ private boolean parse;private ParseUtil parseUtil;@@ -590,7 +590,7 @@ extends GoraReducer<IntWritable, FetchEntry, String, WebPage> {Mark.FETCH_MARK.putMark(fit.page, Mark.GENERATE_MARK.checkMark(fit.page));String key = TableUtil.reverseUrl(fit.url);- if (isParsing) {+ if (parse) {URLWebPage redirectedPage = parseUtil.process(key, fit.page);if (redirectedPage != null) {context.write(TableUtil.reverseUrl(redirectedPage.getUrl()),@@ -708,16 +708,12 @@ extends GoraReducer<IntWritable, FetchEntry, String, WebPage> {Configuration conf = context.getConfiguration();this.fetchQueues = new FetchItemQueues(conf);int threadCount = conf.getInt("fetcher.threads.fetch", 10);- isParsing = conf.getBoolean("fetcher.parse", true);- if (isParsing) {+ parse = conf.getBoolean(FetcherJob.PARSE_KEY, false);+ if (parse) {parseUtil = new ParseUtil(conf);}LOG.info("Fetcher: threads: " + threadCount);- // set non-blocking & no-robots mode for HTTP protocol plugins.- conf.setBoolean(Protocol.CHECK_BLOCKING, false);- conf.setBoolean(Protocol.CHECK_ROBOTS, false);-feeder = new QueueFeeder(context, fetchQueues, threadCount * 50);feeder.start();