[hadoop] branch branch-3.3 updated: HDFS-15430. create should work when parent dir is internalDir and fallback configured. Contributed by Uma Maheswara Rao G.
This is an automated email from the ASF dual-hosted git repository. umamahesh pushed a commit to branch branch-3.3 in repository https://gitbox.apache.org/repos/asf/hadoop.git The following commit(s) were added to refs/heads/branch-3.3 by this push: new 35fe6fd HDFS-15430. create should work when parent dir is internalDir and fallback configured. Contributed by Uma Maheswara Rao G. 35fe6fd is described below commit 35fe6fd54fdc935ed73fa080925c812fe6f493a2 Author: Uma Maheswara Rao G AuthorDate: Sat Jul 4 00:12:10 2020 -0700 HDFS-15430. create should work when parent dir is internalDir and fallback configured. Contributed by Uma Maheswara Rao G. (cherry picked from commit 1f2a80b5e5024aeb7fb1f8c31b8fdd0fdb88bb66) --- .../apache/hadoop/fs/viewfs/ViewFileSystem.java| 37 - .../java/org/apache/hadoop/fs/viewfs/ViewFs.java | 37 + .../fs/viewfs/TestViewFileSystemLinkFallback.java | 148 ...ViewFileSystemOverloadSchemeWithHdfsScheme.java | 28 .../hadoop/fs/viewfs/TestViewFsLinkFallback.java | 154 + 5 files changed, 375 insertions(+), 29 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java index 39d78cf..cb36965 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java @@ -41,6 +41,7 @@ import java.util.Map.Entry; import java.util.Objects; import java.util.Set; +import com.google.common.base.Preconditions; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.conf.Configuration; @@ -1180,7 +1181,41 @@ public class ViewFileSystem extends FileSystem { public FSDataOutputStream create(final Path f, final FsPermission permission, final boolean overwrite, final int bufferSize, final short replication, final long blockSize, -final Progressable progress) throws AccessControlException { +final Progressable progress) throws IOException { + Preconditions.checkNotNull(f, "File cannot be null."); + if (InodeTree.SlashPath.equals(f)) { +throw new FileAlreadyExistsException( +"/ is not a file. The directory / already exist at: " ++ theInternalDir.fullPath); + } + + if (this.fsState.getRootFallbackLink() != null) { + +if (theInternalDir.getChildren().containsKey(f.getName())) { + throw new FileAlreadyExistsException( + "A mount path(file/dir) already exist with the requested path: " + + theInternalDir.getChildren().get(f.getName()).fullPath); +} + +FileSystem linkedFallbackFs = +this.fsState.getRootFallbackLink().getTargetFileSystem(); +Path parent = Path.getPathWithoutSchemeAndAuthority( +new Path(theInternalDir.fullPath)); +String leaf = f.getName(); +Path fileToCreate = new Path(parent, leaf); + +try { + return linkedFallbackFs + .create(fileToCreate, permission, overwrite, bufferSize, + replication, blockSize, progress); +} catch (IOException e) { + StringBuilder msg = + new StringBuilder("Failed to create file:").append(fileToCreate) + .append(" at fallback : ").append(linkedFallbackFs.getUri()); + LOG.error(msg.toString(), e); + throw e; +} + } throw readOnlyMountTable("create", f); } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java index c769003..a63960c 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java @@ -33,6 +33,8 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; + +import com.google.common.base.Preconditions; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.conf.Configuration; @@ -919,6 +921,41 @@ public class ViewFs extends AbstractFileSystem { FileAlreadyExistsException, FileNotFoundException, ParentNotDirectoryException, UnsupportedFileSystemException, UnresolvedLinkException, IOException { + Preconditions.checkNotNull(f, "File cannot be null."); + if (InodeTree.SlashPath.equals(f)) { +throw new FileAlreadyExistsException( +"/ is not a file. The directory / already exist at: " +
[hadoop] branch branch-3.3 updated: HDFS-15430. create should work when parent dir is internalDir and fallback configured. Contributed by Uma Maheswara Rao G.
This is an automated email from the ASF dual-hosted git repository. umamahesh pushed a commit to branch branch-3.3 in repository https://gitbox.apache.org/repos/asf/hadoop.git The following commit(s) were added to refs/heads/branch-3.3 by this push: new 35fe6fd HDFS-15430. create should work when parent dir is internalDir and fallback configured. Contributed by Uma Maheswara Rao G. 35fe6fd is described below commit 35fe6fd54fdc935ed73fa080925c812fe6f493a2 Author: Uma Maheswara Rao G AuthorDate: Sat Jul 4 00:12:10 2020 -0700 HDFS-15430. create should work when parent dir is internalDir and fallback configured. Contributed by Uma Maheswara Rao G. (cherry picked from commit 1f2a80b5e5024aeb7fb1f8c31b8fdd0fdb88bb66) --- .../apache/hadoop/fs/viewfs/ViewFileSystem.java| 37 - .../java/org/apache/hadoop/fs/viewfs/ViewFs.java | 37 + .../fs/viewfs/TestViewFileSystemLinkFallback.java | 148 ...ViewFileSystemOverloadSchemeWithHdfsScheme.java | 28 .../hadoop/fs/viewfs/TestViewFsLinkFallback.java | 154 + 5 files changed, 375 insertions(+), 29 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java index 39d78cf..cb36965 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java @@ -41,6 +41,7 @@ import java.util.Map.Entry; import java.util.Objects; import java.util.Set; +import com.google.common.base.Preconditions; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.conf.Configuration; @@ -1180,7 +1181,41 @@ public class ViewFileSystem extends FileSystem { public FSDataOutputStream create(final Path f, final FsPermission permission, final boolean overwrite, final int bufferSize, final short replication, final long blockSize, -final Progressable progress) throws AccessControlException { +final Progressable progress) throws IOException { + Preconditions.checkNotNull(f, "File cannot be null."); + if (InodeTree.SlashPath.equals(f)) { +throw new FileAlreadyExistsException( +"/ is not a file. The directory / already exist at: " ++ theInternalDir.fullPath); + } + + if (this.fsState.getRootFallbackLink() != null) { + +if (theInternalDir.getChildren().containsKey(f.getName())) { + throw new FileAlreadyExistsException( + "A mount path(file/dir) already exist with the requested path: " + + theInternalDir.getChildren().get(f.getName()).fullPath); +} + +FileSystem linkedFallbackFs = +this.fsState.getRootFallbackLink().getTargetFileSystem(); +Path parent = Path.getPathWithoutSchemeAndAuthority( +new Path(theInternalDir.fullPath)); +String leaf = f.getName(); +Path fileToCreate = new Path(parent, leaf); + +try { + return linkedFallbackFs + .create(fileToCreate, permission, overwrite, bufferSize, + replication, blockSize, progress); +} catch (IOException e) { + StringBuilder msg = + new StringBuilder("Failed to create file:").append(fileToCreate) + .append(" at fallback : ").append(linkedFallbackFs.getUri()); + LOG.error(msg.toString(), e); + throw e; +} + } throw readOnlyMountTable("create", f); } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java index c769003..a63960c 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java @@ -33,6 +33,8 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; + +import com.google.common.base.Preconditions; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; import org.apache.hadoop.conf.Configuration; @@ -919,6 +921,41 @@ public class ViewFs extends AbstractFileSystem { FileAlreadyExistsException, FileNotFoundException, ParentNotDirectoryException, UnsupportedFileSystemException, UnresolvedLinkException, IOException { + Preconditions.checkNotNull(f, "File cannot be null."); + if (InodeTree.SlashPath.equals(f)) { +throw new FileAlreadyExistsException( +"/ is not a file. The directory / already exist at: " +