You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ki...@apache.org on 2020/06/08 22:33:56 UTC

[hadoop] branch branch-2.10 updated: HADOOP-16255. Add ChecksumFs.rename(path, path, boolean). Contributed by Jungtaek Lim.

This is an automated email from the ASF dual-hosted git repository.

kihwal pushed a commit to branch branch-2.10
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/branch-2.10 by this push:
     new 14ff617  HADOOP-16255. Add ChecksumFs.rename(path, path, boolean). Contributed by Jungtaek Lim.
14ff617 is described below

commit 14ff6171a5879f63c1188b07cff8cbe135b9f802
Author: Kihwal Lee <ki...@apache.org>
AuthorDate: Mon Jun 8 17:31:16 2020 -0500

    HADOOP-16255. Add ChecksumFs.rename(path, path, boolean). Contributed by Jungtaek Lim.
---
 .../main/java/org/apache/hadoop/fs/ChecksumFs.java | 26 ++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ChecksumFs.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ChecksumFs.java
index e006c13..b0fdf01 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ChecksumFs.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/ChecksumFs.java
@@ -472,6 +472,32 @@ public abstract class ChecksumFs extends FilterFs {
     }
   }
 
+  @Override
+  public void renameInternal(Path src, Path dst, boolean overwrite)
+      throws AccessControlException, FileAlreadyExistsException,
+      FileNotFoundException, ParentNotDirectoryException,
+      UnresolvedLinkException, IOException {
+    Options.Rename renameOpt = Options.Rename.NONE;
+    if (overwrite) {
+      renameOpt = Options.Rename.OVERWRITE;
+    }
+
+    if (isDirectory(src)) {
+      getMyFs().rename(src, dst, renameOpt);
+    } else {
+      getMyFs().rename(src, dst, renameOpt);
+
+      Path checkFile = getChecksumFile(src);
+      if (exists(checkFile)) { //try to rename checksum
+        if (isDirectory(dst)) {
+          getMyFs().rename(checkFile, dst, renameOpt);
+        } else {
+          getMyFs().rename(checkFile, getChecksumFile(dst), renameOpt);
+        }
+      }
+    }
+  }
+
   /**
    * Implement the delete(Path, boolean) in checksum
    * file system.


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org