Apache Nutch is an extensible and scalable web crawler
Removed all in one Crawl class (NUTCH-1621)
Julien Nioched3f2dd1bbad7
diff --git a/CHANGES.txt b/CHANGES.txtindex 73095c4d0..04cbb8282 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -2,6 +2,8 @@ Nutch Change LogNutch Development Trunk+* NUTCH-1621 Remove deprecated class o.a.n.crawl.Crawler (Rui Gao via jnioche)+* NUTCH-656 Generic Deduplicator (jnioche, snagel)* NUTCH-1100 Avoid NPE in SOLRDedup (markus)diff --git a/src/bin/nutch b/src/bin/nutchindex fa7cba1ba..b1c203a8d 100755--- a/src/bin/nutch+++ b/src/bin/nutch@@ -47,7 +47,6 @@ doneif [ $# = 0 ]; thenecho "Usage: nutch COMMAND"echo "where COMMAND is one of:"- echo " crawl one-step crawler for intranets (DEPRECATED - USE CRAWL SCRIPT INSTEAD)"echo " readdb read / dump crawl db"echo " mergedb merge crawldb-s, with optional filtering"echo " readlinkdb read / dump link db"@@ -193,7 +192,8 @@ fi# figure out which class to runif [ "$COMMAND" = "crawl" ] ; then- CLASS=org.apache.nutch.crawl.Crawl+ echo "Command $COMMAND is deprecated, please use bin/crawl instead"+ exit -1elif [ "$COMMAND" = "inject" ] ; thenCLASS=org.apache.nutch.crawl.Injectorelif [ "$COMMAND" = "generate" ] ; thendiff --git a/src/java/org/apache/nutch/crawl/Crawl.java b/src/java/org/apache/nutch/crawl/Crawl.javadeleted file mode 100644index aaf6e2274..000000000--- a/src/java/org/apache/nutch/crawl/Crawl.java+++ /dev/null@@ -1,171 +0,0 @@-/**- * Licensed to the Apache Software Foundation (ASF) under one or more- * contributor license agreements. See the NOTICE file distributed with- * this work for additional information regarding copyright ownership.- * The ASF licenses this file to You under the Apache License, Version 2.0- * (the "License"); you may not use this file except in compliance with- * the License. You may obtain a copy of the License at- *- * http://www.apache.org/licenses/LICENSE-2.0- *- * Unless required by applicable law or agreed to in writing, software- * distributed under the License is distributed on an "AS IS" BASIS,- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.- * See the License for the specific language governing permissions and- * limitations under the License.- */--package org.apache.nutch.crawl;--import java.util.*;-import java.text.*;--// Commons Logging imports-import org.apache.commons.lang.StringUtils;-import org.slf4j.Logger;-import org.slf4j.LoggerFactory;--import org.apache.hadoop.fs.*;-import org.apache.hadoop.conf.*;-import org.apache.hadoop.mapred.*;-import org.apache.hadoop.util.Tool;-import org.apache.hadoop.util.ToolRunner;-import org.apache.nutch.parse.ParseSegment;-import org.apache.nutch.indexer.IndexingJob;-import org.apache.nutch.indexer.solr.SolrDeleteDuplicates;-import org.apache.nutch.util.HadoopFSUtil;-import org.apache.nutch.util.NutchConfiguration;-import org.apache.nutch.util.NutchJob;--import org.apache.nutch.fetcher.Fetcher;--public class Crawl extends Configured implements Tool {- public static final Logger LOG = LoggerFactory.getLogger(Crawl.class);-- private static String getDate() {- return new SimpleDateFormat("yyyyMMddHHmmss").format- (new Date(System.currentTimeMillis()));- }--- /* Perform complete crawling and indexing (to Solr) given a set of root urls and the -solr- parameter respectively. More information and Usage parameters can be found below. */- public static void main(String args[]) throws Exception {- Configuration conf = NutchConfiguration.create();- int res = ToolRunner.run(conf, new Crawl(), args);- System.exit(res);- }-- @Override- public int run(String[] args) throws Exception {- if (args.length < 1) {- System.out.println- ("Usage: Crawl <urlDir> -solr <solrURL> [-dir d] [-threads n] [-depth i] [-topN N]");- return -1;- }- Path rootUrlDir = null;- Path dir = new Path("crawl-" + getDate());- int threads = getConf().getInt("fetcher.threads.fetch", 10);- int depth = 5;- long topN = Long.MAX_VALUE;- String solrUrl = null;-- for (int i = 0; i < args.length; i++) {- if ("-dir".equals(args[i])) {- dir = new Path(args[i+1]);- i++;- } else if ("-threads".equals(args[i])) {- threads = Integer.parseInt(args[i+1]);- i++;- } else if ("-depth".equals(args[i])) {- depth = Integer.parseInt(args[i+1]);- i++;- } else if ("-topN".equals(args[i])) {- topN = Integer.parseInt(args[i+1]);- i++;- } else if ("-solr".equals(args[i])) {- solrUrl = args[i + 1];- i++;- } else if (args[i] != null) {- rootUrlDir = new Path(args[i]);- }- }-- JobConf job = new NutchJob(getConf());-- if (solrUrl == null) {- LOG.warn("solrUrl is not set, indexing will be skipped...");- }- else {- // for simplicity assume that SOLR is used- // and pass its URL via conf- getConf().set("solr.server.url", solrUrl);- }-- FileSystem fs = FileSystem.get(job);-- if (LOG.isInfoEnabled()) {- LOG.info("crawl started in: " + dir);- LOG.info("rootUrlDir = " + rootUrlDir);- LOG.info("threads = " + threads);- LOG.info("depth = " + depth);- LOG.info("solrUrl=" + solrUrl);- if (topN != Long.MAX_VALUE)- LOG.info("topN = " + topN);- }-- Path crawlDb = new Path(dir + "/crawldb");- Path linkDb = new Path(dir + "/linkdb");- Path segments = new Path(dir + "/segments");- Path indexes = new Path(dir + "/indexes");- Path index = new Path(dir + "/index");-- Path tmpDir = job.getLocalPath("crawl"+Path.SEPARATOR+getDate());- Injector injector = new Injector(getConf());- Generator generator = new Generator(getConf());- Fetcher fetcher = new Fetcher(getConf());- ParseSegment parseSegment = new ParseSegment(getConf());- CrawlDb crawlDbTool = new CrawlDb(getConf());- LinkDb linkDbTool = new LinkDb(getConf());-- // initialize crawlDb- injector.inject(crawlDb, rootUrlDir);- int i;- for (i = 0; i < depth; i++) { // generate new segment- Path[] segs = generator.generate(crawlDb, segments, -1, topN, System- .currentTimeMillis());- if (segs == null) {- LOG.info("Stopping at depth=" + i + " - no more URLs to fetch.");- break;- }- fetcher.fetch(segs[0], threads); // fetch it- if (!Fetcher.isParsing(job)) {- parseSegment.parse(segs[0]); // parse it, if needed- }- crawlDbTool.update(crawlDb, segs, true, true); // update crawldb- }- if (i > 0) {- linkDbTool.invert(linkDb, segments, true, true, false); // invert links-- if (solrUrl != null) {- // index, dedup & merge- FileStatus[] fstats = fs.listStatus(segments, HadoopFSUtil.getPassDirectoriesFilter(fs));-- IndexingJob indexer = new IndexingJob(getConf());- indexer.index(crawlDb, linkDb,- Arrays.asList(HadoopFSUtil.getPaths(fstats)));-- SolrDeleteDuplicates dedup = new SolrDeleteDuplicates();- dedup.setConf(getConf());- dedup.dedup(solrUrl);- }-- } else {- LOG.warn("No URLs to fetch - check your seed list and URL filters.");- }- if (LOG.isInfoEnabled()) { LOG.info("crawl finished: " + dir); }- return 0;- }---}