Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

NUTCH-2183 Improvement to SegmentChecker for skipping non-segments present in segments directory

Lewis John McGibbneyfa4ebb821b72
diff --git a/CHANGES.txt b/CHANGES.txt
index 2deb70b1c..2f0c327ec 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,5 +1,7 @@
Nutch Change Log
+* NUTCH-2183 Improvement to SegmentChecker for skipping non-segments present in segments directory (lewismc)
+
* NUTCH-2180 FileDumper skips Corrupt Segments (Harshavardhan Manjunatha via lewismc)
* NUTCH-2042 parse-html increase chunk size used to detect charset (snagel)
diff --git a/src/java/org/apache/nutch/indexer/IndexingJob.java b/src/java/org/apache/nutch/indexer/IndexingJob.java
index 900af6ab1..342ea4a30 100644
--- a/src/java/org/apache/nutch/indexer/IndexingJob.java
+++ b/src/java/org/apache/nutch/indexer/IndexingJob.java
@@ -186,11 +186,13 @@ public class IndexingJob extends NutchTool implements Tool {
boolean base64 = false;
for (int i = 1; i < args.length; i++) {
+ FileSystem fs = null;
+ Path dir = null;
if (args[i].equals("-linkdb")) {
linkDb = new Path(args[++i]);
} else if (args[i].equals("-dir")) {
- Path dir = new Path(args[++i]);
- FileSystem fs = dir.getFileSystem(getConf());
+ dir = new Path(args[++i]);
+ fs = dir.getFileSystem(getConf());
FileStatus[] fstats = fs.listStatus(dir,
HadoopFSUtil.getPassDirectoriesFilter(fs));
Path[] files = HadoopFSUtil.getPaths(fstats);
@@ -214,7 +216,11 @@ public class IndexingJob extends NutchTool implements Tool {
} else if (args[i].equals("-params")) {
params = args[++i];
} else {
- segments.add(new Path(args[i]));
+ dir = new Path(args[i]);
+ fs = dir.getFileSystem(getConf());
+ if (SegmentChecker.isIndexable(dir,fs)) {
+ segments.add(dir);
+ }
}
}
diff --git a/src/java/org/apache/nutch/segment/SegmentChecker.java b/src/java/org/apache/nutch/segment/SegmentChecker.java
index 3d51c5575..ec601f4c7 100644
--- a/src/java/org/apache/nutch/segment/SegmentChecker.java
+++ b/src/java/org/apache/nutch/segment/SegmentChecker.java
@@ -65,6 +65,11 @@ public class SegmentChecker {
public static boolean checkSegmentDir(Path segmentPath, FileSystem fs)
throws IOException {
+ if (segmentPath.getName().length() != 14) {
+ LOG.warn("The input path at {} is not a segment... skipping", segmentPath.getName());
+ return false;
+ }
+
FileStatus[] fstats_segment = fs.listStatus(segmentPath,
HadoopFSUtil.getPassDirectoriesFilter(fs));
Path[] segment_files = HadoopFSUtil.getPaths(fstats_segment);