Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

NUTCH-1854 bin/crawl fails with a parsing fetcher

Sebastian Nagel2d2b4fcc27ee
diff --git a/CHANGES.txt b/CHANGES.txt
index 51f43f531..f2a075c7c 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,6 +2,8 @@ Nutch Change Log
Nutch Current Development 1.10-SNAPSHOT
+* NUTCH-1854 bin/crawl fails with a parsing fetcher (Asitang Mishra via snagel)
+
* NUTCH-1989 Handling invalid URLs in CommonCrawlDataDumper (Giuseppe Totaro via mattmann)
* NUTCH-1988 Make nested output directory dump optional (Michael Joyce via mattmann)
@@ -12,7 +14,7 @@ Nutch Current Development 1.10-SNAPSHOT
* NUTCH-1906 Typo in CrawlDbReader command line help (Michael Joyce via mattmann)
-* NUTCH-1911 Imeprove DomainStatistics tool command line parsing (Michael Joyce via mattmann)
+* NUTCH-1911 Improve DomainStatistics tool command line parsing (Michael Joyce via mattmann)
* NUTCH-1981 Upgrade to icu4j 55.1 (Marko Asplund via snagel)
diff --git a/src/java/org/apache/nutch/parse/ParseSegment.java b/src/java/org/apache/nutch/parse/ParseSegment.java
index e1360dff9..98cd6c6d9 100644
--- a/src/java/org/apache/nutch/parse/ParseSegment.java
+++ b/src/java/org/apache/nutch/parse/ParseSegment.java
@@ -22,6 +22,7 @@ import org.slf4j.LoggerFactory;
import org.apache.nutch.crawl.CrawlDatum;
import org.apache.nutch.crawl.SignatureFactory;
+import org.apache.nutch.segment.SegmentChecker;
import org.apache.hadoop.io.*;
import org.apache.hadoop.mapred.*;
import org.apache.hadoop.util.*;
@@ -32,6 +33,7 @@ import org.apache.nutch.net.protocols.Response;
import org.apache.nutch.protocol.*;
import org.apache.nutch.scoring.ScoringFilterException;
import org.apache.nutch.scoring.ScoringFilters;
+import org.apache.hadoop.fs.FileSystem;
import org.apache.nutch.util.*;
import org.apache.hadoop.fs.Path;
@@ -198,6 +200,11 @@ public class ParseSegment extends Configured implements Tool,
}
public void parse(Path segment) throws IOException {
+ if (SegmentChecker.isParsed(segment, FileSystem.get(getConf()))) {
+ LOG.warn("Segment: " + segment
+ + " already parsed!! Skipped parsing this segment!!"); // NUTCH-1854
+ return;
+ }
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
long start = System.currentTimeMillis();
diff --git a/src/java/org/apache/nutch/segment/SegmentChecker.java b/src/java/org/apache/nutch/segment/SegmentChecker.java
index 1f570c178..67d58dd2f 100644
--- a/src/java/org/apache/nutch/segment/SegmentChecker.java
+++ b/src/java/org/apache/nutch/segment/SegmentChecker.java
@@ -115,4 +115,16 @@ public class SegmentChecker {
}
}
-}
\ No newline at end of file
+ /**
+ * Check the segment to see if it is has been parsed before.
+ */
+ public static boolean isParsed(Path segment, FileSystem fs)
+ throws IOException {
+
+ if (fs.exists(new Path(segment, CrawlDatum.PARSE_DIR_NAME)))
+ return true;
+ return false;
+
+ }
+
+}