Apache Nutch is an extensible and scalable web crawler
- fix for NUTCH-838 Add timing information to all Tool classes
Chris Mattmann3bf7de69a6ab
diff --git a/CHANGES.txt b/CHANGES.txtindex 35390f22a..31df0ddc6 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -2,6 +2,8 @@ Nutch Change LogRelease 2.0 - Current Development+* NUTCH-838 Add timing information to all Tool classes (Jeroen van Vianen, mattmann)+* NUTCH-837 Remove search servers and Lucene dependencies (ab)* NUTCH-836 Remove deprecated parse plugins (jnioche)diff --git a/conf/log4j.properties b/conf/log4j.propertiesindex 80b54e76a..2aa8eab62 100644--- a/conf/log4j.properties+++ b/conf/log4j.properties@@ -22,6 +22,8 @@ log4j.logger.org.apache.nutch.segment.SegmentMerger=INFO,cmdstdoutlog4j.logger.org.apache.nutch.crawl.CrawlDb=INFO,cmdstdoutlog4j.logger.org.apache.nutch.crawl.LinkDb=INFO,cmdstdoutlog4j.logger.org.apache.nutch.crawl.LinkDbMerger=INFO,cmdstdout+log4j.logger.org.apache.nutch.indexer.solr.SolrIndexer=INFO,cmdstdout+log4j.logger.org.apache.nutch.indexer.solr.SolrDeleteDuplicates=INFO,cmdstdoutlog4j.logger.org.apache.nutch=INFOlog4j.logger.org.apache.hadoop=WARNdiff --git a/src/java/org/apache/nutch/crawl/CrawlDb.java b/src/java/org/apache/nutch/crawl/CrawlDb.javaindex 07cac53d2..4d144545b 100644--- a/src/java/org/apache/nutch/crawl/CrawlDb.java+++ b/src/java/org/apache/nutch/crawl/CrawlDb.java@@ -18,6 +18,7 @@package org.apache.nutch.crawl;import java.io.*;+import java.text.SimpleDateFormat;import java.util.*;// Commons Logging imports@@ -34,6 +35,7 @@ import org.apache.nutch.util.HadoopFSUtil;import org.apache.nutch.util.LockUtil;import org.apache.nutch.util.NutchConfiguration;import org.apache.nutch.util.NutchJob;+import org.apache.nutch.util.TimingUtil;/*** This class takes the output of the fetcher and updates the@@ -63,8 +65,10 @@ public class CrawlDb extends Configured implements Tool {FileSystem fs = FileSystem.get(getConf());Path lock = new Path(crawlDb, LOCK_NAME);LockUtil.createLockFile(fs, lock, force);+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");+ long start = System.currentTimeMillis();if (LOG.isInfoEnabled()) {- LOG.info("CrawlDb update: starting");+ LOG.info("CrawlDb update: starting at " + sdf.format(start));LOG.info("CrawlDb update: db: " + crawlDb);LOG.info("CrawlDb update: segments: " + Arrays.asList(segments));LOG.info("CrawlDb update: additions allowed: " + additionsAllowed);@@ -100,7 +104,8 @@ public class CrawlDb extends Configured implements Tool {}CrawlDb.install(job, crawlDb);- if (LOG.isInfoEnabled()) { LOG.info("CrawlDb update: done"); }+ long end = System.currentTimeMillis();+ LOG.info("CrawlDb update: finished at " + sdf.format(end) + ", elapsed: " + TimingUtil.elapsedTime(start, end));}public static JobConf createJob(Configuration config, Path crawlDb)diff --git a/src/java/org/apache/nutch/crawl/CrawlDbMerger.java b/src/java/org/apache/nutch/crawl/CrawlDbMerger.javaindex 35d4a8ff4..cf9a8a9f6 100644--- a/src/java/org/apache/nutch/crawl/CrawlDbMerger.java+++ b/src/java/org/apache/nutch/crawl/CrawlDbMerger.java@@ -18,6 +18,7 @@package org.apache.nutch.crawl;import java.io.IOException;+import java.text.SimpleDateFormat;import java.util.*;import java.util.Map.Entry;@@ -35,6 +36,7 @@ import org.apache.hadoop.util.*;import org.apache.hadoop.conf.*;import org.apache.nutch.util.NutchConfiguration;import org.apache.nutch.util.NutchJob;+import org.apache.nutch.util.TimingUtil;/*** This tool merges several CrawlDb-s into one, optionally filtering@@ -112,6 +114,10 @@ public class CrawlDbMerger extends Configured implements Tool {}public void merge(Path output, Path[] dbs, boolean normalize, boolean filter) throws Exception {+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");+ long start = System.currentTimeMillis();+ LOG.info("CrawlDb merge: starting at " + sdf.format(start));+JobConf job = createMergeJob(getConf(), output, normalize, filter);for (int i = 0; i < dbs.length; i++) {FileInputFormat.addInputPath(job, new Path(dbs[i], CrawlDb.CURRENT_NAME));@@ -120,6 +126,8 @@ public class CrawlDbMerger extends Configured implements Tool {FileSystem fs = FileSystem.get(getConf());fs.mkdirs(output);fs.rename(FileOutputFormat.getOutputPath(job), new Path(output, CrawlDb.CURRENT_NAME));+ long end = System.currentTimeMillis();+ LOG.info("CrawlDb merge: finished at " + sdf.format(end) + ", elapsed: " + TimingUtil.elapsedTime(start, end));}public static JobConf createMergeJob(Configuration conf, Path output, boolean normalize, boolean filter) {diff --git a/src/java/org/apache/nutch/crawl/Generator.java b/src/java/org/apache/nutch/crawl/Generator.javaindex 60bf6e452..90a0f7fb2 100644--- a/src/java/org/apache/nutch/crawl/Generator.java+++ b/src/java/org/apache/nutch/crawl/Generator.java@@ -44,6 +44,7 @@ import org.apache.nutch.scoring.ScoringFilters;import org.apache.nutch.util.LockUtil;import org.apache.nutch.util.NutchConfiguration;import org.apache.nutch.util.NutchJob;+import org.apache.nutch.util.TimingUtil;import org.apache.nutch.util.URLUtil;/**@@ -472,8 +473,10 @@ public class Generator extends Configured implements Tool {FileSystem fs = FileSystem.get(getConf());LockUtil.createLockFile(fs, lock, force);+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");+ long start = System.currentTimeMillis();+ LOG.info("Generator: starting at " + sdf.format(start));LOG.info("Generator: Selecting best-scoring urls due for fetch.");- LOG.info("Generator: starting");LOG.info("Generator: filtering: " + filter);LOG.info("Generator: normalizing: " + norm);if (topN != Long.MAX_VALUE) {@@ -586,9 +589,8 @@ public class Generator extends Configured implements Tool {LockUtil.removeLockFile(fs, lock);fs.delete(tempDir, true);- if (LOG.isInfoEnabled()) {- LOG.info("Generator: done.");- }+ long end = System.currentTimeMillis();+ LOG.info("Generator: finished at " + sdf.format(end) + ", elapsed: " + TimingUtil.elapsedTime(start, end));Path[] patharray = new Path[generatedSegments.size()];return generatedSegments.toArray(patharray);diff --git a/src/java/org/apache/nutch/crawl/Injector.java b/src/java/org/apache/nutch/crawl/Injector.javaindex 216369d6c..fdce53029 100644--- a/src/java/org/apache/nutch/crawl/Injector.java+++ b/src/java/org/apache/nutch/crawl/Injector.java@@ -18,6 +18,7 @@package org.apache.nutch.crawl;import java.io.*;+import java.text.SimpleDateFormat;import java.util.*;// Commons Logging imports@@ -35,6 +36,7 @@ import org.apache.nutch.scoring.ScoringFilterException;import org.apache.nutch.scoring.ScoringFilters;import org.apache.nutch.util.NutchConfiguration;import org.apache.nutch.util.NutchJob;+import org.apache.nutch.util.TimingUtil;/** This class takes a flat file of URLs and adds them to the of pages to be* crawled. Useful for bootstrapping the system.@@ -79,6 +81,12 @@ public class Injector extends Configured implements Tool {OutputCollector<Text, CrawlDatum> output, Reporter reporter)throws IOException {String url = value.toString(); // value is line of text++ if (url != null && url.trim().startsWith("#")) {+ /* Ignore line that start with # */+ return;+ }+// if tabs : metadata that could be stored// must be name=value and separated by \tfloat customScore = -1f;@@ -182,9 +190,10 @@ public class Injector extends Configured implements Tool {}public void inject(Path crawlDb, Path urlDir) throws IOException {-+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");+ long start = System.currentTimeMillis();if (LOG.isInfoEnabled()) {- LOG.info("Injector: starting");+ LOG.info("Injector: starting at " + sdf.format(start));LOG.info("Injector: crawlDb: " + crawlDb);LOG.info("Injector: urlDir: " + urlDir);}@@ -223,8 +232,9 @@ public class Injector extends Configured implements Tool {// clean upFileSystem fs = FileSystem.get(getConf());fs.delete(tempDir, true);- if (LOG.isInfoEnabled()) { LOG.info("Injector: done"); }+ long end = System.currentTimeMillis();+ LOG.info("Injector: finished at " + sdf.format(end) + ", elapsed: " + TimingUtil.elapsedTime(start, end));}public static void main(String[] args) throws Exception {diff --git a/src/java/org/apache/nutch/crawl/LinkDb.java b/src/java/org/apache/nutch/crawl/LinkDb.javaindex 7d6ea5046..5237d651a 100644--- a/src/java/org/apache/nutch/crawl/LinkDb.java+++ b/src/java/org/apache/nutch/crawl/LinkDb.java@@ -18,6 +18,7 @@package org.apache.nutch.crawl;import java.io.*;+import java.text.SimpleDateFormat;import java.util.*;import java.net.*;@@ -39,6 +40,7 @@ import org.apache.nutch.util.HadoopFSUtil;import org.apache.nutch.util.LockUtil;import org.apache.nutch.util.NutchConfiguration;import org.apache.nutch.util.NutchJob;+import org.apache.nutch.util.TimingUtil;/** Maintains an inverted link map, listing incoming links for each url. */public class LinkDb extends Configured implements Tool, Mapper<Text, ParseData, Text, Inlinks> {@@ -153,8 +155,11 @@ public class LinkDb extends Configured implements Tool, Mapper<Text, ParseData,FileSystem fs = FileSystem.get(getConf());LockUtil.createLockFile(fs, lock, force);Path currentLinkDb = new Path(linkDb, CURRENT_NAME);++ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");+ long start = System.currentTimeMillis();if (LOG.isInfoEnabled()) {- LOG.info("LinkDb: starting");+ LOG.info("LinkDb: starting at " + sdf.format(start));LOG.info("LinkDb: linkdb: " + linkDb);LOG.info("LinkDb: URL normalize: " + normalize);LOG.info("LinkDb: URL filter: " + filter);@@ -191,7 +196,9 @@ public class LinkDb extends Configured implements Tool, Mapper<Text, ParseData,fs.delete(newLinkDb, true);}LinkDb.install(job, linkDb);- if (LOG.isInfoEnabled()) { LOG.info("LinkDb: done"); }++ long end = System.currentTimeMillis();+ LOG.info("LinkDb: finished at " + sdf.format(end) + ", elapsed: " + TimingUtil.elapsedTime(start, end));}private static JobConf createJob(Configuration config, Path linkDb, boolean normalize, boolean filter) {diff --git a/src/java/org/apache/nutch/crawl/LinkDbMerger.java b/src/java/org/apache/nutch/crawl/LinkDbMerger.javaindex 7e6a83730..c50d0528a 100644--- a/src/java/org/apache/nutch/crawl/LinkDbMerger.java+++ b/src/java/org/apache/nutch/crawl/LinkDbMerger.java@@ -17,6 +17,7 @@package org.apache.nutch.crawl;import java.io.IOException;+import java.text.SimpleDateFormat;import java.util.ArrayList;import java.util.Iterator;import java.util.Random;@@ -42,6 +43,7 @@ import org.apache.hadoop.util.Tool;import org.apache.hadoop.util.ToolRunner;import org.apache.nutch.util.NutchConfiguration;import org.apache.nutch.util.NutchJob;+import org.apache.nutch.util.TimingUtil;/*** This tool merges several LinkDb-s into one, optionally filtering@@ -100,6 +102,10 @@ public class LinkDbMerger extends Configured implements Tool, Reducer<Text, Inlipublic void close() throws IOException { }public void merge(Path output, Path[] dbs, boolean normalize, boolean filter) throws Exception {+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");+ long start = System.currentTimeMillis();+ LOG.info("LinkDb merge: starting at " + sdf.format(start));+JobConf job = createMergeJob(getConf(), output, normalize, filter);for (int i = 0; i < dbs.length; i++) {FileInputFormat.addInputPath(job, new Path(dbs[i], LinkDb.CURRENT_NAME));@@ -108,6 +114,9 @@ public class LinkDbMerger extends Configured implements Tool, Reducer<Text, InliFileSystem fs = FileSystem.get(getConf());fs.mkdirs(output);fs.rename(FileOutputFormat.getOutputPath(job), new Path(output, LinkDb.CURRENT_NAME));++ long end = System.currentTimeMillis();+ LOG.info("LinkDb merge: finished at " + sdf.format(end) + ", elapsed: " + TimingUtil.elapsedTime(start, end));}public static JobConf createMergeJob(Configuration config, Path linkDb, boolean normalize, boolean filter) {diff --git a/src/java/org/apache/nutch/crawl/LinkDbReader.java b/src/java/org/apache/nutch/crawl/LinkDbReader.javaindex 0c23f8b3a..a200e5b98 100644--- a/src/java/org/apache/nutch/crawl/LinkDbReader.java+++ b/src/java/org/apache/nutch/crawl/LinkDbReader.java@@ -33,7 +33,9 @@ import org.apache.hadoop.conf.Configuration;import org.apache.nutch.util.NutchConfiguration;import org.apache.nutch.util.NutchJob;+import org.apache.nutch.util.TimingUtil;+import java.text.SimpleDateFormat;import java.util.Iterator;/** . */@@ -89,10 +91,11 @@ public class LinkDbReader extends Configured implements Tool, Closeable {}public void processDumpJob(String linkdb, String output) throws IOException {-+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");+ long start = System.currentTimeMillis();if (LOG.isInfoEnabled()) {- LOG.info("LinkDb dump: starting");- LOG.info("LinkDb db: " + linkdb);+ LOG.info("LinkDb dump: starting at " + sdf.format(start));+ LOG.info("LinkDb dump: db: " + linkdb);}Path outFolder = new Path(output);@@ -108,6 +111,9 @@ public class LinkDbReader extends Configured implements Tool, Closeable {job.setOutputValueClass(Inlinks.class);JobClient.runJob(job);++ long end = System.currentTimeMillis();+ LOG.info("LinkDb dump: finished at " + sdf.format(end) + ", elapsed: " + TimingUtil.elapsedTime(start, end));}public static void main(String[] args) throws Exception {diff --git a/src/java/org/apache/nutch/fetcher/Fetcher.java b/src/java/org/apache/nutch/fetcher/Fetcher.javaindex 164993884..840744cde 100644--- a/src/java/org/apache/nutch/fetcher/Fetcher.java+++ b/src/java/org/apache/nutch/fetcher/Fetcher.java@@ -21,6 +21,7 @@ import java.net.InetAddress;import java.net.MalformedURLException;import java.net.URL;import java.net.UnknownHostException;+import java.text.SimpleDateFormat;import java.util.*;import java.util.Map.Entry;import java.util.concurrent.atomic.AtomicInteger;@@ -1066,8 +1067,10 @@ public class Fetcher extends Configured implements Tool,checkConfiguration();+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");+ long start = System.currentTimeMillis();if (LOG.isInfoEnabled()) {- LOG.info("Fetcher: starting");+ LOG.info("Fetcher: starting at " + sdf.format(start));LOG.info("Fetcher: segment: " + segment);}@@ -1102,7 +1105,9 @@ public class Fetcher extends Configured implements Tool,job.setOutputValueClass(NutchWritable.class);JobClient.runJob(job);- if (LOG.isInfoEnabled()) { LOG.info("Fetcher: done"); }++ long end = System.currentTimeMillis();+ LOG.info("Fetcher: finished at " + sdf.format(end) + ", elapsed: " + TimingUtil.elapsedTime(start, end));}diff --git a/src/java/org/apache/nutch/fetcher/OldFetcher.java b/src/java/org/apache/nutch/fetcher/OldFetcher.javaindex 4796a4d37..583448c2d 100644--- a/src/java/org/apache/nutch/fetcher/OldFetcher.java+++ b/src/java/org/apache/nutch/fetcher/OldFetcher.java@@ -19,6 +19,7 @@ package org.apache.nutch.fetcher;import java.io.IOException;import java.net.MalformedURLException;+import java.text.SimpleDateFormat;import java.util.Map.Entry;// Commons Logging imports@@ -504,8 +505,10 @@ public class OldFetcher extends Configured implements Tool, MapRunnable<Writablepublic void fetch(Path segment, int threads)throws IOException {+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");+ long start = System.currentTimeMillis();if (LOG.isInfoEnabled()) {- LOG.info("OldFetcher: starting");+ LOG.info("OldFetcher: starting at " + sdf.format(start));LOG.info("OldFetcher: segment: " + segment);}@@ -529,7 +532,8 @@ public class OldFetcher extends Configured implements Tool, MapRunnable<Writablejob.setOutputValueClass(NutchWritable.class);JobClient.runJob(job);- if (LOG.isInfoEnabled()) { LOG.info("OldFetcher: done"); }+ long end = System.currentTimeMillis();+ LOG.info("OldFetcher: finished at " + sdf.format(end) + ", elapsed: " + TimingUtil.elapsedTime(start, end));}diff --git a/src/java/org/apache/nutch/indexer/solr/SolrDeleteDuplicates.java b/src/java/org/apache/nutch/indexer/solr/SolrDeleteDuplicates.javaindex d946512ce..8246385ff 100644--- a/src/java/org/apache/nutch/indexer/solr/SolrDeleteDuplicates.java+++ b/src/java/org/apache/nutch/indexer/solr/SolrDeleteDuplicates.java@@ -20,6 +20,7 @@ import java.io.DataInput;import java.io.DataOutput;import java.io.IOException;import java.net.MalformedURLException;+import java.text.SimpleDateFormat;import java.util.Iterator;import org.apache.commons.logging.Log;@@ -41,6 +42,7 @@ import org.apache.hadoop.util.Tool;import org.apache.hadoop.util.ToolRunner;import org.apache.nutch.util.NutchConfiguration;import org.apache.nutch.util.NutchJob;+import org.apache.nutch.util.TimingUtil;import org.apache.solr.client.solrj.SolrQuery;import org.apache.solr.client.solrj.SolrServer;import org.apache.solr.client.solrj.SolrServerException;@@ -121,14 +123,12 @@ Tool {tstamp = (Long)doc.getFieldValue(SolrConstants.TIMESTAMP_FIELD);}- @Overridepublic void readFields(DataInput in) throws IOException {id = Text.readString(in);boost = in.readFloat();tstamp = in.readLong();}- @Overridepublic void write(DataOutput out) throws IOException {Text.writeString(out, id);out.writeFloat(boost);@@ -156,23 +156,19 @@ Tool {return numDocs;}- @Overridepublic long getLength() throws IOException {return numDocs;}- @Overridepublic String[] getLocations() throws IOException {return new String[] {} ;}- @Overridepublic void readFields(DataInput in) throws IOException {docBegin = in.readInt();numDocs = in.readInt();}- @Overridepublic void write(DataOutput out) throws IOException {out.writeInt(docBegin);out.writeInt(numDocs);@@ -238,30 +234,24 @@ Tool {private int currentDoc = 0;- @Overridepublic void close() throws IOException { }- @Overridepublic Text createKey() {return new Text();}- @Overridepublic SolrRecord createValue() {return new SolrRecord();}- @Overridepublic long getPos() throws IOException {return currentDoc;}- @Overridepublic float getProgress() throws IOException {return currentDoc / (float) numDocs;}- @Overridepublic boolean next(Text key, SolrRecord value) throws IOException {if (currentDoc >= numDocs) {return false;@@ -287,17 +277,14 @@ Tool {private UpdateRequest updateRequest = new UpdateRequest();- @Overridepublic Configuration getConf() {return conf;}- @Overridepublic void setConf(Configuration conf) {this.conf = conf;}- @Overridepublic void configure(JobConf job) {try {solr = new CommonsHttpSolrServer(job.get(SolrConstants.SERVER_URL));@@ -307,10 +294,10 @@ Tool {}- @Overridepublic void close() throws IOException {try {if (numDeletes > 0) {+ LOG.info("SolrDeleteDuplicates: deleting " + numDeletes + " duplicates");updateRequest.process(solr);}} catch (SolrServerException e) {@@ -318,7 +305,6 @@ Tool {}}- @Overridepublic void reduce(Text key, Iterator<SolrRecord> values,OutputCollector<Text, SolrRecord> output, Reporter reporter)throws IOException {@@ -336,6 +322,7 @@ Tool {numDeletes++;if (numDeletes >= NUM_MAX_DELETE_REQUEST) {try {+ LOG.info("SolrDeleteDuplicates: deleting " + numDeletes + " duplicates");updateRequest.process(solr);} catch (SolrServerException e) {throw new IOException(e);@@ -347,7 +334,9 @@ Tool {}public void dedup(String solrUrl) throws IOException {- LOG.info("SolrDeleteDuplicates: starting...");+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");+ long start = System.currentTimeMillis();+ LOG.info("SolrDeleteDuplicates: starting at " + sdf.format(start));LOG.info("SolrDeleteDuplicates: Solr url: " + solrUrl);JobConf job = new NutchJob(getConf());@@ -361,8 +350,9 @@ Tool {job.setReducerClass(SolrDeleteDuplicates.class);JobClient.runJob(job);-- LOG.info("SolrDeleteDuplicates: done.");++ long end = System.currentTimeMillis();+ LOG.info("SolrDeleteDuplicates: finished at " + sdf.format(end) + ", elapsed: " + TimingUtil.elapsedTime(start, end));}public int run(String[] args) throws IOException {diff --git a/src/java/org/apache/nutch/indexer/solr/SolrIndexer.java b/src/java/org/apache/nutch/indexer/solr/SolrIndexer.javaindex da7031702..4e01468e5 100644--- a/src/java/org/apache/nutch/indexer/solr/SolrIndexer.java+++ b/src/java/org/apache/nutch/indexer/solr/SolrIndexer.java@@ -16,11 +16,6 @@*/package org.apache.nutch.indexer.solr;-import java.io.IOException;-import java.util.ArrayList;-import java.util.List;-import java.util.Random;-import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import org.apache.hadoop.conf.Configuration;@@ -37,9 +32,16 @@ import org.apache.nutch.indexer.IndexerMapReduce;import org.apache.nutch.indexer.NutchIndexWriterFactory;import org.apache.nutch.util.NutchConfiguration;import org.apache.nutch.util.NutchJob;+import org.apache.nutch.util.TimingUtil;import org.apache.solr.client.solrj.SolrServer;import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;+import java.io.IOException;+import java.text.SimpleDateFormat;+import java.util.ArrayList;+import java.util.List;+import java.util.Random;+public class SolrIndexer extends Configured implements Tool {public static Log LOG = LogFactory.getLog(SolrIndexer.class);@@ -54,7 +56,9 @@ public class SolrIndexer extends Configured implements Tool {public void indexSolr(String solrUrl, Path crawlDb, Path linkDb,List<Path> segments) throws IOException {- LOG.info("SolrIndexer: starting");+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");+ long start = System.currentTimeMillis();+ LOG.info("SolrIndexer: starting at " + sdf.format(start));final JobConf job = new NutchJob(getConf());job.setJobName("index-solr " + solrUrl);@@ -76,13 +80,14 @@ public class SolrIndexer extends Configured implements Tool {// do the commits once and for all the reducers in one goSolrServer solr = new CommonsHttpSolrServer(solrUrl);solr.commit();- }+ long end = System.currentTimeMillis();+ LOG.info("SolrIndexer: finished at " + sdf.format(end) + ", elapsed: " + TimingUtil.elapsedTime(start, end));+ }catch (Exception e){LOG.error(e);} finally {FileSystem.get(job).delete(tmp, true);}- LOG.info("SolrIndexer: done");}public int run(String[] args) throws Exception {diff --git a/src/java/org/apache/nutch/parse/ParseSegment.java b/src/java/org/apache/nutch/parse/ParseSegment.javaindex 52a802a56..237e2d2ff 100644--- a/src/java/org/apache/nutch/parse/ParseSegment.java+++ b/src/java/org/apache/nutch/parse/ParseSegment.java@@ -34,6 +34,7 @@ import org.apache.nutch.util.*;import org.apache.hadoop.fs.Path;import java.io.*;+import java.text.SimpleDateFormat;import java.util.*;import java.util.Map.Entry;@@ -42,7 +43,7 @@ public class ParseSegment extends Configured implements Tool,Mapper<WritableComparable, Content, Text, ParseImpl>,Reducer<Text, Writable, Text, Writable> {- public static final Log LOG = LogFactory.getLog(Parser.class);+ public static final Log LOG = LogFactory.getLog(ParseSegment.class);private ScoringFilters scfilters;@@ -131,9 +132,11 @@ public class ParseSegment extends Configured implements Tool,public void parse(Path segment) throws IOException {+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");+ long start = System.currentTimeMillis();if (LOG.isInfoEnabled()) {- LOG.info("Parse: starting");- LOG.info("Parse: segment: " + segment);+ LOG.info("ParseSegment: starting at " + sdf.format(start));+ LOG.info("ParseSegment: segment: " + segment);}JobConf job = new NutchJob(getConf());@@ -151,7 +154,8 @@ public class ParseSegment extends Configured implements Tool,job.setOutputValueClass(ParseImpl.class);JobClient.runJob(job);- if (LOG.isInfoEnabled()) { LOG.info("Parse: done"); }+ long end = System.currentTimeMillis();+ LOG.info("ParseSegment: finished at " + sdf.format(end) + ", elapsed: " + TimingUtil.elapsedTime(start, end));}diff --git a/src/java/org/apache/nutch/scoring/webgraph/LinkDumper.java b/src/java/org/apache/nutch/scoring/webgraph/LinkDumper.javaindex 07985cb32..e4d32cd4f 100644--- a/src/java/org/apache/nutch/scoring/webgraph/LinkDumper.java+++ b/src/java/org/apache/nutch/scoring/webgraph/LinkDumper.java@@ -19,6 +19,7 @@ package org.apache.nutch.scoring.webgraph;import java.io.DataInput;import java.io.DataOutput;import java.io.IOException;+import java.text.SimpleDateFormat;import java.util.ArrayList;import java.util.Iterator;import java.util.List;@@ -62,6 +63,7 @@ import org.apache.nutch.scoring.webgraph.Loops.LoopSet;import org.apache.nutch.util.FSUtils;import org.apache.nutch.util.NutchConfiguration;import org.apache.nutch.util.NutchJob;+import org.apache.nutch.util.TimingUtil;/*** The LinkDumper tool creates a database of node to inlink information that can@@ -346,7 +348,9 @@ public class LinkDumperpublic void dumpLinks(Path webGraphDb)throws IOException {- LOG.info("NodeDumper: starting");+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");+ long start = System.currentTimeMillis();+ LOG.info("NodeDumper: starting at " + sdf.format(start));Configuration conf = getConf();FileSystem fs = FileSystem.get(conf);@@ -410,6 +414,8 @@ public class LinkDumper}fs.delete(tempInverted, true);+ long end = System.currentTimeMillis();+ LOG.info("LinkDumper: finished at " + sdf.format(end) + ", elapsed: " + TimingUtil.elapsedTime(start, end));}public static void main(String[] args)diff --git a/src/java/org/apache/nutch/scoring/webgraph/LinkRank.java b/src/java/org/apache/nutch/scoring/webgraph/LinkRank.javaindex 44f5594cc..0137d310b 100644--- a/src/java/org/apache/nutch/scoring/webgraph/LinkRank.java+++ b/src/java/org/apache/nutch/scoring/webgraph/LinkRank.java@@ -19,6 +19,7 @@ package org.apache.nutch.scoring.webgraph;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;+import java.text.SimpleDateFormat;import java.util.ArrayList;import java.util.HashSet;import java.util.Iterator;@@ -64,6 +65,7 @@ import org.apache.nutch.scoring.webgraph.Loops.LoopSet;import org.apache.nutch.util.FSUtils;import org.apache.nutch.util.NutchConfiguration;import org.apache.nutch.util.NutchJob;+import org.apache.nutch.util.TimingUtil;import org.apache.nutch.util.URLUtil;public class LinkRank@@ -579,6 +581,10 @@ public class LinkRankpublic void analyze(Path webGraphDb)throws IOException {+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");+ long start = System.currentTimeMillis();+ LOG.info("Analysis: starting at " + sdf.format(start));+// store the link rank under the webgraphdb temporarily, final scores get// upddated into the nodedbPath linkRank = new Path(webGraphDb, "linkrank");@@ -606,8 +612,8 @@ public class LinkRankfloat rankOneScore = (1f / (float)numLinks);if (LOG.isInfoEnabled()) {- LOG.info("Number of links " + numLinks);- LOG.info("Rank One " + rankOneScore);+ LOG.info("Analysis: Number of links: " + numLinks);+ LOG.info("Analysis: Rank One: " + rankOneScore);}// run invert and analysis for a given number of iterations to allow the@@ -616,7 +622,7 @@ public class LinkRankfor (int i = 0; i < numIterations; i++) {// the input to inverting is always the previous output from analysis- LOG.info("Running iteration " + (i + 1) + " of " + numIterations);+ LOG.info("Analysis: Starting iteration " + (i + 1) + " of " + numIterations);Path tempRank = new Path(linkRank + "-"+ Integer.toString(new Random().nextInt(Integer.MAX_VALUE)));fs.mkdirs(tempRank);@@ -629,19 +635,20 @@ public class LinkRankrankOneScore);// replace the temporary NodeDb with the output from analysis- LOG.info("Installing new link scores");+ LOG.info("Analysis: Installing new link scores");FSUtils.replace(fs, linkRank, tempRank, true);- LOG.info("Finished analysis iteration " + (i + 1) + " of "+ LOG.info("Analysis: finished iteration " + (i + 1) + " of "+ numIterations);}// replace the NodeDb in the WebGraph with the final output of analysis- LOG.info("Installing web graph nodes");+ LOG.info("Analysis: Installing web graph nodes");FSUtils.replace(fs, wgNodeDb, nodeDb, true);// remove the temporary link rank folderfs.delete(linkRank, true);- LOG.info("Finished analysis");+ long end = System.currentTimeMillis();+ LOG.info("Analysis: finished at " + sdf.format(end) + ", elapsed: " + TimingUtil.elapsedTime(start, end));}public static void main(String[] args)diff --git a/src/java/org/apache/nutch/scoring/webgraph/Loops.java b/src/java/org/apache/nutch/scoring/webgraph/Loops.javaindex 9a9809ae8..cb42b8ad9 100644--- a/src/java/org/apache/nutch/scoring/webgraph/Loops.java+++ b/src/java/org/apache/nutch/scoring/webgraph/Loops.java@@ -19,6 +19,7 @@ package org.apache.nutch.scoring.webgraph;import java.io.DataInput;import java.io.DataOutput;import java.io.IOException;+import java.text.SimpleDateFormat;import java.util.ArrayList;import java.util.HashSet;import java.util.Iterator;@@ -61,6 +62,7 @@ import org.apache.hadoop.util.ToolRunner;import org.apache.nutch.util.FSUtils;import org.apache.nutch.util.NutchConfiguration;import org.apache.nutch.util.NutchJob;+import org.apache.nutch.util.TimingUtil;/*** The Loops job identifies cycles of loops inside of the web graph. This is@@ -466,8 +468,10 @@ public class Loopspublic void findLoops(Path webGraphDb)throws IOException {+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");+ long start = System.currentTimeMillis();if (LOG.isInfoEnabled()) {- LOG.info("Loops: starting");+ LOG.info("Loops: starting at " + sdf.format(start));LOG.info("Loops: webgraphdb: " + webGraphDb);}@@ -495,11 +499,11 @@ public class Loopsinit.setOutputFormat(SequenceFileOutputFormat.class);try {- LOG.info("Initializer: running");+ LOG.info("Loops: starting initializer");JobClient.runJob(init);- LOG.info("Initializer: installing " + routes);+ LOG.info("Loops: installing initializer " + routes);FSUtils.replace(fs, routes, tempRoute, true);- LOG.info("Initializer: finished");+ LOG.info("Loops: finished initializer");}catch (IOException e) {LOG.error(StringUtils.stringifyException(e));@@ -527,11 +531,11 @@ public class Loopslooper.setBoolean("last", i == (depth - 1));try {- LOG.info("Looper: running");+ LOG.info("Loops: starting looper");JobClient.runJob(looper);- LOG.info("Looper: installing " + routes);+ LOG.info("Loops: installing looper " + routes);FSUtils.replace(fs, routes, tempRoute, true);- LOG.info("Looper: finished");+ LOG.info("Loops: finished looper");}catch (IOException e) {LOG.error(StringUtils.stringifyException(e));@@ -554,14 +558,16 @@ public class Loopsfinalizer.setOutputFormat(MapFileOutputFormat.class);try {- LOG.info("Finalizer: running");+ LOG.info("Loops: starting finalizer");JobClient.runJob(finalizer);- LOG.info("Finalizer: finished");+ LOG.info("Loops: finished finalizer");}catch (IOException e) {LOG.error(StringUtils.stringifyException(e));throw e;}+ long end = System.currentTimeMillis();+ LOG.info("Loops: finished at " + sdf.format(end) + ", elapsed: " + TimingUtil.elapsedTime(start, end));}public static void main(String[] args)diff --git a/src/java/org/apache/nutch/scoring/webgraph/NodeDumper.java b/src/java/org/apache/nutch/scoring/webgraph/NodeDumper.javaindex 322d9ab28..4a6f227f3 100644--- a/src/java/org/apache/nutch/scoring/webgraph/NodeDumper.java+++ b/src/java/org/apache/nutch/scoring/webgraph/NodeDumper.java@@ -17,6 +17,7 @@package org.apache.nutch.scoring.webgraph;import java.io.IOException;+import java.text.SimpleDateFormat;import java.util.Iterator;import org.apache.commons.cli.CommandLine;@@ -49,6 +50,7 @@ import org.apache.hadoop.util.Tool;import org.apache.hadoop.util.ToolRunner;import org.apache.nutch.util.NutchConfiguration;import org.apache.nutch.util.NutchJob;+import org.apache.nutch.util.TimingUtil;/*** A tools that dumps out the top urls by number of inlinks, number of outlinks,@@ -152,9 +154,6 @@ public class NodeDumper** @param webGraphDb The WebGraph from which to pull values.*- * @param inlinks- * @param outlinks- * @param scores* @param topN* @param output*@@ -163,7 +162,9 @@ public class NodeDumperpublic void dumpNodes(Path webGraphDb, DumpType type, long topN, Path output)throws IOException {- LOG.info("NodeDumper: starting");+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");+ long start = System.currentTimeMillis();+ LOG.info("NodeDumper: starting at " + sdf.format(start));Path nodeDb = new Path(webGraphDb, WebGraph.NODE_DIR);Configuration conf = getConf();@@ -193,6 +194,8 @@ public class NodeDumperLOG.error(StringUtils.stringifyException(e));throw e;}+ long end = System.currentTimeMillis();+ LOG.info("NodeDumper: finished at " + sdf.format(end) + ", elapsed: " + TimingUtil.elapsedTime(start, end));}public static void main(String[] args)diff --git a/src/java/org/apache/nutch/scoring/webgraph/ScoreUpdater.java b/src/java/org/apache/nutch/scoring/webgraph/ScoreUpdater.javaindex 31570f0b5..92c485c1d 100644--- a/src/java/org/apache/nutch/scoring/webgraph/ScoreUpdater.java+++ b/src/java/org/apache/nutch/scoring/webgraph/ScoreUpdater.java@@ -17,6 +17,7 @@package org.apache.nutch.scoring.webgraph;import java.io.IOException;+import java.text.SimpleDateFormat;import java.util.Iterator;import java.util.Random;@@ -53,6 +54,7 @@ import org.apache.nutch.crawl.CrawlDatum;import org.apache.nutch.crawl.CrawlDb;import org.apache.nutch.util.NutchConfiguration;import org.apache.nutch.util.NutchJob;+import org.apache.nutch.util.TimingUtil;/*** Updates the score from the WebGraph node database into the crawl database.@@ -151,6 +153,10 @@ public class ScoreUpdaterpublic void update(Path crawlDb, Path webGraphDb)throws IOException {+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");+ long start = System.currentTimeMillis();+ LOG.info("ScoreUpdater: starting at " + sdf.format(start));+Configuration conf = getConf();FileSystem fs = FileSystem.get(conf);@@ -190,8 +196,11 @@ public class ScoreUpdater}// install the temp crawl database- LOG.info("Installing new crawldb " + crawlDb);+ LOG.info("ScoreUpdater: installing new crawldb " + crawlDb);CrawlDb.install(updater, crawlDb);++ long end = System.currentTimeMillis();+ LOG.info("ScoreUpdater: finished at " + sdf.format(end) + ", elapsed: " + TimingUtil.elapsedTime(start, end));}public static void main(String[] args)diff --git a/src/java/org/apache/nutch/scoring/webgraph/WebGraph.java b/src/java/org/apache/nutch/scoring/webgraph/WebGraph.javaindex 17353e09a..9c9e211e4 100644--- a/src/java/org/apache/nutch/scoring/webgraph/WebGraph.java+++ b/src/java/org/apache/nutch/scoring/webgraph/WebGraph.java@@ -17,6 +17,7 @@package org.apache.nutch.scoring.webgraph;import java.io.IOException;+import java.text.SimpleDateFormat;import java.util.ArrayList;import java.util.HashSet;import java.util.Iterator;@@ -63,6 +64,7 @@ import org.apache.nutch.util.FSUtils;import org.apache.nutch.util.LockUtil;import org.apache.nutch.util.NutchConfiguration;import org.apache.nutch.util.NutchJob;+import org.apache.nutch.util.TimingUtil;import org.apache.nutch.util.URLUtil;/**@@ -437,8 +439,10 @@ public class WebGraphpublic void createWebGraph(Path webGraphDb, Path[] segments)throws IOException {+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");+ long start = System.currentTimeMillis();if (LOG.isInfoEnabled()) {- LOG.info("WebGraphDb: starting");+ LOG.info("WebGraphDb: starting at " + sdf.format(start));LOG.info("WebGraphDb: webgraphdb: " + webGraphDb);}@@ -590,6 +594,9 @@ public class WebGraph// remove the lock file for the webgraphLockUtil.removeLockFile(fs, lock);++ long end = System.currentTimeMillis();+ LOG.info("WebGraphDb: finished at " + sdf.format(end) + ", elapsed: " + TimingUtil.elapsedTime(start, end));}public static void main(String[] args)diff --git a/src/java/org/apache/nutch/tools/CrawlDBScanner.java b/src/java/org/apache/nutch/tools/CrawlDBScanner.javaindex 8029bac63..125d8edd2 100644--- a/src/java/org/apache/nutch/tools/CrawlDBScanner.java+++ b/src/java/org/apache/nutch/tools/CrawlDBScanner.java@@ -17,6 +17,7 @@package org.apache.nutch.tools;import java.io.IOException;+import java.text.SimpleDateFormat;import java.util.Iterator;import org.apache.commons.logging.Log;@@ -43,6 +44,7 @@ import org.apache.nutch.crawl.CrawlDatum;import org.apache.nutch.crawl.CrawlDb;import org.apache.nutch.util.NutchConfiguration;import org.apache.nutch.util.NutchJob;+import org.apache.nutch.util.TimingUtil;/*** Dumps all the entries matching a regular expression on their URL. Generates a@@ -99,6 +101,10 @@ public class CrawlDBScanner extends Configured implements Tool,private void scan(Path crawlDb, Path outputPath, String regex, String status,boolean text) throws IOException {+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");+ long start = System.currentTimeMillis();+ LOG.info("CrawlDB scanner: starting at " + sdf.format(start));+JobConf job = new NutchJob(getConf());job.setJobName("Scan : " + crawlDb + " for URLS matching : " + regex);@@ -139,6 +145,9 @@ public class CrawlDBScanner extends Configured implements Tool,} catch (IOException e) {throw e;}++ long end = System.currentTimeMillis();+ LOG.info("CrawlDb scanner: finished at " + sdf.format(end) + ", elapsed: " + TimingUtil.elapsedTime(start, end));}public static void main(String args[]) throws Exception {diff --git a/src/java/org/apache/nutch/tools/FreeGenerator.java b/src/java/org/apache/nutch/tools/FreeGenerator.javaindex c5e961ca8..4b01721d0 100644--- a/src/java/org/apache/nutch/tools/FreeGenerator.java+++ b/src/java/org/apache/nutch/tools/FreeGenerator.java@@ -18,6 +18,7 @@package org.apache.nutch.tools;import java.io.IOException;+import java.text.SimpleDateFormat;import java.util.HashMap;import java.util.Iterator;import java.util.Map.Entry;@@ -50,6 +51,7 @@ import org.apache.nutch.net.URLNormalizers;import org.apache.nutch.scoring.ScoringFilters;import org.apache.nutch.util.NutchConfiguration;import org.apache.nutch.util.NutchJob;+import org.apache.nutch.util.TimingUtil;/*** This tool generates fetchlists (segments to be fetched) from plain text@@ -157,6 +159,10 @@ public class FreeGenerator extends Configured implements Tool {}}+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");+ long start = System.currentTimeMillis();+ LOG.info("FreeGenerator: starting at " + sdf.format(start));+JobConf job = new NutchJob(getConf());job.setBoolean(FILTER_KEY, filter);job.setBoolean(NORMALIZE_KEY, normalize);@@ -177,11 +183,13 @@ public class FreeGenerator extends Configured implements Tool {new Path(segName, CrawlDatum.GENERATE_DIR_NAME)));try {JobClient.runJob(job);- return 0;} catch (Exception e) {LOG.fatal("FAILED: " + StringUtils.stringifyException(e));return -1;}+ long end = System.currentTimeMillis();+ LOG.info("FreeGenerator: finished at " + sdf.format(end) + ", elapsed: " + TimingUtil.elapsedTime(start, end));+ return 0;}public static void main(String[] args) throws Exception {diff --git a/src/java/org/apache/nutch/tools/arc/ArcSegmentCreator.java b/src/java/org/apache/nutch/tools/arc/ArcSegmentCreator.javaindex 7506b7472..cf7f8c424 100644--- a/src/java/org/apache/nutch/tools/arc/ArcSegmentCreator.java+++ b/src/java/org/apache/nutch/tools/arc/ArcSegmentCreator.java@@ -59,6 +59,7 @@ import org.apache.nutch.util.LogUtil;import org.apache.nutch.util.NutchConfiguration;import org.apache.nutch.util.NutchJob;import org.apache.nutch.util.StringUtil;+import org.apache.nutch.util.TimingUtil;/*** <p>The <code>ArcSegmentCreator</code> is a replacement for fetcher that will@@ -346,8 +347,10 @@ public class ArcSegmentCreatorpublic void createSegments(Path arcFiles, Path segmentsOutDir)throws IOException {+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");+ long start = System.currentTimeMillis();if (LOG.isInfoEnabled()) {- LOG.info("ArcSegmentCreator: starting");+ LOG.info("ArcSegmentCreator: starting at " + sdf.format(start));LOG.info("ArcSegmentCreator: arc files dir: " + arcFiles);}@@ -364,9 +367,9 @@ public class ArcSegmentCreatorjob.setOutputValueClass(NutchWritable.class);JobClient.runJob(job);- if (LOG.isInfoEnabled()) {- LOG.info("ArcSegmentCreator: done");- }++ long end = System.currentTimeMillis();+ LOG.info("ArcSegmentCreator: finished at " + sdf.format(end) + ", elapsed: " + TimingUtil.elapsedTime(start, end));}public static void main(String args[])diff --git a/src/java/org/apache/nutch/util/TimingUtil.java b/src/java/org/apache/nutch/util/TimingUtil.javanew file mode 100644index 000000000..8ed5ca8e2--- /dev/null+++ b/src/java/org/apache/nutch/util/TimingUtil.java@@ -0,0 +1,55 @@+/**+ * 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.util;++import java.text.NumberFormat;++public class TimingUtil {++ private static long[] TIME_FACTOR = { 60 * 60 * 1000, 60 * 1000, 1000 };++ /**+ * Calculate the elapsed time between two times specified in milliseconds.+ * @param start The start of the time period+ * @param end The end of the time period+ * @return a string of the form "XhYmZs" when the elapsed time is X hours, Y minutes and Z seconds or null if start > end.+ */+ public static String elapsedTime(long start, long end){+ if (start > end) {+ return null;+ }++ long[] elapsedTime = new long[TIME_FACTOR.length];++ for (int i = 0; i < TIME_FACTOR.length; i++) {+ elapsedTime[i] = start > end ? -1 : (end - start) / TIME_FACTOR[i];+ start += TIME_FACTOR[i] * elapsedTime[i];+ }++ NumberFormat nf = NumberFormat.getInstance();+ nf.setMinimumIntegerDigits(2);+ StringBuffer buf = new StringBuffer();+ for (int i = 0; i < elapsedTime.length; i++) {+ if (i > 0) {+ buf.append(":");+ }+ buf.append(nf.format(elapsedTime[i]));+ }+ return buf.toString();+ }+}diff --git a/src/java/org/apache/nutch/util/domain/DomainStatistics.java b/src/java/org/apache/nutch/util/domain/DomainStatistics.javaindex 843877a02..c3f3398e7 100644--- a/src/java/org/apache/nutch/util/domain/DomainStatistics.java+++ b/src/java/org/apache/nutch/util/domain/DomainStatistics.java@@ -19,6 +19,7 @@ package org.apache.nutch.util.domain;import java.io.IOException;import java.net.URL;+import java.text.SimpleDateFormat;import java.util.Iterator;import org.apache.commons.logging.Log;@@ -43,6 +44,7 @@ import org.apache.hadoop.util.ToolRunner;import org.apache.nutch.crawl.CrawlDatum;import org.apache.nutch.util.NutchConfiguration;import org.apache.nutch.util.NutchJob;+import org.apache.nutch.util.TimingUtil;import org.apache.nutch.util.URLUtil;/**@@ -70,7 +72,7 @@ implements Tool, Mapper<Text, CrawlDatum, Text, LongWritable>,public int run(String[] args) throws IOException {if (args.length < 3) {- System.out.println("usage: inputDirs outDir host|domain|suffix [numOfReducer]");+ System.out.println("usage: DomainStatistics inputDirs outDir host|domain|suffix [numOfReducer]");return 1;}String inputDir = args[0];@@ -81,6 +83,10 @@ implements Tool, Mapper<Text, CrawlDatum, Text, LongWritable>,numOfReducers = Integer.parseInt(args[3]);}+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");+ long start = System.currentTimeMillis();+ LOG.info("DomainStatistics: starting at " + sdf.format(start));+JobConf job = new NutchJob(getConf());job.setJobName("Domain statistics");@@ -112,6 +118,8 @@ implements Tool, Mapper<Text, CrawlDatum, Text, LongWritable>,JobClient.runJob(job);+ long end = System.currentTimeMillis();+ LOG.info("DomainStatistics: finished at " + sdf.format(end) + ", elapsed: " + TimingUtil.elapsedTime(start, end));return 0;}@@ -122,12 +130,10 @@ implements Tool, Mapper<Text, CrawlDatum, Text, LongWritable>,}- @Overridepublic Configuration getConf() {return conf;}- @Overridepublic void setConf(Configuration conf) {this.conf = conf;}