Apache Nutch is an extensible and scalable web crawler
- fix for NUTCH-2015 Make FetchNodeDb optional (off by default) if NutchServer is not used contributed by Sujen Shah this closes #25
Chris Mattmann0ee4f428e6e8
diff --git a/CHANGES.txt b/CHANGES.txtindex ec2ac14ab..d549d138a 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -2,6 +2,8 @@ Nutch Change LogNutch Current Development 1.11-SNAPSHOT+* NUTCH-2015 Make FetchNodeDb optional (off by default) if NutchServer is not used (Sujen Shah via mattmann)+* NUTCH-208 http: proxy exception list: (Matthias Günter, siren, markus, lewismc)* NUTCH-2007 add test libs to classpath of bin/nutch junit (snagel)diff --git a/src/java/org/apache/nutch/fetcher/FetcherThread.java b/src/java/org/apache/nutch/fetcher/FetcherThread.javaindex 53a834b1a..9a482b93d 100644--- a/src/java/org/apache/nutch/fetcher/FetcherThread.java+++ b/src/java/org/apache/nutch/fetcher/FetcherThread.java@@ -57,6 +57,7 @@ import org.apache.nutch.protocol.ProtocolOutput;import org.apache.nutch.protocol.ProtocolStatus;import org.apache.nutch.scoring.ScoringFilterException;import org.apache.nutch.scoring.ScoringFilters;+import org.apache.nutch.service.NutchServer;import org.apache.nutch.util.StringUtil;import org.apache.nutch.util.URLUtil;import org.slf4j.Logger;@@ -126,6 +127,7 @@ public class FetcherThread extends Thread {//Used by the REST serviceprivate FetchNode fetchNode;+ private boolean reportToNutchServer;public FetcherThread(Configuration conf, AtomicInteger activeThreads, FetchItemQueues fetchQueues,QueueFeeder feeder, AtomicInteger spinWaiting, AtomicLong lastRequestStart, Reporter reporter,@@ -189,11 +191,17 @@ public class FetcherThread extends Thread {FetchItem fit = null;try {-+ // checking for the server to be running and fetcher.parse to be true+ if (parsing && NutchServer.getInstance().isRunning())+ reportToNutchServer = true;+while (true) {// creating FetchNode for storing in FetchNodeDb- this.fetchNode = new FetchNode();-+ if (reportToNutchServer)+ this.fetchNode = new FetchNode();+ else+ this.fetchNode = null;+// check whether must be stoppedif (isHalted()) {LOG.debug(getName() + " set to halted");@@ -289,10 +297,12 @@ public class FetcherThread extends Thread {String urlString = fit.url.toString();- //used for FetchNode- fetchNode.setStatus(status.getCode());- fetchNode.setFetchTime(System.currentTimeMillis());- fetchNode.setUrl(fit.url);+ // used for FetchNode+ if (fetchNode != null) {+ fetchNode.setStatus(status.getCode());+ fetchNode.setFetchTime(System.currentTimeMillis());+ fetchNode.setUrl(fit.url);+ }reporter.incrCounter("FetcherStatus", status.getName(), 1);@@ -620,11 +630,12 @@ public class FetcherThread extends Thread {fromHost = null;}- //used by fetchNode- fetchNode.setOutlinks(links);- fetchNode.setTitle(parseData.getTitle());- FetchNodeDb.getInstance().put(fetchNode.getUrl().toString(), fetchNode);-+ //used by fetchNode+ if(fetchNode!=null){+ fetchNode.setOutlinks(links);+ fetchNode.setTitle(parseData.getTitle());+ FetchNodeDb.getInstance().put(fetchNode.getUrl().toString(), fetchNode);+ }int validCount = 0;// Process all outlinks, normalize, filter and deduplicate