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

View File

@ -44,6 +44,7 @@
import org.apache.hadoop.fs.permission.AclEntry; import org.apache.hadoop.fs.permission.AclEntry;
import org.apache.hadoop.fs.permission.AclUtil; import org.apache.hadoop.fs.permission.AclUtil;
import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.fs.viewfs.NotInMountpointException;
import org.apache.hadoop.io.IOUtils; import org.apache.hadoop.io.IOUtils;
import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_DEFAULT; import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.IO_FILE_BUFFER_SIZE_DEFAULT;
@ -494,6 +495,17 @@ FSDataOutputStream create(PathData item, boolean lazyPersist,
throws IOException { throws IOException {
try { try {
if (lazyPersist) { 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); EnumSet<CreateFlag> createFlags = EnumSet.of(CREATE, LAZY_PERSIST);
return create(item.path, return create(item.path,
FsPermission.getFileDefault().applyUMask( FsPermission.getFileDefault().applyUMask(
@ -502,7 +514,7 @@ FSDataOutputStream create(PathData item, boolean lazyPersist,
getConf().getInt(IO_FILE_BUFFER_SIZE_KEY, getConf().getInt(IO_FILE_BUFFER_SIZE_KEY,
IO_FILE_BUFFER_SIZE_DEFAULT), IO_FILE_BUFFER_SIZE_DEFAULT),
(short) 1, (short) 1,
getDefaultBlockSize(), defaultBlockSize,
null, null,
null); null);
} else { } else {