Apache Nutch is an extensible and scalable web crawler
NUTCH-2041 indexer fails if linkdb is missing
Sebastian Nagel8f0a98458f86
diff --git a/CHANGES.txt b/CHANGES.txtindex 95fd50509..e617839b9 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -2,6 +2,8 @@ Nutch Change LogNutch Current Development 1.11-SNAPSHOT+* NUTCH-2041 indexer fails if linkdb is missing (snagel)+* NUTCH-2016 Remove unused class OldFetcher (snagel)* NUTCH-2000 Link inversion fails with .locked already exists (jnioche, snagel)diff --git a/src/java/org/apache/nutch/indexer/IndexerMapReduce.java b/src/java/org/apache/nutch/indexer/IndexerMapReduce.javaindex debaed3b5..bcf4663f2 100644--- a/src/java/org/apache/nutch/indexer/IndexerMapReduce.java+++ b/src/java/org/apache/nutch/indexer/IndexerMapReduce.java@@ -23,6 +23,7 @@ import java.util.Iterator;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import org.apache.hadoop.conf.Configured;+import org.apache.hadoop.fs.FileSystem;import org.apache.hadoop.fs.Path;import org.apache.hadoop.io.Text;import org.apache.hadoop.io.Writable;@@ -33,6 +34,7 @@ import org.apache.hadoop.mapred.OutputCollector;import org.apache.hadoop.mapred.Reducer;import org.apache.hadoop.mapred.Reporter;import org.apache.hadoop.mapred.SequenceFileInputFormat;+import org.apache.hadoop.util.StringUtils;import org.apache.nutch.crawl.CrawlDatum;import org.apache.nutch.crawl.CrawlDb;import org.apache.nutch.crawl.Inlinks;@@ -354,8 +356,20 @@ public class IndexerMapReduce extends Configured implementsFileInputFormat.addInputPath(job, new Path(crawlDb, CrawlDb.CURRENT_NAME));- if (linkDb != null)- FileInputFormat.addInputPath(job, new Path(linkDb, LinkDb.CURRENT_NAME));+ if (linkDb != null) {+ Path currentLinkDb = new Path(linkDb, LinkDb.CURRENT_NAME);+ try {+ if (FileSystem.get(job).exists(currentLinkDb)) {+ FileInputFormat.addInputPath(job, currentLinkDb);+ } else {+ LOG.warn("Ignoring linkDb for indexing, no linkDb found in path: {}",+ linkDb);+ }+ } catch (IOException e) {+ LOG.warn("Failed to use linkDb ({}) for indexing: {}", linkDb,+ StringUtils.stringifyException(e));+ }+ }job.setInputFormat(SequenceFileInputFormat.class);