Pārlūkot izejas kodu

HADOOP-5671. Fix FNF exceptions when copying from old versions of HftpFileSystem. Contributed by Tsz Wo (Nicholas), SZE

git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/branches/branch-0.20@767644 13f79535-47bb-0310-9956-ffa450edef68
Christopher Douglas 16 gadi atpakaļ
vecāks
revīzija
11b0e298da
2 mainītis faili ar 20 papildinājumiem un 2 dzēšanām
  1. 3 1
      CHANGES.txt
  2. 17 1
      src/tools/org/apache/hadoop/tools/DistCp.java

+ 3 - 1
CHANGES.txt

@@ -888,7 +888,6 @@ Release 0.20.0 - 2009-04-15
     HADOOP-5691. Makes org.apache.hadoop.mapreduce.Reducer concrete class 
     instead of abstract. (Amareshwari Sriramadasu via sharad)
 
-
 Release 0.19.2 - Unreleased
 
   BUG FIXES
@@ -965,6 +964,9 @@ Release 0.19.2 - Unreleased
     HADOOP-5551. Prevent directory destruction on file create.
     (Brian Bockelman via shv)
 
+    HADOOP-5671. Fix FNF exceptions when copying from old versions of
+    HftpFileSystem. (Tsz Wo (Nicholas), SZE via cdouglas)
+
 Release 0.19.1 - 2009-02-23 
 
   IMPROVEMENTS

+ 17 - 1
src/tools/org/apache/hadoop/tools/DistCp.java

@@ -1171,9 +1171,25 @@ public class DistCp implements Tool {
       return false;
     }
 
+    //get src checksum
+    final FileChecksum srccs;
+    try {
+      srccs = srcfs.getFileChecksum(srcstatus.getPath());
+    } catch(FileNotFoundException fnfe) {
+      /*
+       * Two possible cases:
+       * (1) src existed once but was deleted between the time period that
+       *     srcstatus was obtained and the try block above.
+       * (2) srcfs does not support file checksum and (incorrectly) throws
+       *     FNFE, e.g. some previous versions of HftpFileSystem.
+       * For case (1), it is okay to return true since src was already deleted.
+       * For case (2), true should be returned.  
+       */
+      return true;
+    }
+
     //compare checksums
     try {
-      final FileChecksum srccs = srcfs.getFileChecksum(srcstatus.getPath());
       final FileChecksum dstcs = dstfs.getFileChecksum(dststatus.getPath());
       //return true if checksum is not supported
       //(i.e. some of the checksums is null)