Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

NUTCH-1030 WebgraphDB program requires manually added directories

Markus Jelsma6483e3e4f41a
diff --git a/CHANGES.txt b/CHANGES.txt
index 8aa148995..816042f28 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,6 +2,8 @@ Nutch Change Log
Release 1.4 - Current development
+* NUTCH-1030 WebgraphDB program requires manually added directories (markus)
+
* NUTCH-1011 Normalize duplicate slashes in URL's (markus)
* NUTCH-993 NullPointerException at FetcherOutputFormat.checkOutputSpecs (Christian Guegi via jnioche)
diff --git a/src/java/org/apache/nutch/scoring/webgraph/WebGraph.java b/src/java/org/apache/nutch/scoring/webgraph/WebGraph.java
index 9c9e211e4..89fd52e38 100644
--- a/src/java/org/apache/nutch/scoring/webgraph/WebGraph.java
+++ b/src/java/org/apache/nutch/scoring/webgraph/WebGraph.java
@@ -451,18 +451,19 @@ public class WebGraph
// lock an existing webgraphdb to prevent multiple simultaneous updates
Path lock = new Path(webGraphDb, LOCK_NAME);
- boolean webGraphDbExists = fs.exists(webGraphDb);
- if (webGraphDbExists) {
- LockUtil.createLockFile(fs, lock, false);
- }
- else {
-
- // if the webgraph doesn't exist, create it
+ if (!fs.exists(webGraphDb)) {
fs.mkdirs(webGraphDb);
}
+ LockUtil.createLockFile(fs, lock, false);
+
// outlink and temp outlink database paths
Path outlinkDb = new Path(webGraphDb, OUTLINK_DIR);
+
+ if (!fs.exists(outlinkDb)) {
+ fs.mkdirs(outlinkDb);
+ }
+
Path tempOutlinkDb = new Path(outlinkDb + "-"
+ Integer.toString(new Random().nextInt(Integer.MAX_VALUE)));
JobConf outlinkJob = new NutchJob(conf);
@@ -480,10 +481,8 @@ public class WebGraph
}
// add the existing webgraph
- if (webGraphDbExists) {
- LOG.info("OutlinkDb: adding input: " + outlinkDb);
- FileInputFormat.addInputPath(outlinkJob, outlinkDb);
- }
+ LOG.info("OutlinkDb: adding input: " + outlinkDb);
+ FileInputFormat.addInputPath(outlinkJob, outlinkDb);
outlinkJob.setInputFormat(SequenceFileInputFormat.class);
outlinkJob.setMapperClass(OutlinkDb.class);