You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nutch.apache.org by ab...@apache.org on 2008/07/21 21:20:22 UTC

svn commit: r678533 [1/2] - in /lucene/nutch/trunk: ./ conf/ lib/ lib/native/Linux-amd64-64/ lib/native/Linux-i386-32/ src/java/org/apache/nutch/crawl/ src/java/org/apache/nutch/fetcher/ src/java/org/apache/nutch/indexer/ src/java/org/apache/nutch/pars...

Author: ab
Date: Mon Jul 21 12:20:21 2008
New Revision: 678533

URL: http://svn.apache.org/viewvc?rev=678533&view=rev
Log:
NUTCH-634 Upgrade Nutch to Hadoop 0.17.1 .

Added:
    lucene/nutch/trunk/lib/hadoop-0.17.1-core.jar   (with props)
Removed:
    lucene/nutch/trunk/lib/hadoop-0.16.0-core.jar
Modified:
    lucene/nutch/trunk/CHANGES.txt
    lucene/nutch/trunk/conf/nutch-default.xml
    lucene/nutch/trunk/lib/native/Linux-amd64-64/libhadoop.a
    lucene/nutch/trunk/lib/native/Linux-amd64-64/libhadoop.so
    lucene/nutch/trunk/lib/native/Linux-amd64-64/libhadoop.so.1
    lucene/nutch/trunk/lib/native/Linux-amd64-64/libhadoop.so.1.0.0
    lucene/nutch/trunk/lib/native/Linux-i386-32/libhadoop.a
    lucene/nutch/trunk/lib/native/Linux-i386-32/libhadoop.so
    lucene/nutch/trunk/lib/native/Linux-i386-32/libhadoop.so.1
    lucene/nutch/trunk/lib/native/Linux-i386-32/libhadoop.so.1.0.0
    lucene/nutch/trunk/src/java/org/apache/nutch/crawl/Crawl.java
    lucene/nutch/trunk/src/java/org/apache/nutch/crawl/CrawlDb.java
    lucene/nutch/trunk/src/java/org/apache/nutch/crawl/CrawlDbFilter.java
    lucene/nutch/trunk/src/java/org/apache/nutch/crawl/CrawlDbMerger.java
    lucene/nutch/trunk/src/java/org/apache/nutch/crawl/CrawlDbReader.java
    lucene/nutch/trunk/src/java/org/apache/nutch/crawl/CrawlDbReducer.java
    lucene/nutch/trunk/src/java/org/apache/nutch/crawl/Generator.java
    lucene/nutch/trunk/src/java/org/apache/nutch/crawl/Injector.java
    lucene/nutch/trunk/src/java/org/apache/nutch/crawl/LinkDb.java
    lucene/nutch/trunk/src/java/org/apache/nutch/crawl/LinkDbFilter.java
    lucene/nutch/trunk/src/java/org/apache/nutch/crawl/LinkDbMerger.java
    lucene/nutch/trunk/src/java/org/apache/nutch/crawl/LinkDbReader.java
    lucene/nutch/trunk/src/java/org/apache/nutch/fetcher/Fetcher.java
    lucene/nutch/trunk/src/java/org/apache/nutch/fetcher/Fetcher2.java
    lucene/nutch/trunk/src/java/org/apache/nutch/fetcher/FetcherOutputFormat.java
    lucene/nutch/trunk/src/java/org/apache/nutch/indexer/DeleteDuplicates.java
    lucene/nutch/trunk/src/java/org/apache/nutch/indexer/FsDirectory.java
    lucene/nutch/trunk/src/java/org/apache/nutch/indexer/IndexMerger.java
    lucene/nutch/trunk/src/java/org/apache/nutch/indexer/Indexer.java
    lucene/nutch/trunk/src/java/org/apache/nutch/parse/Outlink.java
    lucene/nutch/trunk/src/java/org/apache/nutch/parse/ParseOutputFormat.java
    lucene/nutch/trunk/src/java/org/apache/nutch/parse/ParseSegment.java
    lucene/nutch/trunk/src/java/org/apache/nutch/parse/ParseStatus.java
    lucene/nutch/trunk/src/java/org/apache/nutch/parse/ParserFactory.java
    lucene/nutch/trunk/src/java/org/apache/nutch/searcher/FetchedSegments.java
    lucene/nutch/trunk/src/java/org/apache/nutch/searcher/NutchBean.java
    lucene/nutch/trunk/src/java/org/apache/nutch/segment/SegmentMerger.java
    lucene/nutch/trunk/src/java/org/apache/nutch/segment/SegmentReader.java
    lucene/nutch/trunk/src/java/org/apache/nutch/tools/FreeGenerator.java
    lucene/nutch/trunk/src/java/org/apache/nutch/tools/arc/ArcInputFormat.java
    lucene/nutch/trunk/src/java/org/apache/nutch/tools/arc/ArcRecordReader.java
    lucene/nutch/trunk/src/java/org/apache/nutch/tools/arc/ArcSegmentCreator.java
    lucene/nutch/trunk/src/java/org/apache/nutch/tools/compat/CrawlDbConverter.java
    lucene/nutch/trunk/src/java/org/apache/nutch/util/LockUtil.java
    lucene/nutch/trunk/src/test/org/apache/nutch/crawl/TestGenerator.java
    lucene/nutch/trunk/src/test/org/apache/nutch/crawl/TestInjector.java
    lucene/nutch/trunk/src/test/org/apache/nutch/crawl/TestLinkDbMerger.java
    lucene/nutch/trunk/src/test/org/apache/nutch/crawl/TestMapWritable.java
    lucene/nutch/trunk/src/test/org/apache/nutch/fetcher/TestFetcher.java
    lucene/nutch/trunk/src/test/org/apache/nutch/indexer/TestDeleteDuplicates.java
    lucene/nutch/trunk/src/test/org/apache/nutch/searcher/TestDistributedSearch.java

Modified: lucene/nutch/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/CHANGES.txt?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
--- lucene/nutch/trunk/CHANGES.txt (original)
+++ lucene/nutch/trunk/CHANGES.txt Mon Jul 21 12:20:21 2008
@@ -253,6 +253,9 @@
     
 92. NUTCH-618 - Tika error "Media type alias already exists" (mattmann,kubes)
 
+93. NUTCH-634 - Upgrade Nutch to Hadoop 0.17.1 (Michael Gottesman, Lincoln
+    Ritter, ab)
+
 Release 0.9 - 2007-04-02
 
  1. Changed log4j confiquration to log to stdout on commandline

Modified: lucene/nutch/trunk/conf/nutch-default.xml
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/conf/nutch-default.xml?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
--- lucene/nutch/trunk/conf/nutch-default.xml (original)
+++ lucene/nutch/trunk/conf/nutch-default.xml Mon Jul 21 12:20:21 2008
@@ -1189,4 +1189,17 @@
   </description>
 </property>
 
+<!-- Temporary Hadoop 0.17.x workaround. -->
+
+<property>
+  <name>hadoop.job.history.user.location</name>
+  <value>${hadoop.log.dir}/history/user</value>
+  <description>Hadoop 0.17.x comes with a default setting to create
+     user logs inside the output path of the job. This breaks some
+     Hadoop classes, which expect the output to contain only
+     part-XXXXX files. This setting changes the output to a
+     subdirectory of the regular log directory.
+  </description>
+</property>
+
 </configuration>

Added: lucene/nutch/trunk/lib/hadoop-0.17.1-core.jar
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/lib/hadoop-0.17.1-core.jar?rev=678533&view=auto
==============================================================================
Binary file - no diff available.

Propchange: lucene/nutch/trunk/lib/hadoop-0.17.1-core.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Modified: lucene/nutch/trunk/lib/native/Linux-amd64-64/libhadoop.a
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/lib/native/Linux-amd64-64/libhadoop.a?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
Binary files - no diff available.

Modified: lucene/nutch/trunk/lib/native/Linux-amd64-64/libhadoop.so
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/lib/native/Linux-amd64-64/libhadoop.so?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
Binary files - no diff available.

Modified: lucene/nutch/trunk/lib/native/Linux-amd64-64/libhadoop.so.1
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/lib/native/Linux-amd64-64/libhadoop.so.1?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
Binary files - no diff available.

Modified: lucene/nutch/trunk/lib/native/Linux-amd64-64/libhadoop.so.1.0.0
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/lib/native/Linux-amd64-64/libhadoop.so.1.0.0?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
Binary files - no diff available.

Modified: lucene/nutch/trunk/lib/native/Linux-i386-32/libhadoop.a
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/lib/native/Linux-i386-32/libhadoop.a?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
Binary files - no diff available.

Modified: lucene/nutch/trunk/lib/native/Linux-i386-32/libhadoop.so
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/lib/native/Linux-i386-32/libhadoop.so?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
Binary files - no diff available.

Modified: lucene/nutch/trunk/lib/native/Linux-i386-32/libhadoop.so.1
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/lib/native/Linux-i386-32/libhadoop.so.1?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
Binary files - no diff available.

Modified: lucene/nutch/trunk/lib/native/Linux-i386-32/libhadoop.so.1.0.0
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/lib/native/Linux-i386-32/libhadoop.so.1.0.0?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
Binary files - no diff available.

Modified: lucene/nutch/trunk/src/java/org/apache/nutch/crawl/Crawl.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/java/org/apache/nutch/crawl/Crawl.java?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
--- lucene/nutch/trunk/src/java/org/apache/nutch/crawl/Crawl.java (original)
+++ lucene/nutch/trunk/src/java/org/apache/nutch/crawl/Crawl.java Mon Jul 21 12:20:21 2008
@@ -131,19 +131,21 @@
       // Delete old indexes
       if (fs.exists(indexes)) {
         LOG.info("Deleting old indexes: " + indexes);
-        fs.delete(indexes);
+        fs.delete(indexes, true);
       }
 
       // Delete old index
       if (fs.exists(index)) {
         LOG.info("Deleting old merged index: " + index);
-        fs.delete(index);
+        fs.delete(index, true);
       }
 
       // index, dedup & merge
-      indexer.index(indexes, crawlDb, linkDb, fs.listPaths(segments, HadoopFSUtil.getPassAllFilter()));
+      FileStatus[] fstats = fs.listStatus(segments, HadoopFSUtil.getPassDirectoriesFilter(fs));
+      indexer.index(indexes, crawlDb, linkDb, HadoopFSUtil.getPaths(fstats));
       dedup.dedup(new Path[] { indexes });
-      merger.merge(fs.listPaths(indexes, HadoopFSUtil.getPassAllFilter()), index, tmpDir);
+      fstats = fs.listStatus(indexes, HadoopFSUtil.getPassDirectoriesFilter(fs));
+      merger.merge(HadoopFSUtil.getPaths(fstats), index, tmpDir);
     } else {
       LOG.warn("No URLs to fetch - check your seed list and URL filters.");
     }

Modified: lucene/nutch/trunk/src/java/org/apache/nutch/crawl/CrawlDb.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/java/org/apache/nutch/crawl/CrawlDb.java?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
--- lucene/nutch/trunk/src/java/org/apache/nutch/crawl/CrawlDb.java (original)
+++ lucene/nutch/trunk/src/java/org/apache/nutch/crawl/CrawlDb.java Mon Jul 21 12:20:21 2008
@@ -80,8 +80,8 @@
       Path fetch = new Path(segments[i], CrawlDatum.FETCH_DIR_NAME);
       Path parse = new Path(segments[i], CrawlDatum.PARSE_DIR_NAME);
       if (fs.exists(fetch) && fs.exists(parse)) {
-        job.addInputPath(fetch);
-        job.addInputPath(parse);
+        FileInputFormat.addInputPath(job, fetch);
+        FileInputFormat.addInputPath(job, parse);
       } else {
         LOG.info(" - skipping invalid segment " + segments[i]);
       }
@@ -94,7 +94,8 @@
       JobClient.runJob(job);
     } catch (IOException e) {
       LockUtil.removeLockFile(fs, lock);
-      if (fs.exists(job.getOutputPath())) fs.delete(job.getOutputPath());
+      Path outPath = FileOutputFormat.getOutputPath(job);
+      if (fs.exists(outPath) ) fs.delete(outPath, true);
       throw e;
     }
 
@@ -114,14 +115,14 @@
 
     Path current = new Path(crawlDb, CURRENT_NAME);
     if (FileSystem.get(job).exists(current)) {
-      job.addInputPath(current);
+      FileInputFormat.addInputPath(job, current);
     }
     job.setInputFormat(SequenceFileInputFormat.class);
 
     job.setMapperClass(CrawlDbFilter.class);
     job.setReducerClass(CrawlDbReducer.class);
 
-    job.setOutputPath(newCrawlDb);
+    FileOutputFormat.setOutputPath(job, newCrawlDb);
     job.setOutputFormat(MapFileOutputFormat.class);
     job.setOutputKeyClass(Text.class);
     job.setOutputValueClass(CrawlDatum.class);
@@ -130,17 +131,17 @@
   }
 
   public static void install(JobConf job, Path crawlDb) throws IOException {
-    Path newCrawlDb = job.getOutputPath();
+    Path newCrawlDb = FileOutputFormat.getOutputPath(job);
     FileSystem fs = new JobClient(job).getFs();
     Path old = new Path(crawlDb, "old");
     Path current = new Path(crawlDb, CURRENT_NAME);
     if (fs.exists(current)) {
-      if (fs.exists(old)) fs.delete(old);
+      if (fs.exists(old)) fs.delete(old, true);
       fs.rename(current, old);
     }
     fs.mkdirs(crawlDb);
     fs.rename(newCrawlDb, current);
-    if (fs.exists(old)) fs.delete(old);
+    if (fs.exists(old)) fs.delete(old, true);
     Path lock = new Path(crawlDb, LOCK_NAME);
     LockUtil.removeLockFile(fs, lock);
   }

Modified: lucene/nutch/trunk/src/java/org/apache/nutch/crawl/CrawlDbFilter.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/java/org/apache/nutch/crawl/CrawlDbFilter.java?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
--- lucene/nutch/trunk/src/java/org/apache/nutch/crawl/CrawlDbFilter.java (original)
+++ lucene/nutch/trunk/src/java/org/apache/nutch/crawl/CrawlDbFilter.java Mon Jul 21 12:20:21 2008
@@ -22,8 +22,6 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.io.Text;
-import org.apache.hadoop.io.Writable;
-import org.apache.hadoop.io.WritableComparable;
 import org.apache.hadoop.mapred.JobConf;
 import org.apache.hadoop.mapred.Mapper;
 import org.apache.hadoop.mapred.OutputCollector;
@@ -37,7 +35,7 @@
  * 
  * @author Andrzej Bialecki
  */
-public class CrawlDbFilter implements Mapper {
+public class CrawlDbFilter implements Mapper<Text, CrawlDatum, Text, CrawlDatum> {
   public static final String URL_FILTERING = "crawldb.url.filters";
 
   public static final String URL_NORMALIZING = "crawldb.url.normalizers";
@@ -72,7 +70,9 @@
   
   private Text newKey = new Text();
 
-  public void map(WritableComparable key, Writable value, OutputCollector output, Reporter reporter) throws IOException {
+  public void map(Text key, CrawlDatum value,
+      OutputCollector<Text, CrawlDatum> output,
+      Reporter reporter) throws IOException {
 
     String url = key.toString();
     if (urlNormalizers) {

Modified: lucene/nutch/trunk/src/java/org/apache/nutch/crawl/CrawlDbMerger.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/java/org/apache/nutch/crawl/CrawlDbMerger.java?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
--- lucene/nutch/trunk/src/java/org/apache/nutch/crawl/CrawlDbMerger.java (original)
+++ lucene/nutch/trunk/src/java/org/apache/nutch/crawl/CrawlDbMerger.java Mon Jul 21 12:20:21 2008
@@ -53,7 +53,8 @@
   private static final Log LOG = LogFactory.getLog(CrawlDbMerger.class);
 
   public static class Merger extends MapReduceBase implements Reducer<Text, CrawlDatum, Text, CrawlDatum> {
-    MapWritable meta = new MapWritable();
+    private MapWritable meta = new MapWritable();
+    private CrawlDatum res = new CrawlDatum();
     private FetchSchedule schedule;
 
     public void close() throws IOException {}
@@ -64,13 +65,14 @@
 
     public void reduce(Text key, Iterator<CrawlDatum> values, OutputCollector<Text, CrawlDatum> output, Reporter reporter)
             throws IOException {
-      CrawlDatum res = null;
       long resTime = 0L;
+      boolean resSet = false;
       meta.clear();
       while (values.hasNext()) {
         CrawlDatum val = values.next();
-        if (res == null) {
-          res = val;
+        if (!resSet) {
+          res.set(val);
+          resSet = true;
           resTime = schedule.calculateLastFetchTime(res);
           meta.putAll(res.getMetaData());
           continue;
@@ -80,7 +82,7 @@
         if (valTime > resTime) {
           // collect all metadata, newer values override older values
           meta.putAll(val.getMetaData());
-          res = val;
+          res.set(val);
           resTime = valTime ;
         } else {
           // insert older metadata before newer
@@ -104,12 +106,12 @@
   public void merge(Path output, Path[] dbs, boolean normalize, boolean filter) throws Exception {
     JobConf job = createMergeJob(getConf(), output, normalize, filter);
     for (int i = 0; i < dbs.length; i++) {
-      job.addInputPath(new Path(dbs[i], CrawlDb.CURRENT_NAME));
+      FileInputFormat.addInputPath(job, new Path(dbs[i], CrawlDb.CURRENT_NAME));
     }
     JobClient.runJob(job);
     FileSystem fs = FileSystem.get(getConf());
     fs.mkdirs(output);
-    fs.rename(job.getOutputPath(), new Path(output, CrawlDb.CURRENT_NAME));
+    fs.rename(FileOutputFormat.getOutputPath(job), new Path(output, CrawlDb.CURRENT_NAME));
   }
 
   public static JobConf createMergeJob(Configuration conf, Path output, boolean normalize, boolean filter) {
@@ -125,7 +127,7 @@
     job.setBoolean(CrawlDbFilter.URL_NORMALIZING, normalize);
     job.setReducerClass(Merger.class);
 
-    job.setOutputPath(newCrawlDb);
+    FileOutputFormat.setOutputPath(job, newCrawlDb);
     job.setOutputFormat(MapFileOutputFormat.class);
     job.setOutputKeyClass(Text.class);
     job.setOutputValueClass(CrawlDatum.class);

Modified: lucene/nutch/trunk/src/java/org/apache/nutch/crawl/CrawlDbReader.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/java/org/apache/nutch/crawl/CrawlDbReader.java?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
--- lucene/nutch/trunk/src/java/org/apache/nutch/crawl/CrawlDbReader.java (original)
+++ lucene/nutch/trunk/src/java/org/apache/nutch/crawl/CrawlDbReader.java Mon Jul 21 12:20:21 2008
@@ -39,12 +39,13 @@
 import org.apache.hadoop.io.MapFile;
 import org.apache.hadoop.io.SequenceFile;
 import org.apache.hadoop.io.Text;
+import org.apache.hadoop.mapred.FileInputFormat;
+import org.apache.hadoop.mapred.FileOutputFormat;
 import org.apache.hadoop.mapred.JobClient;
 import org.apache.hadoop.mapred.JobConf;
 import org.apache.hadoop.mapred.MapFileOutputFormat;
 import org.apache.hadoop.mapred.Mapper;
 import org.apache.hadoop.mapred.OutputCollector;
-import org.apache.hadoop.mapred.OutputFormatBase;
 import org.apache.hadoop.mapred.RecordWriter;
 import org.apache.hadoop.mapred.Reducer;
 import org.apache.hadoop.mapred.Reporter;
@@ -77,7 +78,8 @@
   private void openReaders(String crawlDb, Configuration config) throws IOException {
     if (readers != null) return;
     FileSystem fs = FileSystem.get(config);
-    readers = MapFileOutputFormat.getReaders(fs, new Path(crawlDb, CrawlDb.CURRENT_NAME), config);
+    readers = MapFileOutputFormat.getReaders(fs, new Path(crawlDb,
+        CrawlDb.CURRENT_NAME), config);
   }
   
   private void closeReaders() {
@@ -91,7 +93,7 @@
     }
   }
   
-  public static class CrawlDatumCsvOutputFormat extends OutputFormatBase<Text,CrawlDatum> {
+  public static class CrawlDatumCsvOutputFormat extends FileOutputFormat<Text,CrawlDatum> {
     protected static class LineRecordWriter implements RecordWriter<Text,CrawlDatum> {
       private DataOutputStream out;
 
@@ -138,7 +140,7 @@
 
     public RecordWriter<Text,CrawlDatum> getRecordWriter(FileSystem fs, JobConf job, String name,
         Progressable progress) throws IOException {
-      Path dir = job.getOutputPath();
+      Path dir = FileOutputFormat.getOutputPath(job);
       DataOutputStream fileOut = fs.create(new Path(dir, name), progress);
       return new LineRecordWriter(fileOut);
    }
@@ -299,14 +301,14 @@
     job.setJobName("stats " + crawlDb);
     job.setBoolean("db.reader.stats.sort", sort);
 
-    job.addInputPath(new Path(crawlDb, CrawlDb.CURRENT_NAME));
+    FileInputFormat.addInputPath(job, new Path(crawlDb, CrawlDb.CURRENT_NAME));
     job.setInputFormat(SequenceFileInputFormat.class);
 
     job.setMapperClass(CrawlDbStatMapper.class);
     job.setCombinerClass(CrawlDbStatCombiner.class);
     job.setReducerClass(CrawlDbStatReducer.class);
 
-    job.setOutputPath(tmpFolder);
+    FileOutputFormat.setOutputPath(job, tmpFolder);
     job.setOutputFormat(SequenceFileOutputFormat.class);
     job.setOutputKeyClass(Text.class);
     job.setOutputValueClass(LongWritable.class);
@@ -366,7 +368,7 @@
       }
     }
     // removing the tmp folder
-    fileSystem.delete(tmpFolder);
+    fileSystem.delete(tmpFolder, true);
     if (LOG.isInfoEnabled()) { LOG.info("CrawlDb statistics: done"); }
 
   }
@@ -375,7 +377,8 @@
     Text key = new Text(url);
     CrawlDatum val = new CrawlDatum();
     openReaders(crawlDb, config);
-    CrawlDatum res = (CrawlDatum)MapFileOutputFormat.getEntry(readers, new HashPartitioner(), key, val);
+    CrawlDatum res = (CrawlDatum)MapFileOutputFormat.getEntry(readers,
+        new HashPartitioner<Text, CrawlDatum>(), key, val);
     return res;
   }
 
@@ -401,10 +404,10 @@
     JobConf job = new NutchJob(config);
     job.setJobName("dump " + crawlDb);
 
-    job.addInputPath(new Path(crawlDb, CrawlDb.CURRENT_NAME));
+    FileInputFormat.addInputPath(job, new Path(crawlDb, CrawlDb.CURRENT_NAME));
     job.setInputFormat(SequenceFileInputFormat.class);
 
-    job.setOutputPath(outFolder);
+    FileOutputFormat.setOutputPath(job, outFolder);
     if(format == CSV_FORMAT) job.setOutputFormat(CrawlDatumCsvOutputFormat.class);
     else job.setOutputFormat(TextOutputFormat.class);
     job.setOutputKeyClass(Text.class);
@@ -429,12 +432,12 @@
 
     JobConf job = new NutchJob(config);
     job.setJobName("topN prepare " + crawlDb);
-    job.addInputPath(new Path(crawlDb, CrawlDb.CURRENT_NAME));
+    FileInputFormat.addInputPath(job, new Path(crawlDb, CrawlDb.CURRENT_NAME));
     job.setInputFormat(SequenceFileInputFormat.class);
     job.setMapperClass(CrawlDbTopNMapper.class);
     job.setReducerClass(IdentityReducer.class);
 
-    job.setOutputPath(tempDir);
+    FileOutputFormat.setOutputPath(job, tempDir);
     job.setOutputFormat(SequenceFileOutputFormat.class);
     job.setOutputKeyClass(FloatWritable.class);
     job.setOutputValueClass(Text.class);
@@ -450,22 +453,21 @@
     job.setJobName("topN collect " + crawlDb);
     job.setLong("db.reader.topn", topN);
 
-    job.addInputPath(tempDir);
+    FileInputFormat.addInputPath(job, tempDir);
     job.setInputFormat(SequenceFileInputFormat.class);
     job.setMapperClass(IdentityMapper.class);
     job.setReducerClass(CrawlDbTopNReducer.class);
 
-    job.setOutputPath(outFolder);
+    FileOutputFormat.setOutputPath(job, outFolder);
     job.setOutputFormat(TextOutputFormat.class);
     job.setOutputKeyClass(FloatWritable.class);
     job.setOutputValueClass(Text.class);
 
-    // XXX *sigh* this apparently doesn't work ... :-((
     job.setNumReduceTasks(1); // create a single file.
     
     JobClient.runJob(job);
     FileSystem fs = FileSystem.get(config);
-    fs.delete(tempDir);
+    fs.delete(tempDir, true);
     if (LOG.isInfoEnabled()) { LOG.info("CrawlDb topN: done"); }
 
   }

Modified: lucene/nutch/trunk/src/java/org/apache/nutch/crawl/CrawlDbReducer.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/java/org/apache/nutch/crawl/CrawlDbReducer.java?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
--- lucene/nutch/trunk/src/java/org/apache/nutch/crawl/CrawlDbReducer.java (original)
+++ lucene/nutch/trunk/src/java/org/apache/nutch/crawl/CrawlDbReducer.java Mon Jul 21 12:20:21 2008
@@ -32,7 +32,7 @@
 import org.apache.nutch.scoring.ScoringFilters;
 
 /** Merge new page entries with existing entries. */
-public class CrawlDbReducer implements Reducer {
+public class CrawlDbReducer implements Reducer<Text, CrawlDatum, Text, CrawlDatum> {
   public static final Log LOG = LogFactory.getLog(CrawlDbReducer.class);
   
   private int retryMax;
@@ -42,6 +42,8 @@
   private boolean additionsAllowed;
   private int maxInterval;
   private FetchSchedule schedule;
+  private CrawlDatum fetch = new CrawlDatum();
+  private CrawlDatum old = new CrawlDatum();
 
   public void configure(JobConf job) {
     retryMax = job.getInt("db.fetch.retry.max", 3);
@@ -55,40 +57,44 @@
 
   public void close() {}
 
-  public void reduce(WritableComparable key, Iterator values,
-                     OutputCollector output, Reporter reporter)
+  public void reduce(Text key, Iterator<CrawlDatum> values,
+                     OutputCollector<Text, CrawlDatum> output, Reporter reporter)
     throws IOException {
 
-    CrawlDatum fetch = null;
-    CrawlDatum old = null;
+    boolean fetchSet = false;
+    boolean oldSet = false;
     byte[] signature = null;
     linked.clear();
 
     while (values.hasNext()) {
       CrawlDatum datum = (CrawlDatum)values.next();
       if (CrawlDatum.hasDbStatus(datum)) {
-        if (old == null) {
-          old = datum;
+        if (!oldSet) {
+          old.set(datum);
+          oldSet = true;
         } else {
           // always take the latest version
-          if (old.getFetchTime() < datum.getFetchTime()) old = datum;
+          if (old.getFetchTime() < datum.getFetchTime()) old.set(datum);
         }
         continue;
       }
 
       if (CrawlDatum.hasFetchStatus(datum)) {
-        if (fetch == null) {
-          fetch = datum;
+        if (!fetchSet) {
+          fetch.set(datum);
+          fetchSet = true;
         } else {
           // always take the latest version
-          if (fetch.getFetchTime() < datum.getFetchTime()) fetch = datum;
+          if (fetch.getFetchTime() < datum.getFetchTime()) fetch.set(datum);
         }
         continue;
       }
 
       switch (datum.getStatus()) {                // collect other info
       case CrawlDatum.STATUS_LINKED:
-        linked.add(datum);
+        CrawlDatum link = new CrawlDatum();
+        link.set(datum);
+        linked.add(link);
         break;
       case CrawlDatum.STATUS_SIGNATURE:
         signature = datum.getSignature();
@@ -99,16 +105,17 @@
     }
 
     // if it doesn't already exist, skip it
-    if (old == null && !additionsAllowed) return;
+    if (!oldSet && !additionsAllowed) return;
     
     // if there is no fetched datum, perhaps there is a link
-    if (fetch == null && linked.size() > 0) {
+    if (!fetchSet && linked.size() > 0) {
       fetch = linked.get(0);
+      fetchSet = true;
     }
     
     // still no new data - record only unchanged old data, if exists, and return
-    if (fetch == null) {
-      if (old != null) // at this point at least "old" should be present
+    if (!fetchSet) {
+      if (oldSet) // at this point at least "old" should be present
         output.collect(key, old);
       else
         LOG.warn("Missing fetch and old value, signature=" + signature);
@@ -116,12 +123,12 @@
     }
     
     if (signature == null) signature = fetch.getSignature();
-    long prevModifiedTime = old != null ? old.getModifiedTime() : 0L;
-    long prevFetchTime = old != null ? old.getFetchTime() : 0L;
+    long prevModifiedTime = oldSet ? old.getModifiedTime() : 0L;
+    long prevFetchTime = oldSet ? old.getFetchTime() : 0L;
 
     // initialize with the latest version, be it fetch or link
     result.set(fetch);
-    if (old != null) {
+    if (oldSet) {
       // copy metadata from old, if exists
       if (old.getMetaData().size() > 0) {
         result.getMetaData().putAll(old.getMetaData());
@@ -138,7 +145,7 @@
     switch (fetch.getStatus()) {                // determine new status
 
     case CrawlDatum.STATUS_LINKED:                // it was link
-      if (old != null) {                          // if old exists
+      if (oldSet) {                          // if old exists
         result.set(old);                          // use it
       } else {
         result = schedule.initializeSchedule((Text)key, result);
@@ -164,7 +171,7 @@
       if (fetch.getStatus() == CrawlDatum.STATUS_FETCH_NOTMODIFIED) {
         modified = FetchSchedule.STATUS_NOTMODIFIED;
       } else {
-        if (old != null && old.getSignature() != null && signature != null) {
+        if (oldSet && old.getSignature() != null && signature != null) {
           if (SignatureComparator._compare(old.getSignature(), signature) != 0) {
             modified = FetchSchedule.STATUS_MODIFIED;
           } else {
@@ -178,7 +185,7 @@
       // set the result status and signature
       if (modified == FetchSchedule.STATUS_NOTMODIFIED) {
         result.setStatus(CrawlDatum.STATUS_DB_NOTMODIFIED);
-        if (old != null) result.setSignature(old.getSignature());
+        if (oldSet) result.setSignature(old.getSignature());
       } else {
         switch (fetch.getStatus()) {
         case CrawlDatum.STATUS_FETCH_SUCCESS:
@@ -192,7 +199,7 @@
           break;
         default:
           LOG.warn("Unexpected status: " + fetch.getStatus() + " resetting to old status.");
-          if (old != null) result.setStatus(old.getStatus());
+          if (oldSet) result.setStatus(old.getStatus());
           else result.setStatus(CrawlDatum.STATUS_DB_UNFETCHED);
         }
         result.setSignature(signature);
@@ -210,7 +217,7 @@
       }   
       return;
     case CrawlDatum.STATUS_FETCH_RETRY:           // temporary failure
-      if (old != null) {
+      if (oldSet) {
         result.setSignature(old.getSignature());  // use old signature
       }
       result = schedule.setPageRetrySchedule((Text)key, result, prevFetchTime,
@@ -223,7 +230,7 @@
       break;
 
     case CrawlDatum.STATUS_FETCH_GONE:            // permanent failure
-      if (old != null)
+      if (oldSet)
         result.setSignature(old.getSignature());  // use old signature
       result.setStatus(CrawlDatum.STATUS_DB_GONE);
       result = schedule.setPageGoneSchedule((Text)key, result, prevFetchTime,
@@ -235,7 +242,7 @@
     }
 
     try {
-      scfilters.updateDbScore((Text)key, old, result, linked);
+      scfilters.updateDbScore((Text)key, oldSet ? old : null, result, linked);
     } catch (Exception e) {
       if (LOG.isWarnEnabled()) {
         LOG.warn("Couldn't update score, key=" + key + ": " + e);

Modified: lucene/nutch/trunk/src/java/org/apache/nutch/crawl/Generator.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/java/org/apache/nutch/crawl/Generator.java?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
--- lucene/nutch/trunk/src/java/org/apache/nutch/crawl/Generator.java (original)
+++ lucene/nutch/trunk/src/java/org/apache/nutch/crawl/Generator.java Mon Jul 21 12:20:21 2008
@@ -339,24 +339,25 @@
         output.collect((Text)key, (CrawlDatum)value);
       }
     }
+    private CrawlDatum orig = new CrawlDatum();
+    private LongWritable genTime = new LongWritable(0L);
 
     public void reduce(Text key, Iterator<CrawlDatum> values, OutputCollector<Text, CrawlDatum> output, Reporter reporter) throws IOException {
-      CrawlDatum orig = null;
-      LongWritable genTime = null;
       while (values.hasNext()) {
         CrawlDatum val = values.next();
         if (val.getMetaData().containsKey(Nutch.WRITABLE_GENERATE_TIME_KEY)) {
-          genTime = (LongWritable)val.getMetaData().get(Nutch.WRITABLE_GENERATE_TIME_KEY);
+          LongWritable gt = (LongWritable)val.getMetaData().get(Nutch.WRITABLE_GENERATE_TIME_KEY);
+          genTime.set(gt.get());
           if (genTime.get() != generateTime) {
-            orig = val;
-            genTime = null;
+            orig.set(val);
+            genTime.set(0L);
             continue;
           }
         } else {
-          orig = val;
+          orig.set(val);
         }
       }
-      if (genTime != null) {
+      if (genTime.get() != 0L) {
         orig.getMetaData().put(Nutch.WRITABLE_GENERATE_TIME_KEY, genTime);
       }
       output.collect(key, orig);
@@ -440,14 +441,14 @@
     job.setLong(CRAWL_TOP_N, topN);
     job.setBoolean(CRAWL_GENERATE_FILTER, filter);
 
-    job.setInputPath(new Path(dbDir, CrawlDb.CURRENT_NAME));
+    FileInputFormat.addInputPath(job, new Path(dbDir, CrawlDb.CURRENT_NAME));
     job.setInputFormat(SequenceFileInputFormat.class);
 
     job.setMapperClass(Selector.class);
     job.setPartitionerClass(Selector.class);
     job.setReducerClass(Selector.class);
 
-    job.setOutputPath(tempDir);
+    FileOutputFormat.setOutputPath(job, tempDir);
     job.setOutputFormat(SequenceFileOutputFormat.class);
     job.setOutputKeyClass(FloatWritable.class);
     job.setOutputKeyComparatorClass(DecreasingFloatComparator.class);
@@ -476,7 +477,7 @@
     if (empty) {
       LOG.warn("Generator: 0 records selected for fetching, exiting ...");
       LockUtil.removeLockFile(fs, lock);
-      fs.delete(tempDir);
+      fs.delete(tempDir, true);
       return null;
     }
 
@@ -489,7 +490,7 @@
     
     job.setInt("partition.url.by.host.seed", new Random().nextInt());
 
-    job.setInputPath(tempDir);
+    FileInputFormat.addInputPath(job, tempDir);
     job.setInputFormat(SequenceFileInputFormat.class);
 
     job.setMapperClass(SelectorInverseMapper.class);
@@ -499,7 +500,7 @@
     job.setReducerClass(PartitionReducer.class);
     job.setNumReduceTasks(numLists);
 
-    job.setOutputPath(output);
+    FileOutputFormat.setOutputPath(job, output);
     job.setOutputFormat(SequenceFileOutputFormat.class);
     job.setOutputKeyClass(Text.class);
     job.setOutputValueClass(CrawlDatum.class);
@@ -508,7 +509,7 @@
       JobClient.runJob(job);
     } catch (IOException e) {
       LockUtil.removeLockFile(fs, lock);
-      fs.delete(tempDir);
+      fs.delete(tempDir, true);
       throw e;
     }
     if (getConf().getBoolean(GENERATE_UPDATE_CRAWLDB, false)) {
@@ -520,28 +521,28 @@
       job = new NutchJob(getConf());
       job.setJobName("generate: updatedb " + dbDir);
       job.setLong(Nutch.GENERATE_TIME_KEY, generateTime);
-      job.addInputPath(tempDir);
-      job.addInputPath(new Path(dbDir, CrawlDb.CURRENT_NAME));
+      FileInputFormat.addInputPath(job, tempDir);
+      FileInputFormat.addInputPath(job, new Path(dbDir, CrawlDb.CURRENT_NAME));
       job.setInputFormat(SequenceFileInputFormat.class);
       job.setMapperClass(CrawlDbUpdater.class);
       job.setReducerClass(CrawlDbUpdater.class);
       job.setOutputFormat(MapFileOutputFormat.class);
       job.setOutputKeyClass(Text.class);
       job.setOutputValueClass(CrawlDatum.class);
-      job.setOutputPath(tempDir2);
+      FileOutputFormat.setOutputPath(job, tempDir2);
       try {
         JobClient.runJob(job);
         CrawlDb.install(job, dbDir);
       } catch (IOException e) {
         LockUtil.removeLockFile(fs, lock);
-        fs.delete(tempDir);
-        fs.delete(tempDir2);
+        fs.delete(tempDir, true);
+        fs.delete(tempDir2, true);
         throw e;
       }
-      fs.delete(tempDir2);
+      fs.delete(tempDir2, true);
     }
     LockUtil.removeLockFile(fs, lock);
-    fs.delete(tempDir);
+    fs.delete(tempDir, true);
 
     if (LOG.isInfoEnabled()) { LOG.info("Generator: done."); }
 

Modified: lucene/nutch/trunk/src/java/org/apache/nutch/crawl/Injector.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/java/org/apache/nutch/crawl/Injector.java?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
--- lucene/nutch/trunk/src/java/org/apache/nutch/crawl/Injector.java (original)
+++ lucene/nutch/trunk/src/java/org/apache/nutch/crawl/Injector.java Mon Jul 21 12:20:21 2008
@@ -99,22 +99,25 @@
     public void configure(JobConf job) {}    
     public void close() {}
 
+    private CrawlDatum old = new CrawlDatum();
+    private CrawlDatum injected = new CrawlDatum();
+    
     public void reduce(Text key, Iterator<CrawlDatum> values,
                        OutputCollector<Text, CrawlDatum> output, Reporter reporter)
       throws IOException {
-      CrawlDatum old = null;
-      CrawlDatum injected = null;
+      boolean oldSet = false;
       while (values.hasNext()) {
         CrawlDatum val = values.next();
         if (val.getStatus() == CrawlDatum.STATUS_INJECTED) {
-          injected = val;
+          injected.set(val);
           injected.setStatus(CrawlDatum.STATUS_DB_UNFETCHED);
         } else {
-          old = val;
+          old.set(val);
+          oldSet = true;
         }
       }
       CrawlDatum res = null;
-      if (old != null) res = old; // don't overwrite existing value
+      if (oldSet) res = old; // don't overwrite existing value
       else res = injected;
 
       output.collect(key, res);
@@ -146,10 +149,10 @@
     }
     JobConf sortJob = new NutchJob(getConf());
     sortJob.setJobName("inject " + urlDir);
-    sortJob.setInputPath(urlDir);
+    FileInputFormat.addInputPath(sortJob, urlDir);
     sortJob.setMapperClass(InjectMapper.class);
 
-    sortJob.setOutputPath(tempDir);
+    FileOutputFormat.setOutputPath(sortJob, tempDir);
     sortJob.setOutputFormat(SequenceFileOutputFormat.class);
     sortJob.setOutputKeyClass(Text.class);
     sortJob.setOutputValueClass(CrawlDatum.class);
@@ -161,14 +164,14 @@
       LOG.info("Injector: Merging injected urls into crawl db.");
     }
     JobConf mergeJob = CrawlDb.createJob(getConf(), crawlDb);
-    mergeJob.addInputPath(tempDir);
+    FileInputFormat.addInputPath(mergeJob, tempDir);
     mergeJob.setReducerClass(InjectReducer.class);
     JobClient.runJob(mergeJob);
     CrawlDb.install(mergeJob, crawlDb);
 
     // clean up
     FileSystem fs = FileSystem.get(getConf());
-    fs.delete(tempDir);
+    fs.delete(tempDir, true);
     if (LOG.isInfoEnabled()) { LOG.info("Injector: done"); }
 
   }

Modified: lucene/nutch/trunk/src/java/org/apache/nutch/crawl/LinkDb.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/java/org/apache/nutch/crawl/LinkDb.java?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
--- lucene/nutch/trunk/src/java/org/apache/nutch/crawl/LinkDb.java (original)
+++ lucene/nutch/trunk/src/java/org/apache/nutch/crawl/LinkDb.java Mon Jul 21 12:20:21 2008
@@ -164,7 +164,7 @@
       if (LOG.isInfoEnabled()) {
         LOG.info("LinkDb: adding segment: " + segments[i]);
       }
-      job.addInputPath(new Path(segments[i], ParseData.DIR_NAME));
+      FileInputFormat.addInputPath(job, new Path(segments[i], ParseData.DIR_NAME));
     }
     try {
       JobClient.runJob(job);
@@ -177,18 +177,18 @@
         LOG.info("LinkDb: merging with existing linkdb: " + linkDb);
       }
       // try to merge
-      Path newLinkDb = job.getOutputPath();
+      Path newLinkDb = FileOutputFormat.getOutputPath(job);
       job = LinkDbMerger.createMergeJob(getConf(), linkDb, normalize, filter);
-      job.addInputPath(currentLinkDb);
-      job.addInputPath(newLinkDb);
+      FileInputFormat.addInputPath(job, currentLinkDb);
+      FileInputFormat.addInputPath(job, newLinkDb);
       try {
         JobClient.runJob(job);
       } catch (IOException e) {
         LockUtil.removeLockFile(fs, lock);
-        fs.delete(newLinkDb);
+        fs.delete(newLinkDb, true);
         throw e;
       }
-      fs.delete(newLinkDb);
+      fs.delete(newLinkDb, true);
     }
     LinkDb.install(job, linkDb);
     if (LOG.isInfoEnabled()) { LOG.info("LinkDb: done"); }
@@ -220,7 +220,7 @@
     }
     job.setReducerClass(LinkDbMerger.class);
 
-    job.setOutputPath(newLinkDb);
+    FileOutputFormat.setOutputPath(job, newLinkDb);
     job.setOutputFormat(MapFileOutputFormat.class);
     job.setBoolean("mapred.output.compress", true);
     job.setOutputKeyClass(Text.class);
@@ -230,17 +230,17 @@
   }
 
   public static void install(JobConf job, Path linkDb) throws IOException {
-    Path newLinkDb = job.getOutputPath();
+    Path newLinkDb = FileOutputFormat.getOutputPath(job);
     FileSystem fs = new JobClient(job).getFs();
     Path old = new Path(linkDb, "old");
     Path current = new Path(linkDb, CURRENT_NAME);
     if (fs.exists(current)) {
-      if (fs.exists(old)) fs.delete(old);
+      if (fs.exists(old)) fs.delete(old, true);
       fs.rename(current, old);
     }
     fs.mkdirs(linkDb);
     fs.rename(newLinkDb, current);
-    if (fs.exists(old)) fs.delete(old);
+    if (fs.exists(old)) fs.delete(old, true);
     LockUtil.removeLockFile(fs, new Path(linkDb, LOCK_NAME));
   }
 

Modified: lucene/nutch/trunk/src/java/org/apache/nutch/crawl/LinkDbFilter.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/java/org/apache/nutch/crawl/LinkDbFilter.java?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
--- lucene/nutch/trunk/src/java/org/apache/nutch/crawl/LinkDbFilter.java (original)
+++ lucene/nutch/trunk/src/java/org/apache/nutch/crawl/LinkDbFilter.java Mon Jul 21 12:20:21 2008
@@ -23,8 +23,6 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.io.Text;
-import org.apache.hadoop.io.Writable;
-import org.apache.hadoop.io.WritableComparable;
 import org.apache.hadoop.mapred.JobConf;
 import org.apache.hadoop.mapred.Mapper;
 import org.apache.hadoop.mapred.OutputCollector;
@@ -38,7 +36,7 @@
  * 
  * @author Andrzej Bialecki
  */
-public class LinkDbFilter implements Mapper {
+public class LinkDbFilter implements Mapper<Text, Inlinks, Text, Inlinks> {
   public static final String URL_FILTERING = "linkdb.url.filters";
 
   public static final String URL_NORMALIZING = "linkdb.url.normalizer";
@@ -73,7 +71,8 @@
 
   public void close() {}
 
-  public void map(WritableComparable key, Writable value, OutputCollector output, Reporter reporter) throws IOException {
+  public void map(Text key, Inlinks value,
+      OutputCollector<Text, Inlinks> output, Reporter reporter) throws IOException {
     String url = key.toString();
     Inlinks result = new Inlinks();
     if (normalize) {
@@ -93,8 +92,7 @@
       }
     }
     if (url == null) return; // didn't pass the filters
-    Inlinks inlinks = (Inlinks)value;
-    Iterator<Inlink> it = inlinks.iterator();
+    Iterator<Inlink> it = value.iterator();
     String fromUrl = null;
     while (it.hasNext()) {
       Inlink inlink = it.next();

Modified: lucene/nutch/trunk/src/java/org/apache/nutch/crawl/LinkDbMerger.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/java/org/apache/nutch/crawl/LinkDbMerger.java?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
--- lucene/nutch/trunk/src/java/org/apache/nutch/crawl/LinkDbMerger.java (original)
+++ lucene/nutch/trunk/src/java/org/apache/nutch/crawl/LinkDbMerger.java Mon Jul 21 12:20:21 2008
@@ -28,6 +28,8 @@
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.io.Text;
+import org.apache.hadoop.mapred.FileInputFormat;
+import org.apache.hadoop.mapred.FileOutputFormat;
 import org.apache.hadoop.mapred.JobClient;
 import org.apache.hadoop.mapred.JobConf;
 import org.apache.hadoop.mapred.MapFileOutputFormat;
@@ -100,12 +102,12 @@
   public void merge(Path output, Path[] dbs, boolean normalize, boolean filter) throws Exception {
     JobConf job = createMergeJob(getConf(), output, normalize, filter);
     for (int i = 0; i < dbs.length; i++) {
-      job.addInputPath(new Path(dbs[i], LinkDb.CURRENT_NAME));      
+      FileInputFormat.addInputPath(job, new Path(dbs[i], LinkDb.CURRENT_NAME));      
     }
     JobClient.runJob(job);
     FileSystem fs = FileSystem.get(getConf());
     fs.mkdirs(output);
-    fs.rename(job.getOutputPath(), new Path(output, LinkDb.CURRENT_NAME));
+    fs.rename(FileOutputFormat.getOutputPath(job), new Path(output, LinkDb.CURRENT_NAME));
   }
 
   public static JobConf createMergeJob(Configuration config, Path linkDb, boolean normalize, boolean filter) {
@@ -123,7 +125,7 @@
     job.setBoolean(LinkDbFilter.URL_FILTERING, filter);
     job.setReducerClass(LinkDbMerger.class);
 
-    job.setOutputPath(newLinkDb);
+    FileOutputFormat.setOutputPath(job, newLinkDb);
     job.setOutputFormat(MapFileOutputFormat.class);
     job.setBoolean("mapred.output.compress", true);
     job.setOutputKeyClass(Text.class);

Modified: lucene/nutch/trunk/src/java/org/apache/nutch/crawl/LinkDbReader.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/java/org/apache/nutch/crawl/LinkDbReader.java?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
--- lucene/nutch/trunk/src/java/org/apache/nutch/crawl/LinkDbReader.java (original)
+++ lucene/nutch/trunk/src/java/org/apache/nutch/crawl/LinkDbReader.java Mon Jul 21 12:20:21 2008
@@ -99,10 +99,10 @@
     JobConf job = new NutchJob(getConf());
     job.setJobName("read " + linkdb);
 
-    job.addInputPath(new Path(linkdb, LinkDb.CURRENT_NAME));
+    FileInputFormat.addInputPath(job, new Path(linkdb, LinkDb.CURRENT_NAME));
     job.setInputFormat(SequenceFileInputFormat.class);
 
-    job.setOutputPath(outFolder);
+    FileOutputFormat.setOutputPath(job, outFolder);
     job.setOutputFormat(TextOutputFormat.class);
     job.setOutputKeyClass(Text.class);
     job.setOutputValueClass(Inlinks.class);

Modified: lucene/nutch/trunk/src/java/org/apache/nutch/fetcher/Fetcher.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/java/org/apache/nutch/fetcher/Fetcher.java?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
--- lucene/nutch/trunk/src/java/org/apache/nutch/fetcher/Fetcher.java (original)
+++ lucene/nutch/trunk/src/java/org/apache/nutch/fetcher/Fetcher.java Mon Jul 21 12:20:21 2008
@@ -62,7 +62,8 @@
       FileSystem fs = FileSystem.get(job);
       InputSplit[] splits = new InputSplit[files.length];
       for (int i = 0; i < files.length; i++) {
-        splits[i] = new FileSplit(files[i], 0, fs.getFileStatus(files[i]).getLen(), job);
+        splits[i] = new FileSplit(files[i], 0,
+            fs.getFileStatus(files[i]).getLen(), (String[])null);
       }
       return splits;
     }
@@ -519,12 +520,12 @@
     // for politeness, don't permit parallel execution of a single task
     job.setSpeculativeExecution(false);
 
-    job.setInputPath(new Path(segment, CrawlDatum.GENERATE_DIR_NAME));
+    FileInputFormat.addInputPath(job, new Path(segment, CrawlDatum.GENERATE_DIR_NAME));
     job.setInputFormat(InputFormat.class);
 
     job.setMapRunnerClass(Fetcher.class);
 
-    job.setOutputPath(segment);
+    FileOutputFormat.setOutputPath(job, segment);
     job.setOutputFormat(FetcherOutputFormat.class);
     job.setOutputKeyClass(Text.class);
     job.setOutputValueClass(NutchWritable.class);

Modified: lucene/nutch/trunk/src/java/org/apache/nutch/fetcher/Fetcher2.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/java/org/apache/nutch/fetcher/Fetcher2.java?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
--- lucene/nutch/trunk/src/java/org/apache/nutch/fetcher/Fetcher2.java (original)
+++ lucene/nutch/trunk/src/java/org/apache/nutch/fetcher/Fetcher2.java Mon Jul 21 12:20:21 2008
@@ -83,11 +83,12 @@
  * 
  * @author Andrzej Bialecki
  */
-public class Fetcher2 extends Configured implements MapRunnable { 
+public class Fetcher2 extends Configured implements
+    MapRunnable<Text, CrawlDatum, Text, NutchWritable> { 
 
   public static final Log LOG = LogFactory.getLog(Fetcher2.class);
   
-  public static class InputFormat extends SequenceFileInputFormat {
+  public static class InputFormat extends SequenceFileInputFormat<Text, CrawlDatum> {
     /** Don't split inputs, to keep things polite. */
     public InputSplit[] getSplits(JobConf job, int nSplits)
       throws IOException {
@@ -95,13 +96,14 @@
       FileSplit[] splits = new FileSplit[files.length];
       FileSystem fs = FileSystem.get(job);
       for (int i = 0; i < files.length; i++) {
-        splits[i] = new FileSplit(files[i], 0, fs.getFileStatus(files[i]).getLen(), job);
+        splits[i] = new FileSplit(files[i], 0,
+            fs.getFileStatus(files[i]).getLen(), (String[])null);
       }
       return splits;
     }
   }
 
-  private OutputCollector output;
+  private OutputCollector<Text, NutchWritable> output;
   private Reporter reporter;
   
   private String segmentName;
@@ -376,11 +378,12 @@
    * items are consumed by FetcherThread-s.
    */
   private static class QueueFeeder extends Thread {
-    private RecordReader reader;
+    private RecordReader<Text, CrawlDatum> reader;
     private FetchItemQueues queues;
     private int size;
     
-    public QueueFeeder(RecordReader reader, FetchItemQueues queues, int size) {
+    public QueueFeeder(RecordReader<Text, CrawlDatum> reader,
+        FetchItemQueues queues, int size) {
       this.reader = reader;
       this.queues = queues;
       this.size = size;
@@ -681,7 +684,8 @@
           }
           return url;
         } else {
-          CrawlDatum newDatum = new CrawlDatum();
+          CrawlDatum newDatum = new CrawlDatum(CrawlDatum.STATUS_LINKED,
+              datum.getFetchInterval());
           if (reprUrl != null) {
             newDatum.getMetaData().put(Nutch.WRITABLE_REPR_URL_KEY,
                 new Text(reprUrl));
@@ -859,7 +863,8 @@
     return conf.getBoolean("fetcher.store.content", true);
   }
 
-  public void run(RecordReader input, OutputCollector output,
+  public void run(RecordReader<Text, CrawlDatum> input,
+      OutputCollector<Text, NutchWritable> output,
                   Reporter reporter) throws IOException {
 
     this.output = output;
@@ -927,12 +932,12 @@
     // for politeness, don't permit parallel execution of a single task
     job.setSpeculativeExecution(false);
 
-    job.setInputPath(new Path(segment, CrawlDatum.GENERATE_DIR_NAME));
+    FileInputFormat.addInputPath(job, new Path(segment, CrawlDatum.GENERATE_DIR_NAME));
     job.setInputFormat(InputFormat.class);
 
     job.setMapRunnerClass(Fetcher2.class);
 
-    job.setOutputPath(segment);
+    FileOutputFormat.setOutputPath(job, segment);
     job.setOutputFormat(FetcherOutputFormat.class);
     job.setOutputKeyClass(Text.class);
     job.setOutputValueClass(NutchWritable.class);

Modified: lucene/nutch/trunk/src/java/org/apache/nutch/fetcher/FetcherOutputFormat.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/java/org/apache/nutch/fetcher/FetcherOutputFormat.java?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
--- lucene/nutch/trunk/src/java/org/apache/nutch/fetcher/FetcherOutputFormat.java (original)
+++ lucene/nutch/trunk/src/java/org/apache/nutch/fetcher/FetcherOutputFormat.java Mon Jul 21 12:20:21 2008
@@ -25,16 +25,16 @@
 import org.apache.hadoop.fs.Path;
 
 import org.apache.hadoop.io.MapFile;
-import org.apache.hadoop.io.SequenceFile;
-import org.apache.hadoop.io.WritableComparable;
 import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.io.Text;
 import org.apache.hadoop.io.SequenceFile.CompressionType;
 
+import org.apache.hadoop.mapred.FileOutputFormat;
 import org.apache.hadoop.mapred.OutputFormat;
 import org.apache.hadoop.mapred.RecordWriter;
 import org.apache.hadoop.mapred.JobConf;
 import org.apache.hadoop.mapred.Reporter;
+import org.apache.hadoop.mapred.SequenceFileOutputFormat;
 import org.apache.hadoop.util.Progressable;
 
 import org.apache.nutch.parse.Parse;
@@ -42,32 +42,34 @@
 import org.apache.nutch.protocol.Content;
 
 /** Splits FetcherOutput entries into multiple map files. */
-public class FetcherOutputFormat implements OutputFormat {
+public class FetcherOutputFormat implements OutputFormat<Text, NutchWritable> {
 
   public void checkOutputSpecs(FileSystem fs, JobConf job) throws IOException {
-    if (fs.exists(new Path(job.getOutputPath(), CrawlDatum.FETCH_DIR_NAME)))
+    Path out = FileOutputFormat.getOutputPath(job);
+    if (fs.exists(new Path(out, CrawlDatum.FETCH_DIR_NAME)))
       throw new IOException("Segment already fetched!");
   }
 
-  public RecordWriter getRecordWriter(final FileSystem fs,
+  public RecordWriter<Text, NutchWritable> getRecordWriter(final FileSystem fs,
                                       final JobConf job,
                                       final String name,
                                       final Progressable progress) throws IOException {
 
+    Path out = FileOutputFormat.getOutputPath(job);
     final Path fetch =
-      new Path(new Path(job.getOutputPath(), CrawlDatum.FETCH_DIR_NAME), name);
+      new Path(new Path(out, CrawlDatum.FETCH_DIR_NAME), name);
     final Path content =
-      new Path(new Path(job.getOutputPath(), Content.DIR_NAME), name);
+      new Path(new Path(out, Content.DIR_NAME), name);
     
-    final CompressionType compType = SequenceFile.getCompressionType(job);
+    final CompressionType compType = SequenceFileOutputFormat.getOutputCompressionType(job);
 
     final MapFile.Writer fetchOut =
       new MapFile.Writer(job, fs, fetch.toString(), Text.class, CrawlDatum.class,
           compType, progress);
     
-    return new RecordWriter() {
+    return new RecordWriter<Text, NutchWritable>() {
         private MapFile.Writer contentOut;
-        private RecordWriter parseOut;
+        private RecordWriter<Text, Parse> parseOut;
 
         {
           if (Fetcher.isStoringContent(job)) {
@@ -81,17 +83,17 @@
           }
         }
 
-        public void write(WritableComparable key, Writable value)
+        public void write(Text key, NutchWritable value)
           throws IOException {
 
-          Writable w = ((NutchWritable)value).get();
+          Writable w = value.get();
           
           if (w instanceof CrawlDatum)
             fetchOut.append(key, w);
           else if (w instanceof Content)
             contentOut.append(key, w);
           else if (w instanceof Parse)
-            parseOut.write(key, w);
+            parseOut.write(key, (Parse)w);
         }
 
         public void close(Reporter reporter) throws IOException {

Modified: lucene/nutch/trunk/src/java/org/apache/nutch/indexer/DeleteDuplicates.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/java/org/apache/nutch/indexer/DeleteDuplicates.java?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
--- lucene/nutch/trunk/src/java/org/apache/nutch/indexer/DeleteDuplicates.java (original)
+++ lucene/nutch/trunk/src/java/org/apache/nutch/indexer/DeleteDuplicates.java Mon Jul 21 12:20:21 2008
@@ -148,7 +148,7 @@
       Path[] files = listPaths(job);
       InputSplit[] splits = new InputSplit[files.length];
       for (int i = 0; i < files.length; i++) {
-        splits[i] = new FileSplit(files[i], 0, INDEX_LENGTH, job);
+        splits[i] = new FileSplit(files[i], 0, INDEX_LENGTH, (String[])null);
       }
       return splits;
     }
@@ -263,21 +263,19 @@
     
     public void close() {}
     
+    private IndexDoc latest = new IndexDoc();
+    
     public void reduce(Text key, Iterator<IndexDoc> values,
         OutputCollector<MD5Hash, IndexDoc> output, Reporter reporter) throws IOException {
-      IndexDoc latest = null;
+      WritableUtils.cloneInto(latest, values.next());
       while (values.hasNext()) {
         IndexDoc value = values.next();
-        if (latest == null) {
-          latest = value;
-          continue;
-        }
         if (value.time > latest.time) {
           // discard current and use more recent
           latest.keep = false;
           LOG.debug("-discard " + latest + ", keep " + value);
           output.collect(latest.hash, latest);
-          latest = value;
+          WritableUtils.cloneInto(latest, value);
         } else {
           // discard
           value.keep = false;
@@ -301,10 +299,13 @@
     }
     
     public void close() {}
+    
+    private IndexDoc highest = new IndexDoc();
+    
     public void reduce(MD5Hash key, Iterator<IndexDoc> values,
                        OutputCollector<Text, IndexDoc> output, Reporter reporter)
       throws IOException {
-      IndexDoc highest = null;
+      boolean highestSet = false;
       while (values.hasNext()) {
         IndexDoc value = values.next();
         // skip already deleted
@@ -313,8 +314,9 @@
           output.collect(value.url, value);
           continue;
         }
-        if (highest == null) {
-          highest = value;
+        if (!highestSet) {
+          WritableUtils.cloneInto(highest, value);
+          highestSet = true;
           continue;
         }
         IndexDoc toDelete = null, toKeep = null;
@@ -334,7 +336,7 @@
         
         toDelete.keep = false;
         output.collect(toDelete.url, toDelete);
-        highest = toKeep;
+        WritableUtils.cloneInto(highest, toKeep);
       }    
       LOG.debug("-keep " + highest);
       // no need to add this - in phase 2 we only process docs to delete them
@@ -427,7 +429,7 @@
       if (LOG.isInfoEnabled()) {
         LOG.info("Dedup: adding indexes in: " + indexDirs[i]);
       }
-      job.addInputPath(indexDirs[i]);
+      FileInputFormat.addInputPath(job, indexDirs[i]);
     }
     job.setJobName("dedup 1: urls by time");
 
@@ -436,7 +438,7 @@
     job.setMapOutputValueClass(IndexDoc.class);
 
     job.setReducerClass(UrlsReducer.class);
-    job.setOutputPath(outDir1);
+    FileOutputFormat.setOutputPath(job, outDir1);
 
     job.setOutputKeyClass(MD5Hash.class);
     job.setOutputValueClass(IndexDoc.class);
@@ -450,7 +452,7 @@
     job = new NutchJob(getConf());
     job.setJobName("dedup 2: content by hash");
 
-    job.addInputPath(outDir1);
+    FileInputFormat.addInputPath(job, outDir1);
     job.setInputFormat(SequenceFileInputFormat.class);
     job.setMapOutputKeyClass(MD5Hash.class);
     job.setMapOutputValueClass(IndexDoc.class);
@@ -458,7 +460,7 @@
     job.setSpeculativeExecution(false);
     
     job.setReducerClass(HashReducer.class);
-    job.setOutputPath(outDir2);
+    FileOutputFormat.setOutputPath(job, outDir2);
 
     job.setOutputKeyClass(Text.class);
     job.setOutputValueClass(IndexDoc.class);
@@ -467,12 +469,12 @@
     JobClient.runJob(job);
 
     // remove outDir1 - no longer needed
-    fs.delete(outDir1);
+    fs.delete(outDir1, true);
     
     job = new NutchJob(getConf());
     job.setJobName("dedup 3: delete from index(es)");
 
-    job.addInputPath(outDir2);
+    FileInputFormat.addInputPath(job, outDir2);
     job.setInputFormat(SequenceFileInputFormat.class);
     //job.setInputKeyClass(Text.class);
     //job.setInputValueClass(IndexDoc.class);
@@ -487,7 +489,7 @@
 
     JobClient.runJob(job);
 
-    fs.delete(outDir2);
+    fs.delete(outDir2, true);
 
     if (LOG.isInfoEnabled()) { LOG.info("Dedup: done"); }
   }

Modified: lucene/nutch/trunk/src/java/org/apache/nutch/indexer/FsDirectory.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/java/org/apache/nutch/indexer/FsDirectory.java?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
--- lucene/nutch/trunk/src/java/org/apache/nutch/indexer/FsDirectory.java (original)
+++ lucene/nutch/trunk/src/java/org/apache/nutch/indexer/FsDirectory.java Mon Jul 21 12:20:21 2008
@@ -54,15 +54,17 @@
       throw new IOException(directory + " not a directory");
 
     // clear old files
-    Path[] files = fs.listPaths(directory, HadoopFSUtil.getPassAllFilter());
+    FileStatus[] fstats = fs.listStatus(directory, HadoopFSUtil.getPassAllFilter());
+    Path[] files = HadoopFSUtil.getPaths(fstats);
     for (int i = 0; i < files.length; i++) {
-      if (!fs.delete(files[i]))
+      if (!fs.delete(files[i], false))
         throw new IOException("Cannot delete " + files[i]);
     }
   }
 
   public String[] list() throws IOException {
-    Path[] files = fs.listPaths(directory, HadoopFSUtil.getPassAllFilter());
+    FileStatus[] fstats = fs.listStatus(directory, HadoopFSUtil.getPassAllFilter());
+    Path[] files = HadoopFSUtil.getPaths(fstats);
     if (files == null) return null;
 
     String[] result = new String[files.length];
@@ -89,7 +91,7 @@
   }
 
   public void deleteFile(String name) throws IOException {
-    if (!fs.delete(new Path(directory, name)))
+    if (!fs.delete(new Path(directory, name), false))
       throw new IOException("Cannot delete " + name);
   }
 
@@ -98,14 +100,14 @@
     // so we explicitly delete the target first.
     Path target = new Path(directory, to);
     if (fs.exists(target)) {
-      fs.delete(target);
+      fs.delete(target, false);
     }
     fs.rename(new Path(directory, from), target);
   }
 
   public IndexOutput createOutput(String name) throws IOException {
     Path file = new Path(directory, name);
-    if (fs.exists(file) && !fs.delete(file))      // delete existing, if any
+    if (fs.exists(file) && !fs.delete(file, false))      // delete existing, if any
       throw new IOException("Cannot overwrite: " + file);
 
     return new DfsIndexOutput(file, this.ioFileBufferSize);

Modified: lucene/nutch/trunk/src/java/org/apache/nutch/indexer/IndexMerger.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/java/org/apache/nutch/indexer/IndexMerger.java?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
--- lucene/nutch/trunk/src/java/org/apache/nutch/indexer/IndexMerger.java (original)
+++ lucene/nutch/trunk/src/java/org/apache/nutch/indexer/IndexMerger.java Mon Jul 21 12:20:21 2008
@@ -63,7 +63,7 @@
 
     FileSystem localFs = FileSystem.getLocal(getConf());  
     if (localFs.exists(localWorkingDir)) {
-      localFs.delete(localWorkingDir);
+      localFs.delete(localWorkingDir, true);
     }
     localFs.mkdirs(localWorkingDir);
 
@@ -135,7 +135,8 @@
     Path outputIndex = new Path(args[i++]);
 
     for (; i < args.length; i++) {
-      indexDirs.addAll(Arrays.asList(fs.listPaths(new Path(args[i]), HadoopFSUtil.getPassAllFilter())));
+      FileStatus[] fstats = fs.listStatus(new Path(args[i]), HadoopFSUtil.getPassDirectoriesFilter(fs));
+      indexDirs.addAll(Arrays.asList(HadoopFSUtil.getPaths(fstats)));
     }
 
     //
@@ -151,7 +152,7 @@
       LOG.fatal("IndexMerger: " + StringUtils.stringifyException(e));
       return -1;
     } finally {
-      FileSystem.getLocal(getConf()).delete(workDir);
+      FileSystem.getLocal(getConf()).delete(workDir, true);
     }
   }
 }

Modified: lucene/nutch/trunk/src/java/org/apache/nutch/indexer/Indexer.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/java/org/apache/nutch/indexer/Indexer.java?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
--- lucene/nutch/trunk/src/java/org/apache/nutch/indexer/Indexer.java (original)
+++ lucene/nutch/trunk/src/java/org/apache/nutch/indexer/Indexer.java Mon Jul 21 12:20:21 2008
@@ -83,14 +83,14 @@
 
   /** Unwrap Lucene Documents created by reduce and add them to an index. */
   public static class OutputFormat
-    extends org.apache.hadoop.mapred.OutputFormatBase<WritableComparable, LuceneDocumentWrapper> {
+    extends org.apache.hadoop.mapred.FileOutputFormat<WritableComparable, LuceneDocumentWrapper> {
     public RecordWriter<WritableComparable, LuceneDocumentWrapper> getRecordWriter(final FileSystem fs, JobConf job,
                                         String name, final Progressable progress) throws IOException {
-      final Path perm = new Path(job.getOutputPath(), name);
+      final Path perm = new Path(FileOutputFormat.getOutputPath(job), name);
       final Path temp =
         job.getLocalPath("index/_"+Integer.toString(new Random().nextInt()));
 
-      fs.delete(perm);                            // delete old, if any
+      fs.delete(perm, true);                            // delete old, if any
 
       final AnalyzerFactory factory = new AnalyzerFactory(job);
       final IndexWriter writer =                  // build locally first
@@ -290,20 +290,20 @@
       if (LOG.isInfoEnabled()) {
         LOG.info("Indexer: adding segment: " + segments[i]);
       }
-      job.addInputPath(new Path(segments[i], CrawlDatum.FETCH_DIR_NAME));
-      job.addInputPath(new Path(segments[i], CrawlDatum.PARSE_DIR_NAME));
-      job.addInputPath(new Path(segments[i], ParseData.DIR_NAME));
-      job.addInputPath(new Path(segments[i], ParseText.DIR_NAME));
+      FileInputFormat.addInputPath(job, new Path(segments[i], CrawlDatum.FETCH_DIR_NAME));
+      FileInputFormat.addInputPath(job, new Path(segments[i], CrawlDatum.PARSE_DIR_NAME));
+      FileInputFormat.addInputPath(job, new Path(segments[i], ParseData.DIR_NAME));
+      FileInputFormat.addInputPath(job, new Path(segments[i], ParseText.DIR_NAME));
     }
 
-    job.addInputPath(new Path(crawlDb, CrawlDb.CURRENT_NAME));
-    job.addInputPath(new Path(linkDb, LinkDb.CURRENT_NAME));
+    FileInputFormat.addInputPath(job, new Path(crawlDb, CrawlDb.CURRENT_NAME));
+    FileInputFormat.addInputPath(job, new Path(linkDb, LinkDb.CURRENT_NAME));
     job.setInputFormat(SequenceFileInputFormat.class);
 
     job.setMapperClass(Indexer.class);
     job.setReducerClass(Indexer.class);
 
-    job.setOutputPath(indexDir);
+    FileOutputFormat.setOutputPath(job, indexDir);
     job.setOutputFormat(OutputFormat.class);
     job.setOutputKeyClass(Text.class);
     job.setOutputValueClass(NutchWritable.class);

Modified: lucene/nutch/trunk/src/java/org/apache/nutch/parse/Outlink.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/java/org/apache/nutch/parse/Outlink.java?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
--- lucene/nutch/trunk/src/java/org/apache/nutch/parse/Outlink.java (original)
+++ lucene/nutch/trunk/src/java/org/apache/nutch/parse/Outlink.java Mon Jul 21 12:20:21 2008
@@ -21,8 +21,6 @@
 import java.net.MalformedURLException;
 
 import org.apache.hadoop.io.*;
-import org.apache.nutch.net.URLNormalizers;
-import org.apache.hadoop.conf.Configuration;
 
 /* An outgoing link from a page. */
 public class Outlink implements Writable {

Modified: lucene/nutch/trunk/src/java/org/apache/nutch/parse/ParseOutputFormat.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/java/org/apache/nutch/parse/ParseOutputFormat.java?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
--- lucene/nutch/trunk/src/java/org/apache/nutch/parse/ParseOutputFormat.java (original)
+++ lucene/nutch/trunk/src/java/org/apache/nutch/parse/ParseOutputFormat.java Mon Jul 21 12:20:21 2008
@@ -44,7 +44,7 @@
 import org.apache.hadoop.util.Progressable;
 
 /* Parse content in a segment. */
-public class ParseOutputFormat implements OutputFormat {
+public class ParseOutputFormat implements OutputFormat<Text, Parse> {
   private static final Log LOG = LogFactory.getLog(ParseOutputFormat.class);
 
   private URLFilters filters;
@@ -75,11 +75,12 @@
   }
 
   public void checkOutputSpecs(FileSystem fs, JobConf job) throws IOException {
-    if (fs.exists(new Path(job.getOutputPath(), CrawlDatum.PARSE_DIR_NAME)))
+    Path out = FileOutputFormat.getOutputPath(job);
+    if (fs.exists(new Path(out, CrawlDatum.PARSE_DIR_NAME)))
       throw new IOException("Segment already parsed!");
   }
 
-  public RecordWriter getRecordWriter(FileSystem fs, JobConf job,
+  public RecordWriter<Text, Parse> getRecordWriter(FileSystem fs, JobConf job,
                                       String name, Progressable progress) throws IOException {
 
     this.filters = new URLFilters(job);
@@ -90,14 +91,12 @@
     int maxOutlinksPerPage = job.getInt("db.max.outlinks.per.page", 100);
     final int maxOutlinks = (maxOutlinksPerPage < 0) ? Integer.MAX_VALUE
                                                      : maxOutlinksPerPage;
-    final CompressionType compType = SequenceFile.getCompressionType(job);
+    final CompressionType compType = SequenceFileOutputFormat.getOutputCompressionType(job);
+    Path out = FileOutputFormat.getOutputPath(job);
     
-    Path text =
-      new Path(new Path(job.getOutputPath(), ParseText.DIR_NAME), name);
-    Path data =
-      new Path(new Path(job.getOutputPath(), ParseData.DIR_NAME), name);
-    Path crawl =
-      new Path(new Path(job.getOutputPath(), CrawlDatum.PARSE_DIR_NAME), name);
+    Path text = new Path(new Path(out, ParseText.DIR_NAME), name);
+    Path data = new Path(new Path(out, ParseData.DIR_NAME), name);
+    Path crawl = new Path(new Path(out, CrawlDatum.PARSE_DIR_NAME), name);
     
     final MapFile.Writer textOut =
       new MapFile.Writer(job, fs, text.toString(), Text.class, ParseText.class,
@@ -111,13 +110,12 @@
       SequenceFile.createWriter(fs, job, crawl, Text.class, CrawlDatum.class,
           compType, progress);
     
-    return new RecordWriter() {
+    return new RecordWriter<Text, Parse>() {
 
 
-        public void write(WritableComparable key, Writable value)
+        public void write(Text key, Parse parse)
           throws IOException {
           
-          Parse parse = (Parse)value;
           String fromUrl = key.toString();
           String fromHost = null; 
           String toHost = null;          

Modified: lucene/nutch/trunk/src/java/org/apache/nutch/parse/ParseSegment.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/java/org/apache/nutch/parse/ParseSegment.java?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
--- lucene/nutch/trunk/src/java/org/apache/nutch/parse/ParseSegment.java (original)
+++ lucene/nutch/trunk/src/java/org/apache/nutch/parse/ParseSegment.java Mon Jul 21 12:20:21 2008
@@ -38,7 +38,9 @@
 import java.util.Map.Entry;
 
 /* Parse content in a segment. */
-public class ParseSegment extends Configured implements Tool, Mapper<WritableComparable, Content, Text, ParseImpl>, Reducer<Text, Writable, Text, Writable> {
+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);
   
@@ -135,13 +137,13 @@
     JobConf job = new NutchJob(getConf());
     job.setJobName("parse " + segment);
 
-    job.setInputPath(new Path(segment, Content.DIR_NAME));
+    FileInputFormat.addInputPath(job, new Path(segment, Content.DIR_NAME));
     job.set(Nutch.SEGMENT_NAME_KEY, segment.getName());
     job.setInputFormat(SequenceFileInputFormat.class);
     job.setMapperClass(ParseSegment.class);
     job.setReducerClass(ParseSegment.class);
     
-    job.setOutputPath(segment);
+    FileOutputFormat.setOutputPath(job, segment);
     job.setOutputFormat(ParseOutputFormat.class);
     job.setOutputKeyClass(Text.class);
     job.setOutputValueClass(ParseImpl.class);

Modified: lucene/nutch/trunk/src/java/org/apache/nutch/parse/ParseStatus.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/java/org/apache/nutch/parse/ParseStatus.java?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
--- lucene/nutch/trunk/src/java/org/apache/nutch/parse/ParseStatus.java (original)
+++ lucene/nutch/trunk/src/java/org/apache/nutch/parse/ParseStatus.java Mon Jul 21 12:20:21 2008
@@ -24,7 +24,6 @@
 import java.io.DataInput;
 import java.io.DataOutput;
 import java.io.IOException;
-import java.util.Arrays;
 
 import org.apache.hadoop.io.VersionMismatchException;
 import org.apache.hadoop.io.Writable;

Modified: lucene/nutch/trunk/src/java/org/apache/nutch/parse/ParserFactory.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/java/org/apache/nutch/parse/ParserFactory.java?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
--- lucene/nutch/trunk/src/java/org/apache/nutch/parse/ParserFactory.java (original)
+++ lucene/nutch/trunk/src/java/org/apache/nutch/parse/ParserFactory.java Mon Jul 21 12:20:21 2008
@@ -104,7 +104,7 @@
   throws ParserNotFound {
     
     List<Parser> parsers = null;
-    List parserExts = null;
+    List<Extension> parserExts = null;
     
     ObjectCache objectCache = ObjectCache.get(conf);
     

Modified: lucene/nutch/trunk/src/java/org/apache/nutch/searcher/FetchedSegments.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/java/org/apache/nutch/searcher/FetchedSegments.java?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
--- lucene/nutch/trunk/src/java/org/apache/nutch/searcher/FetchedSegments.java (original)
+++ lucene/nutch/trunk/src/java/org/apache/nutch/searcher/FetchedSegments.java Mon Jul 21 12:20:21 2008
@@ -27,6 +27,7 @@
 import org.apache.hadoop.fs.*;
 import org.apache.nutch.protocol.*;
 import org.apache.nutch.parse.*;
+import org.apache.nutch.util.HadoopFSUtil;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.mapred.*;
 import org.apache.hadoop.mapred.lib.*;
@@ -116,7 +117,9 @@
 
   /** Construct given a directory containing fetcher output. */
   public FetchedSegments(FileSystem fs, String segmentsDir, Configuration conf) throws IOException {
-    Path[] segmentDirs = fs.listPaths(new Path(segmentsDir));
+    FileStatus[] fstats = fs.listStatus(new Path(segmentsDir), 
+        HadoopFSUtil.getPassDirectoriesFilter(fs));
+    Path[] segmentDirs = HadoopFSUtil.getPaths(fstats);
     this.summarizer = new SummarizerFactory(conf).getSummarizer();
 
     if (segmentDirs != null) {

Modified: lucene/nutch/trunk/src/java/org/apache/nutch/searcher/NutchBean.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/java/org/apache/nutch/searcher/NutchBean.java?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
--- lucene/nutch/trunk/src/java/org/apache/nutch/searcher/NutchBean.java (original)
+++ lucene/nutch/trunk/src/java/org/apache/nutch/searcher/NutchBean.java Mon Jul 21 12:20:21 2008
@@ -122,7 +122,9 @@
       }
       
       Vector vDirs=new Vector();
-      Path [] directories = fs.listPaths(indexesDir, HadoopFSUtil.getPassDirectoriesFilter(fs));
+      FileStatus[] fstats = fs.listStatus(indexesDir,
+          HadoopFSUtil.getPassDirectoriesFilter(fs));
+      Path [] directories = HadoopFSUtil.getPaths(fstats);
       for(int i = 0; i < directories.length; i++) {
         Path indexdone = new Path(directories[i], Indexer.DONE_NAME);
         if(fs.isFile(indexdone)) {

Modified: lucene/nutch/trunk/src/java/org/apache/nutch/segment/SegmentMerger.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/java/org/apache/nutch/segment/SegmentMerger.java?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
--- lucene/nutch/trunk/src/java/org/apache/nutch/segment/SegmentMerger.java (original)
+++ lucene/nutch/trunk/src/java/org/apache/nutch/segment/SegmentMerger.java Mon Jul 21 12:20:21 2008
@@ -27,6 +27,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configured;
+import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.io.MapFile;
@@ -36,6 +37,8 @@
 import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.io.WritableComparable;
 import org.apache.hadoop.io.SequenceFile.CompressionType;
+import org.apache.hadoop.mapred.FileInputFormat;
+import org.apache.hadoop.mapred.FileOutputFormat;
 import org.apache.hadoop.mapred.FileSplit;
 import org.apache.hadoop.mapred.InputSplit;
 import org.apache.hadoop.mapred.JobClient;
@@ -48,6 +51,7 @@
 import org.apache.hadoop.mapred.Reducer;
 import org.apache.hadoop.mapred.Reporter;
 import org.apache.hadoop.mapred.SequenceFileInputFormat;
+import org.apache.hadoop.mapred.SequenceFileOutputFormat;
 import org.apache.hadoop.mapred.SequenceFileRecordReader;
 import org.apache.hadoop.util.Progressable;
 import org.apache.nutch.crawl.CrawlDatum;
@@ -110,7 +114,9 @@
  * 
  * @author Andrzej Bialecki
  */
-public class SegmentMerger extends Configured implements Mapper, Reducer {
+public class SegmentMerger extends Configured implements
+    Mapper<Text, MetaWrapper, Text, MetaWrapper>,
+    Reducer<Text, MetaWrapper, Text, MetaWrapper> {
   private static final Log LOG = LogFactory.getLog(SegmentMerger.class);
 
   private static final String SEGMENT_PART_KEY = "part";
@@ -125,10 +131,11 @@
    * Wraps inputs in an {@link MetaWrapper}, to permit merging different
    * types in reduce and use additional metadata.
    */
-  public static class ObjectInputFormat extends SequenceFileInputFormat {
+  public static class ObjectInputFormat extends
+    SequenceFileInputFormat<Text, MetaWrapper> {
     
     @Override
-    public RecordReader getRecordReader(InputSplit split,
+    public RecordReader<Text, MetaWrapper> getRecordReader(InputSplit split,
         JobConf job, Reporter reporter) {
 
       reporter.setStatus(split.toString());
@@ -174,12 +181,12 @@
     }
   }
 
-  public static class SegmentOutputFormat extends OutputFormatBase {
+  public static class SegmentOutputFormat extends FileOutputFormat<Text, MetaWrapper> {
     private static final String DEFAULT_SLICE = "default";
     
     @Override
-    public RecordWriter getRecordWriter(final FileSystem fs, final JobConf job, final String name, final Progressable progress) throws IOException {
-      return new RecordWriter() {
+    public RecordWriter<Text, MetaWrapper> getRecordWriter(final FileSystem fs, final JobConf job, final String name, final Progressable progress) throws IOException {
+      return new RecordWriter<Text, MetaWrapper>() {
         MapFile.Writer c_out = null;
         MapFile.Writer f_out = null;
         MapFile.Writer pd_out = null;
@@ -189,9 +196,8 @@
         HashMap sliceWriters = new HashMap();
         String segmentName = job.get("segment.merger.segmentName");
         
-        public void write(WritableComparable key, Writable value) throws IOException {
+        public void write(Text key, MetaWrapper wrapper) throws IOException {
           // unwrap
-          MetaWrapper wrapper = (MetaWrapper)value;
           SegmentPart sp = SegmentPart.parse(wrapper.getMeta(SEGMENT_PART_KEY));
           Writable o = (Writable)wrapper.get();
           String slice = wrapper.getMeta(SEGMENT_SLICE_KEY);
@@ -232,14 +238,15 @@
           SequenceFile.Writer res = (SequenceFile.Writer)sliceWriters.get(slice + dirName);
           if (res != null) return res;
           Path wname;
+          Path out = FileOutputFormat.getOutputPath(job);
           if (slice == DEFAULT_SLICE) {
-            wname = new Path(new Path(new Path(job.getOutputPath(), segmentName), dirName), name);
+            wname = new Path(new Path(new Path(out, segmentName), dirName), name);
           } else {
-            wname = new Path(new Path(new Path(job.getOutputPath(), segmentName + "-" + slice), dirName), name);
+            wname = new Path(new Path(new Path(out, segmentName + "-" + slice), dirName), name);
           }
           res = SequenceFile.createWriter(fs, job, wname, Text.class, 
-                                          CrawlDatum.class, 
-                                          SequenceFile.getCompressionType(job), progress);
+              CrawlDatum.class,
+              SequenceFileOutputFormat.getOutputCompressionType(job), progress);
           sliceWriters.put(slice + dirName, res);
           return res;
         }
@@ -250,12 +257,14 @@
           MapFile.Writer res = (MapFile.Writer)sliceWriters.get(slice + dirName);
           if (res != null) return res;
           Path wname;
+          Path out = FileOutputFormat.getOutputPath(job);
           if (slice == DEFAULT_SLICE) {
-            wname = new Path(new Path(new Path(job.getOutputPath(), segmentName), dirName), name);
+            wname = new Path(new Path(new Path(out, segmentName), dirName), name);
           } else {
-            wname = new Path(new Path(new Path(job.getOutputPath(), segmentName + "-" + slice), dirName), name);
+            wname = new Path(new Path(new Path(out, segmentName + "-" + slice), dirName), name);
           }
-          CompressionType compType = SequenceFile.getCompressionType(job);
+          CompressionType compType = 
+              SequenceFileOutputFormat.getOutputCompressionType(job);
           if (clazz.isAssignableFrom(ParseText.class)) {
             compType = CompressionType.RECORD;
           }
@@ -312,7 +321,8 @@
   
   private Text newKey = new Text();
   
-  public void map(WritableComparable key, Writable value, OutputCollector output, Reporter reporter) throws IOException {
+  public void map(Text key, MetaWrapper value,
+      OutputCollector<Text, MetaWrapper> output, Reporter reporter) throws IOException {
     String url = key.toString();
     if (normalizers != null) {
       try {
@@ -342,7 +352,8 @@
    * important that segments be named in an increasing lexicographic order as
    * their creation time increases.
    */
-  public void reduce(WritableComparable key, Iterator values, OutputCollector output, Reporter reporter) throws IOException {
+  public void reduce(Text key, Iterator<MetaWrapper> values,
+      OutputCollector<Text, MetaWrapper> output, Reporter reporter) throws IOException {
     CrawlDatum lastG = null;
     CrawlDatum lastF = null;
     CrawlDatum lastSig = null;
@@ -358,7 +369,7 @@
     TreeMap<String, ArrayList<CrawlDatum>> linked =
       new TreeMap<String, ArrayList<CrawlDatum>>();
     while (values.hasNext()) {
-      MetaWrapper wrapper = (MetaWrapper)values.next();
+      MetaWrapper wrapper = values.next();
       Object o = wrapper.get();
       String spString = wrapper.getMeta(SEGMENT_PART_KEY);
       if (spString == null) {
@@ -568,33 +579,33 @@
       if (segs[i] == null) continue;
       if (g) {
         Path gDir = new Path(segs[i], CrawlDatum.GENERATE_DIR_NAME);
-        job.addInputPath(gDir);
+        FileInputFormat.addInputPath(job, gDir);
       }
       if (c) {
         Path cDir = new Path(segs[i], Content.DIR_NAME);
-        job.addInputPath(cDir);
+        FileInputFormat.addInputPath(job, cDir);
       }
       if (f) {
         Path fDir = new Path(segs[i], CrawlDatum.FETCH_DIR_NAME);
-        job.addInputPath(fDir);
+        FileInputFormat.addInputPath(job, fDir);
       }
       if (p) {
         Path pDir = new Path(segs[i], CrawlDatum.PARSE_DIR_NAME);
-        job.addInputPath(pDir);
+        FileInputFormat.addInputPath(job, pDir);
       }
       if (pd) {
         Path pdDir = new Path(segs[i], ParseData.DIR_NAME);
-        job.addInputPath(pdDir);
+        FileInputFormat.addInputPath(job, pdDir);
       }
       if (pt) {
         Path ptDir = new Path(segs[i], ParseText.DIR_NAME);
-        job.addInputPath(ptDir);
+        FileInputFormat.addInputPath(job, ptDir);
       }
     }
     job.setInputFormat(ObjectInputFormat.class);
     job.setMapperClass(SegmentMerger.class);
     job.setReducerClass(SegmentMerger.class);
-    job.setOutputPath(out);
+    FileOutputFormat.setOutputPath(job, out);
     job.setOutputKeyClass(Text.class);
     job.setOutputValueClass(MetaWrapper.class);
     job.setOutputFormat(SegmentOutputFormat.class);
@@ -626,7 +637,9 @@
     boolean normalize = false;
     for (int i = 1; i < args.length; i++) {
       if (args[i].equals("-dir")) {
-        Path[] files = fs.listPaths(new Path(args[++i]), HadoopFSUtil.getPassDirectoriesFilter(fs));
+        FileStatus[] fstats = fs.listStatus(new Path(args[++i]),
+            HadoopFSUtil.getPassDirectoriesFilter(fs));
+        Path[] files = HadoopFSUtil.getPaths(fstats);
         for (int j = 0; j < files.length; j++)
           segs.add(files[j]);
       } else if (args[i].equals("-filter")) {

Modified: lucene/nutch/trunk/src/java/org/apache/nutch/segment/SegmentReader.java
URL: http://svn.apache.org/viewvc/lucene/nutch/trunk/src/java/org/apache/nutch/segment/SegmentReader.java?rev=678533&r1=678532&r2=678533&view=diff
==============================================================================
--- lucene/nutch/trunk/src/java/org/apache/nutch/segment/SegmentReader.java (original)
+++ lucene/nutch/trunk/src/java/org/apache/nutch/segment/SegmentReader.java Mon Jul 21 12:20:21 2008
@@ -38,6 +38,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.conf.Configured;
+import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.io.MapFile;
@@ -46,6 +47,7 @@
 import org.apache.hadoop.io.UTF8;
 import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.io.WritableComparable;
+import org.apache.hadoop.mapred.FileOutputFormat;
 import org.apache.hadoop.mapred.JobClient;
 import org.apache.hadoop.mapred.JobConf;
 import org.apache.hadoop.mapred.MapFileOutputFormat;
@@ -69,7 +71,8 @@
 import org.apache.nutch.util.NutchJob;
 
 /** Dump the content of a segment. */
-public class SegmentReader extends Configured implements Reducer {
+public class SegmentReader extends Configured implements
+    Reducer<Text, NutchWritable, Text, Text> {
 
   public static final Log LOG = LogFactory.getLog(SegmentReader.class);
 
@@ -78,31 +81,36 @@
   private boolean co, fe, ge, pa, pd, pt;
   private FileSystem fs;
 
-  public static class InputCompatMapper extends MapReduceBase implements Mapper {
+  public static class InputCompatMapper extends MapReduceBase implements
+      Mapper<WritableComparable, Writable, Text, NutchWritable> {
     private Text newKey = new Text();
 
-    public void map(WritableComparable key, Writable value, OutputCollector collector, Reporter reporter) throws IOException {
+    public void map(WritableComparable key, Writable value,
+        OutputCollector<Text, NutchWritable> collector, Reporter reporter) throws IOException {
       // convert on the fly from old formats with UTF8 keys
       if (key instanceof UTF8) {
         newKey.set(key.toString());
         key = newKey;
       }
-      collector.collect(key, new NutchWritable(value));
+      collector.collect((Text)key, new NutchWritable(value));
     }
     
   }
 
   /** Implements a text output format */
-  public static class TextOutputFormat extends org.apache.hadoop.mapred.OutputFormatBase {
-    public RecordWriter getRecordWriter(final FileSystem fs, JobConf job, String name, final Progressable progress) throws IOException {
+  public static class TextOutputFormat extends
+      FileOutputFormat<WritableComparable, Writable> {
+    public RecordWriter<WritableComparable, Writable> getRecordWriter(
+        final FileSystem fs, JobConf job,
+        String name, final Progressable progress) throws IOException {
 
-      final Path segmentDumpFile = new Path(job.getOutputPath(), name);
+      final Path segmentDumpFile = new Path(FileOutputFormat.getOutputPath(job), name);
 
       // Get the old copy out of the way
-      if (fs.exists(segmentDumpFile)) fs.delete(segmentDumpFile);
+      if (fs.exists(segmentDumpFile)) fs.delete(segmentDumpFile, true);
 
       final PrintStream printStream = new PrintStream(fs.create(segmentDumpFile));
-      return new RecordWriter() {
+      return new RecordWriter<WritableComparable, Writable>() {
         public synchronized void write(WritableComparable key, Writable value) throws IOException {
           printStream.println(value);
         }
@@ -162,14 +170,15 @@
   
   public void close() {}
 
-  public void reduce(WritableComparable key, Iterator values, OutputCollector output, Reporter reporter)
+  public void reduce(Text key, Iterator<NutchWritable> values,
+      OutputCollector<Text, Text> output, Reporter reporter)
           throws IOException {
     StringBuffer dump = new StringBuffer();
 
     dump.append("\nRecno:: ").append(recNo++).append("\n");
     dump.append("URL:: " + key.toString() + "\n");
     while (values.hasNext()) {
-      Writable value = ((NutchWritable) values.next()).get(); // unwrap
+      Writable value = values.next().get(); // unwrap
       if (value instanceof CrawlDatum) {
         dump.append("\nCrawlDatum::\n").append(((CrawlDatum) value).toString());
       } else if (value instanceof Content) {
@@ -219,8 +228,9 @@
     Path dumpFile = new Path(output, job.get("segment.dump.dir", "dump"));
 
     // remove the old file
-    fs.delete(dumpFile);
-    Path[] files = fs.listPaths(tempDir, HadoopFSUtil.getPassAllFilter());
+    fs.delete(dumpFile, true);
+    FileStatus[] fstats = fs.listStatus(tempDir, HadoopFSUtil.getPassAllFilter());
+    Path[] files = HadoopFSUtil.getPaths(fstats);
 
     PrintWriter writer = null;
     int currentRecordNumber = 0;
@@ -559,7 +569,8 @@
           if (args[i] == null) continue;
           if (args[i].equals("-dir")) {
             Path dir = new Path(args[++i]);
-            Path[] files = fs.listPaths(dir, HadoopFSUtil.getPassDirectoriesFilter(fs));
+            FileStatus[] fstats = fs.listStatus(dir, HadoopFSUtil.getPassDirectoriesFilter(fs));
+            Path[] files = HadoopFSUtil.getPaths(fstats);
             if (files != null && files.length > 0) {
               dirs.addAll(Arrays.asList(files));
             }