HDFS-14236. Lazy persist copy/ put fails with ViewFs.

This commit is contained in:
Hanisha Koneru 2019-01-29 16:45:44 -08:00
parent d1714c20e9
commit b3bc94ebfd
1 changed files with 13 additions and 1 deletions

View File

@ -44,6 +44,7 @@
import org.apache.hadoop.fs.permission.AclEntry;
import org.apache.hadoop.fs.permission.AclUtil;
import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.fs.viewfs.NotInMountpointException;
import org.apache.hadoop.io.IOUtils;
import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_DEFAULT;
@ -494,6 +495,17 @@ FSDataOutputStream create(PathData item, boolean lazyPersist,
throws IOException {
try {
if (lazyPersist) {
long defaultBlockSize;
try {
defaultBlockSize = getDefaultBlockSize();
} catch (NotInMountpointException ex) {
// ViewFileSystem#getDefaultBlockSize() throws an exception as it
// needs a target FS to retrive the default block size from.
// Hence, for ViewFs, we should call getDefaultBlockSize with the
// target path.
defaultBlockSize = getDefaultBlockSize(item.path);
}
EnumSet<CreateFlag> createFlags = EnumSet.of(CREATE, LAZY_PERSIST);
return create(item.path,
FsPermission.getFileDefault().applyUMask(
@ -502,7 +514,7 @@ FSDataOutputStream create(PathData item, boolean lazyPersist,
getConf().getInt(IO_FILE_BUFFER_SIZE_KEY,
IO_FILE_BUFFER_SIZE_DEFAULT),
(short) 1,
getDefaultBlockSize(),
defaultBlockSize,
null,
null);
} else {