Bläddra i källkod

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.19@767645 13f79535-47bb-0310-9956-ffa450edef68
Christopher Douglas 16 år sedan
förälder
incheckning
64f3080a44
2 ändrade filer med 20 tillägg och 1 borttagningar
  1. 3 0
      CHANGES.txt
  2. 17 1
      src/tools/org/apache/hadoop/tools/DistCp.java

+ 3 - 0
CHANGES.txt

@@ -101,6 +101,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 
 
     HADOOP-5225. Workaround for tmp file handling in HDFS. sync() is 

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

@@ -1161,9 +1161,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)