Apache Nutch is an extensible and scalable web crawler
Adding DOAP for Nutch. Contributed by Chris Mattmann.
Douglass Cuttinga8a7c5092359
diff --git a/site/doap.rdf b/site/doap.rdfnew file mode 100644index 000000000..4b328951f--- /dev/null+++ b/site/doap.rdf@@ -0,0 +1,47 @@+<?xml version="1.0"?>+<?xml-stylesheet type="text/xsl"?>+<rdf:RDF xml:lang="en"+ xmlns="http://usefulinc.com/ns/doap#"+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"+ xmlns:asfext="http://projects.apache.org/ns/asfext#"+ xmlns:foaf="http://xmlns.com/foaf/0.1/">+<!--+ =======================================================================++ Copyright (c) 2006 The Apache Software Foundation.+ All rights reserved.++ =======================================================================+-->+ <Project rdf:about="http://lucene.apache.org/nutch/">+ <created>2006-02-28</created>+ <license rdf:resource="http://usefulinc.com/doap/licenses/asl20" />+ <name>Apache Nutch</name>+ <homepage rdf:resource="http://lucene.apache.org/nutch/" />+ <asfext:pmc rdf:resource="http://lucene.apache.org" />+ <shortdesc>Nutch is the open-source search engine.</shortdesc>+ <description>Nutch is open source web-search software. It builds+ on Lucene Java and Hadoop, adding web-specifics, such as a+ crawler, a link-graph database, parsers for HTML and other+ document formats, etc.+ </description>+ <bug-database rdf:resource="http://issues.apache.org/jira/browse/NUTCH" />+ <mailing-list rdf:resource="http://lucene.apache.org/nutch/mailing_lists.html" />+ <download-page rdf:resource="http://www.apache.org/dyn/closer.cgi/lucene/nutch/" />+ <programming-language>Java</programming-language>+ <category rdf:resource="http://projects.apache.org/category/web-framework" />+ <release>+ <Version>+ <name>0.7</name>+ <created>2005-08-17</created>+ <revision>0.7</revision>+ </Version>+ </release>+ <repository>+ <SVNRepository>+ <location rdf:resource="http://svn.apache.org/repos/asf/lucene/nutch/"/>+ <browse rdf:resource="http://svn.apache.org/viewcvs.cgi/lucene/nutch/"/>+ </SVNRepository>+ </repository>+ </Project>+</rdf:RDF>diff --git a/src/java/org/apache/nutch/crawl/Crawl.java b/src/java/org/apache/nutch/crawl/Crawl.javaindex 47abd5a4b..c3dfac5cf 100644--- a/src/java/org/apache/nutch/crawl/Crawl.java+++ b/src/java/org/apache/nutch/crawl/Crawl.java@@ -44,11 +44,11 @@ public class Crawl {/* Perform complete crawling and indexing given a set of root urls. */- public static void main(String args[]) throws Exception {+ public static boolean doMain(String args[]) throws Exception {if (args.length < 1) {System.out.println("Usage: Crawl <urlDir> [-dir d] [-threads n] [-depth i] [-topN N]");- return;+ return false;}Configuration conf = NutchConfiguration.create();@@ -122,5 +122,22 @@ public class Crawl {new IndexMerger(fs, fs.listFiles(indexes), index, tmpDir, job).merge();LOG.info("crawl finished: " + dir);++ return true;+ }++ /**+ * main() wrapper that returns proper exit status+ */+ public static void main(String[] args) {+ Runtime rt = Runtime.getRuntime();+ try {+ boolean status = doMain(args);+ rt.exit(status ? 0 : 1);+ }+ catch (Exception e) {+ LOG.log(Level.SEVERE, "error, caught Exception in main()", e);+ rt.exit(1);+ }}}diff --git a/src/java/org/apache/nutch/crawl/CrawlDb.java b/src/java/org/apache/nutch/crawl/CrawlDb.javaindex 2bce1a98c..dd1806e9c 100644--- a/src/java/org/apache/nutch/crawl/CrawlDb.java+++ b/src/java/org/apache/nutch/crawl/CrawlDb.java@@ -90,17 +90,31 @@ public class CrawlDb extends Configured {fs.delete(old);}- public static void main(String[] args) throws Exception {+ public static boolean doMain(String[] args) throws Exception {CrawlDb crawlDb = new CrawlDb(NutchConfiguration.create());if (args.length < 2) {System.err.println("Usage: <crawldb> <segment>");- return;+ return false;}crawlDb.update(new File(args[0]), new File(args[1]));- }-+ return true;+ }+ /**+ * main() wrapper that returns proper exit status+ */+ public static void main(String[] args) {+ Runtime rt = Runtime.getRuntime();+ try {+ boolean status = doMain(args);+ rt.exit(status ? 0 : 1);+ }+ catch (Exception e) {+ LOG.log(Level.SEVERE, "error, caught Exception in main()", e);+ rt.exit(1);+ }+ }}diff --git a/src/java/org/apache/nutch/crawl/CrawlDbReader.java b/src/java/org/apache/nutch/crawl/CrawlDbReader.javaindex a4fa9009b..6fbec7ccd 100644--- a/src/java/org/apache/nutch/crawl/CrawlDbReader.java+++ b/src/java/org/apache/nutch/crawl/CrawlDbReader.java@@ -20,7 +20,7 @@ import java.io.File;import java.io.IOException;import java.util.Iterator;import java.util.TreeMap;-import java.util.logging.Logger;+import java.util.logging.*;import org.apache.hadoop.fs.FileSystem;import org.apache.hadoop.io.LongWritable;@@ -241,7 +241,7 @@ public class CrawlDbReader {JobClient.runJob(job);}- public static void main(String[] args) throws IOException {+ public static boolean doMain(String[] args) throws IOException {CrawlDbReader dbr = new CrawlDbReader();if (args.length < 1) {@@ -250,7 +250,7 @@ public class CrawlDbReader {System.err.println("\t-stats\tprint overall statistics to System.out");System.err.println("\t-dump <out_dir>\tdump the whole db to a text file in <out_dir>");System.err.println("\t-url <url>\tprint information on <url> to System.out");- return;+ return false;}String param = null;String crawlDb = args[0];@@ -266,8 +266,24 @@ public class CrawlDbReader {dbr.readUrl(crawlDb, param, conf);} else {System.err.println("\nError: wrong argument " + args[i]);+ return false;}}- return;+ return true;+ }++ /**+ * main() wrapper that returns proper exit status+ */+ public static void main(String[] args) {+ Runtime rt = Runtime.getRuntime();+ try {+ boolean status = doMain(args);+ rt.exit(status ? 0 : -1);+ }+ catch (Exception e) {+ LOG.log(Level.SEVERE, "error, caught Exception in main()", e);+ rt.exit(-1);+ }}}diff --git a/src/java/org/apache/nutch/crawl/Generator.java b/src/java/org/apache/nutch/crawl/Generator.javaindex 19ce50ac4..3c315bd57 100644--- a/src/java/org/apache/nutch/crawl/Generator.java+++ b/src/java/org/apache/nutch/crawl/Generator.java@@ -237,10 +237,10 @@ public class Generator extends Configured {/*** Generate a fetchlist from the pagedb and linkdb*/- public static void main(String args[]) throws Exception {+ public static boolean doMain(String args[]) throws Exception {if (args.length < 2) {System.out.println("Usage: Generator <crawldb> <segments_dir> [-topN N] [-numFetchers numFetchers] [-adddays numDays]");- return;+ return false;}File dbDir = new File(args[0]);@@ -266,5 +266,22 @@ public class Generator extends Configured {LOG.info("topN: " + topN);Generator gen = new Generator(NutchConfiguration.create());gen.generate(dbDir, segmentsDir, numFetchers, topN, curTime);++ return true;+ }++ /**+ * main() wrapper that returns proper exit status+ */+ public static void main(String[] args) {+ Runtime rt = Runtime.getRuntime();+ try {+ boolean status = doMain(args);+ rt.exit(status ? 0 : 1);+ }+ catch (Exception e) {+ LOG.log(Level.SEVERE, "error, caught Exception in main()", e);+ rt.exit(1);+ }}}diff --git a/src/java/org/apache/nutch/crawl/Injector.java b/src/java/org/apache/nutch/crawl/Injector.javaindex 673017c67..95744e8c2 100644--- a/src/java/org/apache/nutch/crawl/Injector.java+++ b/src/java/org/apache/nutch/crawl/Injector.java@@ -127,15 +127,31 @@ public class Injector extends Configured {}- public static void main(String[] args) throws Exception {+ public static boolean doMain(String[] args) throws Exception {Injector injector = new Injector(NutchConfiguration.create());if (args.length < 2) {System.err.println("Usage: Injector <crawldb> <url_dir>");- return;+ return false;}injector.inject(new File(args[0]), new File(args[1]));++ return true;}+ /**+ * main() wrapper that returns proper exit status+ */+ public static void main(String[] args) {+ Runtime rt = Runtime.getRuntime();+ try {+ boolean status = doMain(args);+ rt.exit(status ? 0 : 1);+ }+ catch (Exception e) {+ LOG.log(Level.SEVERE, "error, caught Exception in main()", e);+ rt.exit(1);+ }+ }}diff --git a/src/java/org/apache/nutch/crawl/LinkDbReader.java b/src/java/org/apache/nutch/crawl/LinkDbReader.javaindex 9cf550397..f2c53386e 100644--- a/src/java/org/apache/nutch/crawl/LinkDbReader.java+++ b/src/java/org/apache/nutch/crawl/LinkDbReader.java@@ -29,7 +29,7 @@ import org.apache.hadoop.conf.Configuration;import org.apache.nutch.util.NutchConfiguration;import org.apache.nutch.util.NutchJob;-import java.util.logging.Logger;+import java.util.logging.*;/** . */public class LinkDbReader implements Closeable {@@ -96,12 +96,12 @@ public class LinkDbReader implements Closeable {JobClient.runJob(job);}- public static void main(String[] args) throws Exception {+ public static boolean doMain(String[] args) throws Exception {if (args.length < 2) {System.err.println("LinkDbReader <linkdb> {-dump <out_dir> | -url <url>)");System.err.println("\t-dump <out_dir>\tdump whole link db to a text file in <out_dir>");System.err.println("\t-url <url>\tprint information about <url> to System.out");- return;+ return false;}Configuration conf = NutchConfiguration.create();if (args[1].equals("-dump")) {@@ -118,7 +118,24 @@ public class LinkDbReader implements Closeable {}} else {System.err.println("Error: wrong argument " + args[1]);- return;+ return false;+ }++ return true;+ }++ /**+ * main() wrapper that returns proper exit status+ */+ public static void main(String[] args) {+ Runtime rt = Runtime.getRuntime();+ try {+ boolean status = doMain(args);+ rt.exit(status ? 0 : 1);+ }+ catch (Exception e) {+ LOG.log(Level.SEVERE, "error, caught Exception in main()", e);+ rt.exit(1);}}}diff --git a/src/java/org/apache/nutch/fetcher/Fetcher.java b/src/java/org/apache/nutch/fetcher/Fetcher.javaindex 387029d88..967ce5f01 100644--- a/src/java/org/apache/nutch/fetcher/Fetcher.java+++ b/src/java/org/apache/nutch/fetcher/Fetcher.java@@ -369,13 +369,13 @@ public class Fetcher extends Configured implements MapRunnable {/** Run the fetcher. */- public static void main(String[] args) throws Exception {+ public static boolean doMain(String[] args) throws Exception {String usage = "Usage: Fetcher <segment> [-threads n] [-noParsing]";if (args.length < 1) {System.err.println(usage);- System.exit(-1);+ return false;}File segment = new File(args[0]);@@ -399,5 +399,21 @@ public class Fetcher extends Configured implements MapRunnable {fetcher.fetch(segment, threads, parsing); // run the Fetcher+ return true;+ }++ /**+ * main() wrapper that returns proper exit status+ */+ public static void main(String[] args) {+ Runtime rt = Runtime.getRuntime();+ try {+ boolean status = doMain(args);+ rt.exit(status ? 0 : 1);+ }+ catch (Exception e) {+ LOG.log(Level.SEVERE, "error, caught Exception in main()", e);+ rt.exit(1);+ }}}diff --git a/src/java/org/apache/nutch/indexer/DeleteDuplicates.java b/src/java/org/apache/nutch/indexer/DeleteDuplicates.javaindex 9c9b7adf7..5ef6d203a 100644--- a/src/java/org/apache/nutch/indexer/DeleteDuplicates.java+++ b/src/java/org/apache/nutch/indexer/DeleteDuplicates.java@@ -342,12 +342,12 @@ public class DeleteDuplicates extends ConfiguredLOG.info("Dedup: done");}- public static void main(String[] args) throws Exception {+ public static boolean doMain(String[] args) throws Exception {DeleteDuplicates dedup = new DeleteDuplicates(NutchConfiguration.create());if (args.length < 1) {System.err.println("Usage: <indexes> ...");- return;+ return false;}File[] indexes = new File[args.length];@@ -356,6 +356,22 @@ public class DeleteDuplicates extends Configured}dedup.dedup(indexes);++ return true;}+ /**+ * main() wrapper that returns proper exit status+ */+ public static void main(String[] args) {+ Runtime rt = Runtime.getRuntime();+ try {+ boolean status = doMain(args);+ rt.exit(status ? 0 : 1);+ }+ catch (Exception e) {+ LOG.log(Level.SEVERE, "error, caught Exception in main()", e);+ rt.exit(1);+ }+ }}diff --git a/src/java/org/apache/nutch/indexer/IndexMerger.java b/src/java/org/apache/nutch/indexer/IndexMerger.javaindex ed7d1cec2..0104b0701 100644--- a/src/java/org/apache/nutch/indexer/IndexMerger.java+++ b/src/java/org/apache/nutch/indexer/IndexMerger.java@@ -105,11 +105,11 @@ public class IndexMerger {/*** Create an index for the input files in the named directory.*/- public static void main(String[] args) throws Exception {+ public static boolean doMain(String[] args) throws Exception {String usage = "IndexMerger [-workingdir <workingdir>] outputIndex indexesDir...";if (args.length < 2) {System.err.println("Usage: " + usage);- return;+ return false;}//@@ -148,5 +148,22 @@ public class IndexMerger {merger.merge();LOG.info("done merging");FileUtil.fullyDelete(workDir, conf);++ return true;+ }++ /**+ * main() wrapper that returns proper exit status+ */+ public static void main(String[] args) {+ Runtime rt = Runtime.getRuntime();+ try {+ boolean status = doMain(args);+ rt.exit(status ? 0 : 1);+ }+ catch (Exception e) {+ LOG.log(Level.SEVERE, "error, caught Exception in main()", e);+ rt.exit(1);+ }}}diff --git a/src/java/org/apache/nutch/indexer/Indexer.java b/src/java/org/apache/nutch/indexer/Indexer.javaindex c4937131d..9575397e8 100644--- a/src/java/org/apache/nutch/indexer/Indexer.java+++ b/src/java/org/apache/nutch/indexer/Indexer.java@@ -269,12 +269,12 @@ public class Indexer extends Configured implements Reducer {LOG.info("Indexer: done");}- public static void main(String[] args) throws Exception {+ public static boolean doMain(String[] args) throws Exception {Indexer indexer = new Indexer(NutchConfiguration.create());if (args.length < 4) {System.err.println("Usage: <index> <crawldb> <linkdb> <segment> ...");- return;+ return false;}File[] segments = new File[args.length-3];@@ -284,6 +284,22 @@ public class Indexer extends Configured implements Reducer {indexer.index(new File(args[0]), new File(args[1]), new File(args[2]),segments);++ return true;}+ /**+ * main() wrapper that returns proper exit status+ */+ public static void main(String[] args) {+ Runtime rt = Runtime.getRuntime();+ try {+ boolean status = doMain(args);+ rt.exit(status ? 0 : 1);+ }+ catch (Exception e) {+ LOG.log(Level.SEVERE, "error, caught Exception in main()", e);+ rt.exit(1);+ }+ }}diff --git a/src/java/org/apache/nutch/parse/ParseSegment.java b/src/java/org/apache/nutch/parse/ParseSegment.javaindex 76dce6a9f..6709810b4 100644--- a/src/java/org/apache/nutch/parse/ParseSegment.java+++ b/src/java/org/apache/nutch/parse/ParseSegment.java@@ -104,19 +104,36 @@ public class ParseSegment extends Configured implements Mapper, Reducer {}- public static void main(String[] args) throws Exception {+ public static boolean doMain(String[] args) throws Exception {File segment;String usage = "Usage: ParseSegment segment";if (args.length == 0) {System.err.println(usage);- System.exit(-1);+ return false;}segment = new File(args[0]);ParseSegment parseSegment = new ParseSegment(NutchConfiguration.create());parseSegment.parse(segment);++ return true;+ }++ /**+ * main() wrapper that returns proper exit status+ */+ public static void main(String[] args) {+ Runtime rt = Runtime.getRuntime();+ try {+ boolean status = doMain(args);+ rt.exit(status ? 0 : 1);+ }+ catch (Exception e) {+ LOG.log(Level.SEVERE, "error, caught Exception in main()", e);+ rt.exit(1);+ }}}diff --git a/src/java/org/apache/nutch/plugin/PluginRepository.java b/src/java/org/apache/nutch/plugin/PluginRepository.javaindex c35afa039..636ffcccf 100644--- a/src/java/org/apache/nutch/plugin/PluginRepository.java+++ b/src/java/org/apache/nutch/plugin/PluginRepository.java@@ -26,7 +26,7 @@ import java.util.WeakHashMap;import java.util.Iterator;import java.util.List;import java.util.Map;-import java.util.logging.Logger;+import java.util.logging.*;import java.util.regex.Pattern;// Nutch imports@@ -400,10 +400,10 @@ public class PluginRepository {* selected class.* @throws Exception*/- public static void main(String[] args) throws Exception {+ public static boolean doMain(String[] args) throws Exception {if (args.length < 2) {System.err.println("Usage: PluginRepository pluginId className [arg1 arg2 ...]");- return;+ return false;}Configuration conf = NutchConfiguration.create();PluginRepository repo = new PluginRepository(conf);@@ -411,7 +411,7 @@ public class PluginRepository {PluginDescriptor d = repo.getPluginDescriptor(args[0]);if (d == null) {System.err.println("Plugin '" + args[0] + "' not present or inactive.");- return;+ return false;}ClassLoader cl = d.getClassLoader();// args[1] - class name@@ -420,17 +420,34 @@ public class PluginRepository {clazz = Class.forName(args[1], true, cl);} catch (Exception e) {System.err.println("Could not load the class '" + args[1] + ": " + e.getMessage());- return;+ return false;}Method m = null;try {m = clazz.getMethod("main", new Class[]{args.getClass()});} catch (Exception e) {System.err.println("Could not find the 'main(String[])' method in class " + args[1] + ": " + e.getMessage());- return;+ return false;}String[] subargs = new String[args.length - 2];System.arraycopy(args, 2, subargs, 0, subargs.length);m.invoke(null, new Object[]{subargs});++ return true;+ }++ /**+ * main() wrapper that returns proper exit status+ */+ public static void main(String[] args) {+ Runtime rt = Runtime.getRuntime();+ try {+ boolean status = doMain(args);+ rt.exit(status ? 0 : 1);+ }+ catch (Exception e) {+ LOG.log(Level.SEVERE, "error, caught Exception in main()", e);+ rt.exit(1);}+ }}diff --git a/src/java/org/apache/nutch/searcher/DistributedSearch.java b/src/java/org/apache/nutch/searcher/DistributedSearch.javaindex 839943f0f..928ddd635 100644--- a/src/java/org/apache/nutch/searcher/DistributedSearch.java+++ b/src/java/org/apache/nutch/searcher/DistributedSearch.java@@ -19,7 +19,7 @@ package org.apache.nutch.searcher;import java.net.InetSocketAddress;import java.io.*;import java.util.*;-import java.util.logging.Logger;+import java.util.logging.*;import java.lang.reflect.Method;import org.apache.nutch.parse.ParseData;@@ -53,12 +53,12 @@ public class DistributedSearch {private Server() {}/** Runs a search server. */- public static void main(String[] args) throws Exception {+ public static boolean doMain(String[] args) throws Exception {String usage = "DistributedSearch$Server <port> <index dir>";if (args.length == 0 || args.length > 2) {System.err.println(usage);- System.exit(-1);+ return false;}int port = Integer.parseInt(args[0]);@@ -70,8 +70,24 @@ public class DistributedSearch {org.apache.hadoop.ipc.Server server = RPC.getServer(bean, port, 10, true, conf);server.start();server.join();++ return true;}+ /**+ * main() wrapper that returns proper exit status+ */+ public static void main(String[] args) {+ Runtime rt = Runtime.getRuntime();+ try {+ boolean status = doMain(args);+ rt.exit(status ? 0 : 1);+ }+ catch (Exception e) {+ LOG.log(Level.SEVERE, "error, caught Exception in main()", e);+ rt.exit(1);+ }+ }}/** The search client. */@@ -311,12 +327,12 @@ public class DistributedSearch {return getRemote(hit).getFetchDate(hit);}- public static void main(String[] args) throws Exception {+ public static boolean doMain(String[] args) throws Exception {String usage = "DistributedSearch$Client query <host> <port> ...";if (args.length == 0) {System.err.println(usage);- System.exit(-1);+ return false;}Query query = Query.parse(args[0], NutchConfiguration.create());@@ -336,6 +352,7 @@ public class DistributedSearch {System.out.println(" "+i+" "+ client.getDetails(hits.getHit(i)));}+ return true;}public void run() {@@ -362,5 +379,20 @@ public class DistributedSearch {running = false;interrupt();}++ /**+ * main() wrapper that returns proper exit status+ */+ public static void main(String[] args) {+ Runtime rt = Runtime.getRuntime();+ try {+ boolean status = doMain(args);+ rt.exit(status ? 0 : 1);+ }+ catch (Exception e) {+ LOG.log(Level.SEVERE, "error, caught Exception in main()", e);+ rt.exit(1);+ }+ }}}diff --git a/src/java/org/apache/nutch/segment/SegmentReader.java b/src/java/org/apache/nutch/segment/SegmentReader.javaindex ba320e1b8..d815d011f 100644--- a/src/java/org/apache/nutch/segment/SegmentReader.java+++ b/src/java/org/apache/nutch/segment/SegmentReader.java@@ -25,7 +25,7 @@ import java.io.OutputStreamWriter;import java.io.PrintStream;import java.io.PrintWriter;import java.util.Iterator;-import java.util.logging.Logger;+import java.util.logging.*;import org.apache.nutch.crawl.CrawlDatum;import org.apache.hadoop.fs.FileSystem;@@ -221,7 +221,7 @@ public class SegmentReader extends Configured implements Reducer {}}- public static void main(String[] args) throws Exception {+ public static boolean doMain(String[] args) throws Exception {Configuration conf = NutchConfiguration.create();SegmentReader segmentReader = new SegmentReader(conf);@@ -229,8 +229,25 @@ public class SegmentReader extends Configured implements Reducer {if (args.length == 0) {System.err.println(usage);- System.exit(-1);+ return false;}segmentReader.reader(new File(args[0]));++ return true;+ }++ /**+ * main() wrapper that returns proper exit status+ */+ public static void main(String[] args) {+ Runtime rt = Runtime.getRuntime();+ try {+ boolean status = doMain(args);+ rt.exit(status ? 0 : 1);+ }+ catch (Exception e) {+ LOG.log(Level.SEVERE, "error, caught Exception in main()", e);+ rt.exit(1);+ }}}