From 14ff6171a5879f63c1188b07cff8cbe135b9f802 Mon Sep 17 00:00:00 2001 From: Kihwal Lee Date: Mon, 8 Jun 2020 17:31:16 -0500 Subject: [PATCH] HADOOP-16255. Add ChecksumFs.rename(path, path, boolean). Contributed by Jungtaek Lim. --- .../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 e006c137c7b..b0fdf013627 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.