Przeglądaj źródła

HADOOP-730. Use renameTo rather than copy for local renames.


git-svn-id: https://svn.apache.org/repos/asf/hadoop/core/trunk@634417 13f79535-47bb-0310-9956-ffa450edef68
Christopher Douglas 17 lat temu
rodzic
commit
68c71c8700

+ 2 - 0
CHANGES.txt

@@ -66,6 +66,8 @@ Trunk (unreleased changes)
     HADOOP-2833. Do not use "Dr. Who" as the default user in JobClient. 
     A valid user name is required. (Tsz Wo (Nicholas), SZE via rangadi)
 
+    HADOOP-730. Use rename rather than copy for local renames. (cdouglas)
+
   OPTIMIZATIONS
 
     HADOOP-2790.  Fixed inefficient method hasSpeculativeTask by removing

+ 4 - 5
src/java/org/apache/hadoop/fs/RawLocalFileSystem.java

@@ -42,8 +42,6 @@ public class RawLocalFileSystem extends FileSystem {
   TreeMap<File, FileOutputStream> nonsharedLockDataSet =
     new TreeMap<File, FileOutputStream>();
   TreeMap<File, FileLock> lockObjSet = new TreeMap<File, FileLock>();
-  // by default use copy/delete instead of rename
-  boolean useCopyForRename = true;
   
   public RawLocalFileSystem() {
     workingDir = new Path(System.getProperty("user.dir")).makeQualified(this);
@@ -207,9 +205,10 @@ public class RawLocalFileSystem extends FileSystem {
   }
   
   public boolean rename(Path src, Path dst) throws IOException {
-    if (useCopyForRename) {
-      return FileUtil.copy(this, src, this, dst, true, getConf());
-    } else return pathToFile(src).renameTo(pathToFile(dst));
+    if (pathToFile(src).renameTo(pathToFile(dst))) {
+      return true;
+    }
+    return FileUtil.copy(this, src, this, dst, true, getConf());
   }
   
   public boolean delete(Path p) throws IOException {