HADOOP-16255. Add ChecksumFs.rename(path, path, boolean). Contributed by Jungtaek Lim.

This commit is contained in:
Kihwal Lee 2020-06-08 17:31:16 -05:00
parent 6eb7c28293
commit 14ff6171a5
1 changed files with 26 additions and 0 deletions

View File

@ -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.