From 5c2cb63ceb522cba1c17f2fb18c02ecbef777787 Mon Sep 17 00:00:00 2001 From: Uma Maheswara Rao G Date: Sun, 28 Jun 2020 20:35:01 -0700 Subject: [PATCH 1/5] HDFS-15430. create should work when parent dir is internalDir and fallback configured. --- .../hadoop/fs/viewfs/ViewFileSystem.java | 36 +++- .../org/apache/hadoop/fs/viewfs/ViewFs.java | 35 ++++ .../TestViewFileSystemLinkFallback.java | 151 +++++++++++++++++ .../fs/viewfs/TestViewFsLinkFallback.java | 155 ++++++++++++++++++ 4 files changed, 376 insertions(+), 1 deletion(-) 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 39d78cf65012d..1ba7d70ed42b2 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 @@ -1180,7 +1180,41 @@ public FSDataOutputStream append(final Path f, final int bufferSize, 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 { + + if (f != null && 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); + } + + // Just a sanity check. This should not happen. + if (InodeTree.SlashPath.equals(f)) { + throw new FileAlreadyExistsException( + "/ is not a file. The directory / already exist at: " + + theInternalDir.fullPath); + } + + if (this.fsState.getRootFallbackLink() != null) { + 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 c769003aacffa..a978d6b63a3d2 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 @@ -919,6 +919,41 @@ public FSDataOutputStream createInternal(final Path f, FileAlreadyExistsException, FileNotFoundException, ParentNotDirectoryException, UnsupportedFileSystemException, UnresolvedLinkException, IOException { + if (f != null && 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); + } + + // Just a sanity check. This should not happen. + if (InodeTree.SlashPath.equals(f)) { + throw new FileAlreadyExistsException( + "/ is not a file. The directory / already exist at: " + + theInternalDir.fullPath); + } + + if (this.fsState.getRootFallbackLink() != null) { + AbstractFileSystem 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 + .createInternal(fileToCreate, flag, absolutePermission, + bufferSize, replication, blockSize, progress, checksumOpt, + true); + } 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-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLinkFallback.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLinkFallback.java index bec261cf3eb37..182c1189164a0 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLinkFallback.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLinkFallback.java @@ -33,6 +33,7 @@ import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FSDataOutputStream; +import org.apache.hadoop.fs.FileAlreadyExistsException; import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.FileSystemTestHelper; @@ -765,4 +766,154 @@ public void testMkdirsShouldReturnFalseWhenFallbackFSNotAvailable() assertTrue(fsTarget.exists(test)); } } + + /** + * Tests that the create file should be successful when the parent directory + * is same as the existent fallback directory. The new file should be created + * in fallback. + */ + @Test + public void testCreateFileOnInternalMountDirWithSameDirTreeExistInFallback() + throws Exception { + Configuration conf = new Configuration(); + ConfigUtil.addLink(conf, "/user1/hive/warehouse/partition-0", + new Path(targetTestRoot.toString()).toUri()); + Path dir1 = new Path(targetTestRoot, + "fallbackDir/user1/hive/warehouse/partition-0"); + fsTarget.mkdirs(dir1); + Path fallbackTarget = new Path(targetTestRoot, "fallbackDir"); + ConfigUtil.addLinkFallback(conf, fallbackTarget.toUri()); + + try (FileSystem vfs = FileSystem.get(viewFsDefaultClusterUri, conf)) { + Path p = new Path("/user1/hive/warehouse/test.file"); + Path test = Path.mergePaths(fallbackTarget, p); + assertFalse(fsTarget.exists(test)); + assertTrue(fsTarget.exists(test.getParent())); + vfs.createNewFile(p); + assertTrue(fsTarget.exists(test)); + } + } + + /** + * Tests the making of a new directory which is not matching to any of + * internal directory. + */ + @Test + public void testCreateNewFileWithOutMatchingToMountDirOrFallbackDirPath() + throws Exception { + Configuration conf = new Configuration(); + ConfigUtil.addLink(conf, "/user1/hive/warehouse/partition-0", + new Path(targetTestRoot.toString()).toUri()); + Path fallbackTarget = new Path(targetTestRoot, "fallbackDir"); + fsTarget.mkdirs(fallbackTarget); + ConfigUtil.addLinkFallback(conf, fallbackTarget.toUri()); + try (FileSystem vfs = FileSystem.get(viewFsDefaultClusterUri, conf)) { + Path p = new Path("/user2/test.file"); + Path test = Path.mergePaths(fallbackTarget, p); + assertFalse(fsTarget.exists(test)); + // user2 does not exist in fallback + assertFalse(fsTarget.exists(test.getParent())); + vfs.createNewFile(p); + // /user2/test.file should be created in fallback + assertTrue(fsTarget.exists(test)); + } + } + + /** + * Tests the making of a new file on root which is not matching to any of + * fallback files on root. + */ + @Test + public void testCreateFileOnRootWithFallbackEnabled() + throws Exception { + Configuration conf = new Configuration(); + Path fallbackTarget = new Path(targetTestRoot, "fallbackDir"); + fsTarget.mkdirs(fallbackTarget); + + ConfigUtil.addLink(conf, "/user1/hive/", + new Path(targetTestRoot.toString()).toUri()); + ConfigUtil.addLinkFallback(conf, fallbackTarget.toUri()); + + try (FileSystem vfs = FileSystem.get(viewFsDefaultClusterUri, conf)) { + Path p = new Path("/test.file"); + Path test = Path.mergePaths(fallbackTarget, p); + assertFalse(fsTarget.exists(test)); + vfs.createNewFile(p); + // /test.file should be created in fallback + assertTrue(fsTarget.exists(test)); + } + } + + /** + * Tests the create of a file on root where the path is matching to an + * existing file on fallback's file on root. + */ + @Test (expected = FileAlreadyExistsException.class) + public void testCreateFileOnRootWithFallbackWithFileAlreadyExist() + throws Exception { + Configuration conf = new Configuration(); + Path fallbackTarget = new Path(targetTestRoot, "fallbackDir"); + Path testFile = new Path(fallbackTarget, "test.file"); + // pre-creating test file in fallback. + fsTarget.createNewFile(testFile); + + ConfigUtil.addLink(conf, "/user1/hive/", + new Path(targetTestRoot.toString()).toUri()); + ConfigUtil.addLinkFallback(conf, fallbackTarget.toUri()); + + try (FileSystem vfs = FileSystem.get(viewFsDefaultClusterUri, conf)) { + Path p = new Path("/test.file"); + assertTrue(fsTarget.exists(testFile)); + vfs.create(p, false).close(); + } + } + + /** + * Tests the creating of a file where the path is same as mount link path. + */ + @Test(expected= FileAlreadyExistsException.class) + public void testCreateFileWhereThePathIsSameAsItsMountLinkPath() + throws Exception { + Configuration conf = new Configuration(); + Path fallbackTarget = new Path(targetTestRoot, "fallbackDir"); + fsTarget.mkdirs(fallbackTarget); + + ConfigUtil.addLink(conf, "/user1/hive/", + new Path(targetTestRoot.toString()).toUri()); + ConfigUtil.addLinkFallback(conf, fallbackTarget.toUri()); + + try (FileSystem vfs = FileSystem.get(viewFsDefaultClusterUri, conf)) { + Path p = new Path("/user1/hive"); + assertFalse(fsTarget.exists(Path.mergePaths(fallbackTarget, p))); + vfs.create(p).close(); + } + } + + /** + * Tests the create of a file where he path is same as one of of the internal + * dir path should fail. + */ + @Test + public void testCreateFileSameAsInternalDirPath() + throws Exception { + Configuration conf = new Configuration(); + Path fallbackTarget = new Path(targetTestRoot, "fallbackDir"); + fsTarget.mkdirs(fallbackTarget); + ConfigUtil.addLink(conf, "/user1/hive/", + new Path(targetTestRoot.toString()).toUri()); + ConfigUtil.addLinkFallback(conf, fallbackTarget.toUri()); + + try (FileSystem vfs = FileSystem.get(viewFsDefaultClusterUri, conf)) { + Path p = new Path("/user1"); + assertFalse(fsTarget.exists(Path.mergePaths(fallbackTarget, p))); + try { + vfs.createNewFile(p); + Assert.fail("Should fail to create file as this is an internal dir."); + } catch (NotInMountpointException e){ + // This tree is part of internal tree. The above expetion will be thrown + // from getDefaultReplication, getDefaultBlockSize APIs which was called + // in create API. + } + } + } } diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsLinkFallback.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsLinkFallback.java index 49c0957c446d1..b8f0900bba8d0 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsLinkFallback.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsLinkFallback.java @@ -17,6 +17,7 @@ */ package org.apache.hadoop.fs.viewfs; +import static org.apache.hadoop.fs.CreateFlag.CREATE; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -24,12 +25,15 @@ import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; +import java.util.EnumSet; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.AbstractFileSystem; +import org.apache.hadoop.fs.FileAlreadyExistsException; import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.FsConstants; +import org.apache.hadoop.fs.Options; import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.hdfs.DFSConfigKeys; @@ -294,4 +298,155 @@ public void testMkdirShouldFailWhenFallbackFSNotAvailable() assertTrue(fsTarget.exists(test)); } + /** + * Tests that the create file should be successful when the parent directory + * is same as the existent fallback directory. The new file should be created + * in fallback. + */ + @Test + public void testCreateFileOnInternalMountDirWithSameDirTreeExistInFallback() + throws Exception { + Configuration conf = new Configuration(); + ConfigUtil.addLink(conf, "/user1/hive/warehouse/partition-0", + new Path(targetTestRoot.toString()).toUri()); + Path dir1 = new Path(targetTestRoot, + "fallbackDir/user1/hive/warehouse/partition-0"); + fsTarget.mkdirs(dir1); + Path fallbackTarget = new Path(targetTestRoot, "fallbackDir"); + ConfigUtil.addLinkFallback(conf, fallbackTarget.toUri()); + + AbstractFileSystem vfs = + AbstractFileSystem.get(viewFsDefaultClusterUri, conf); + Path p = new Path("/user1/hive/warehouse/test.file"); + Path test = Path.mergePaths(fallbackTarget, p); + assertFalse(fsTarget.exists(test)); + assertTrue(fsTarget.exists(test.getParent())); + vfs.create(p, EnumSet.of(CREATE), + Options.CreateOpts.perms(FsPermission.getDefault())); + assertTrue(fsTarget.exists(test)); + + } + + /** + * Tests the making of a new directory which is not matching to any of + * internal directory. + */ + @Test + public void testCreateNewFileWithOutMatchingToMountDirOrFallbackDirPath() + throws Exception { + Configuration conf = new Configuration(); + ConfigUtil.addLink(conf, "/user1/hive/warehouse/partition-0", + new Path(targetTestRoot.toString()).toUri()); + Path fallbackTarget = new Path(targetTestRoot, "fallbackDir"); + fsTarget.mkdirs(fallbackTarget); + ConfigUtil.addLinkFallback(conf, fallbackTarget.toUri()); + AbstractFileSystem vfs = + AbstractFileSystem.get(viewFsDefaultClusterUri, conf); + Path p = new Path("/user2/test.file"); + Path test = Path.mergePaths(fallbackTarget, p); + assertFalse(fsTarget.exists(test)); + // user2 does not exist in fallback + assertFalse(fsTarget.exists(test.getParent())); + vfs.create(p, EnumSet.of(CREATE), + Options.CreateOpts.perms(FsPermission.getDefault()), + Options.CreateOpts.createParent()); + // /user2/test.file should be created in fallback + assertTrue(fsTarget.exists(test)); + } + + /** + * Tests the making of a new file on root which is not matching to any of + * fallback files on root. + */ + @Test + public void testCreateFileOnRootWithFallbackEnabled() + throws Exception { + Configuration conf = new Configuration(); + Path fallbackTarget = new Path(targetTestRoot, "fallbackDir"); + fsTarget.mkdirs(fallbackTarget); + + ConfigUtil.addLink(conf, "/user1/hive/", + new Path(targetTestRoot.toString()).toUri()); + ConfigUtil.addLinkFallback(conf, fallbackTarget.toUri()); + + AbstractFileSystem vfs = + AbstractFileSystem.get(viewFsDefaultClusterUri, conf); + Path p = new Path("/test.file"); + Path test = Path.mergePaths(fallbackTarget, p); + assertFalse(fsTarget.exists(test)); + vfs.create(p, EnumSet.of(CREATE), + Options.CreateOpts.perms(FsPermission.getDefault())); + // /test.file should be created in fallback + assertTrue(fsTarget.exists(test)); + + } + + /** + * Tests the create of a file on root where the path is matching to an + * existing file on fallback's file on root. + */ + @Test (expected = FileAlreadyExistsException.class) + public void testCreateFileOnRootWithFallbackWithFileAlreadyExist() + throws Exception { + Configuration conf = new Configuration(); + Path fallbackTarget = new Path(targetTestRoot, "fallbackDir"); + Path testFile = new Path(fallbackTarget, "test.file"); + // pre-creating test file in fallback. + fsTarget.createNewFile(testFile); + + ConfigUtil.addLink(conf, "/user1/hive/", + new Path(targetTestRoot.toString()).toUri()); + ConfigUtil.addLinkFallback(conf, fallbackTarget.toUri()); + + AbstractFileSystem vfs = + AbstractFileSystem.get(viewFsDefaultClusterUri, conf); + Path p = new Path("/test.file"); + assertTrue(fsTarget.exists(testFile)); + vfs.create(p, EnumSet.of(CREATE), + Options.CreateOpts.perms(FsPermission.getDefault())); + } + + /** + * Tests the creating of a file where the path is same as mount link path. + */ + @Test(expected= FileAlreadyExistsException.class) + public void testCreateFileWhereThePathIsSameAsItsMountLinkPath() + throws Exception { + Configuration conf = new Configuration(); + Path fallbackTarget = new Path(targetTestRoot, "fallbackDir"); + fsTarget.mkdirs(fallbackTarget); + + ConfigUtil.addLink(conf, "/user1/hive/", + new Path(targetTestRoot.toString()).toUri()); + ConfigUtil.addLinkFallback(conf, fallbackTarget.toUri()); + + AbstractFileSystem vfs = + AbstractFileSystem.get(viewFsDefaultClusterUri, conf); + Path p = new Path("/user1/hive"); + assertFalse(fsTarget.exists(Path.mergePaths(fallbackTarget, p))); + vfs.create(p, EnumSet.of(CREATE), + Options.CreateOpts.perms(FsPermission.getDefault())); + } + + /** + * Tests the create of a file where he path is same as one of of the internal + * dir path should fail. + */ + @Test(expected = FileAlreadyExistsException.class) + public void testCreateFileSameAsInternalDirPath() + throws Exception { + Configuration conf = new Configuration(); + Path fallbackTarget = new Path(targetTestRoot, "fallbackDir"); + fsTarget.mkdirs(fallbackTarget); + ConfigUtil.addLink(conf, "/user1/hive/", + new Path(targetTestRoot.toString()).toUri()); + ConfigUtil.addLinkFallback(conf, fallbackTarget.toUri()); + + AbstractFileSystem vfs = + AbstractFileSystem.get(viewFsDefaultClusterUri, conf); + Path p = new Path("/user1"); + assertFalse(fsTarget.exists(Path.mergePaths(fallbackTarget, p))); + vfs.create(p, EnumSet.of(CREATE), + Options.CreateOpts.perms(FsPermission.getDefault())); + } } From 26829f58f1e57a133143e3444c8b31a77b3d812e Mon Sep 17 00:00:00 2001 From: Uma Maheswara Rao G Date: Tue, 30 Jun 2020 17:20:50 -0700 Subject: [PATCH 2/5] Fix review comments. Also moved child exist check inside fallback condition as we attempt create only in the case of fallback. --- .../hadoop/fs/viewfs/ViewFileSystem.java | 14 ++-- .../org/apache/hadoop/fs/viewfs/ViewFs.java | 13 ++-- .../TestViewFileSystemLinkFallback.java | 60 ++++++++-------- .../fs/viewfs/TestViewFsLinkFallback.java | 68 +++++++++---------- 4 files changed, 78 insertions(+), 77 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 1ba7d70ed42b2..b1cfb77ae4807 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 @@ -1182,12 +1182,6 @@ public FSDataOutputStream create(final Path f, final int bufferSize, final short replication, final long blockSize, final Progressable progress) throws IOException { - if (f != null && 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); - } - // Just a sanity check. This should not happen. if (InodeTree.SlashPath.equals(f)) { throw new FileAlreadyExistsException( @@ -1196,6 +1190,14 @@ public FSDataOutputStream create(final Path f, } if (this.fsState.getRootFallbackLink() != null) { + + if (f != null && 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( 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 a978d6b63a3d2..d5854a14e0d9b 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 @@ -919,12 +919,6 @@ public FSDataOutputStream createInternal(final Path f, FileAlreadyExistsException, FileNotFoundException, ParentNotDirectoryException, UnsupportedFileSystemException, UnresolvedLinkException, IOException { - if (f != null && 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); - } - // Just a sanity check. This should not happen. if (InodeTree.SlashPath.equals(f)) { throw new FileAlreadyExistsException( @@ -933,6 +927,13 @@ public FSDataOutputStream createInternal(final Path f, } if (this.fsState.getRootFallbackLink() != null) { + if (f != null && 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); + } + AbstractFileSystem linkedFallbackFs = this.fsState.getRootFallbackLink().getTargetFileSystem(); Path parent = Path.getPathWithoutSchemeAndAuthority( diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLinkFallback.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLinkFallback.java index 182c1189164a0..2e7ead20a9bc5 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLinkFallback.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLinkFallback.java @@ -785,12 +785,12 @@ public void testCreateFileOnInternalMountDirWithSameDirTreeExistInFallback() ConfigUtil.addLinkFallback(conf, fallbackTarget.toUri()); try (FileSystem vfs = FileSystem.get(viewFsDefaultClusterUri, conf)) { - Path p = new Path("/user1/hive/warehouse/test.file"); - Path test = Path.mergePaths(fallbackTarget, p); - assertFalse(fsTarget.exists(test)); - assertTrue(fsTarget.exists(test.getParent())); - vfs.createNewFile(p); - assertTrue(fsTarget.exists(test)); + Path vfsTestFile = new Path("/user1/hive/warehouse/test.file"); + Path testFileInFallback = Path.mergePaths(fallbackTarget, vfsTestFile); + assertFalse(fsTarget.exists(testFileInFallback)); + assertTrue(fsTarget.exists(testFileInFallback.getParent())); + vfs.create(vfsTestFile).close(); + assertTrue(fsTarget.exists(testFileInFallback)); } } @@ -808,14 +808,14 @@ public void testCreateNewFileWithOutMatchingToMountDirOrFallbackDirPath() fsTarget.mkdirs(fallbackTarget); ConfigUtil.addLinkFallback(conf, fallbackTarget.toUri()); try (FileSystem vfs = FileSystem.get(viewFsDefaultClusterUri, conf)) { - Path p = new Path("/user2/test.file"); - Path test = Path.mergePaths(fallbackTarget, p); - assertFalse(fsTarget.exists(test)); + Path vfsTestFile = new Path("/user2/test.file"); + Path testFileInFallback = Path.mergePaths(fallbackTarget, vfsTestFile); + assertFalse(fsTarget.exists(testFileInFallback)); // user2 does not exist in fallback - assertFalse(fsTarget.exists(test.getParent())); - vfs.createNewFile(p); + assertFalse(fsTarget.exists(testFileInFallback.getParent())); + vfs.create(vfsTestFile).close(); // /user2/test.file should be created in fallback - assertTrue(fsTarget.exists(test)); + assertTrue(fsTarget.exists(testFileInFallback)); } } @@ -824,8 +824,7 @@ public void testCreateNewFileWithOutMatchingToMountDirOrFallbackDirPath() * fallback files on root. */ @Test - public void testCreateFileOnRootWithFallbackEnabled() - throws Exception { + public void testCreateFileOnRootWithFallbackEnabled() throws Exception { Configuration conf = new Configuration(); Path fallbackTarget = new Path(targetTestRoot, "fallbackDir"); fsTarget.mkdirs(fallbackTarget); @@ -835,12 +834,12 @@ public void testCreateFileOnRootWithFallbackEnabled() ConfigUtil.addLinkFallback(conf, fallbackTarget.toUri()); try (FileSystem vfs = FileSystem.get(viewFsDefaultClusterUri, conf)) { - Path p = new Path("/test.file"); - Path test = Path.mergePaths(fallbackTarget, p); - assertFalse(fsTarget.exists(test)); - vfs.createNewFile(p); + Path vfsTestFile = new Path("/test.file"); + Path testFileInFallback = Path.mergePaths(fallbackTarget, vfsTestFile); + assertFalse(fsTarget.exists(testFileInFallback)); + vfs.create(vfsTestFile).close(); // /test.file should be created in fallback - assertTrue(fsTarget.exists(test)); + assertTrue(fsTarget.exists(testFileInFallback)); } } @@ -855,16 +854,16 @@ public void testCreateFileOnRootWithFallbackWithFileAlreadyExist() Path fallbackTarget = new Path(targetTestRoot, "fallbackDir"); Path testFile = new Path(fallbackTarget, "test.file"); // pre-creating test file in fallback. - fsTarget.createNewFile(testFile); + fsTarget.create(testFile).close(); ConfigUtil.addLink(conf, "/user1/hive/", new Path(targetTestRoot.toString()).toUri()); ConfigUtil.addLinkFallback(conf, fallbackTarget.toUri()); try (FileSystem vfs = FileSystem.get(viewFsDefaultClusterUri, conf)) { - Path p = new Path("/test.file"); + Path vfsTestFile = new Path("/test.file"); assertTrue(fsTarget.exists(testFile)); - vfs.create(p, false).close(); + vfs.create(vfsTestFile, false).close(); } } @@ -883,19 +882,18 @@ public void testCreateFileWhereThePathIsSameAsItsMountLinkPath() ConfigUtil.addLinkFallback(conf, fallbackTarget.toUri()); try (FileSystem vfs = FileSystem.get(viewFsDefaultClusterUri, conf)) { - Path p = new Path("/user1/hive"); - assertFalse(fsTarget.exists(Path.mergePaths(fallbackTarget, p))); - vfs.create(p).close(); + Path vfsTestDir = new Path("/user1/hive"); + assertFalse(fsTarget.exists(Path.mergePaths(fallbackTarget, vfsTestDir))); + vfs.create(vfsTestDir).close(); } } /** - * Tests the create of a file where he path is same as one of of the internal + * Tests the create of a file where the path is same as one of of the internal * dir path should fail. */ @Test - public void testCreateFileSameAsInternalDirPath() - throws Exception { + public void testCreateFileSameAsInternalDirPath() throws Exception { Configuration conf = new Configuration(); Path fallbackTarget = new Path(targetTestRoot, "fallbackDir"); fsTarget.mkdirs(fallbackTarget); @@ -904,10 +902,10 @@ public void testCreateFileSameAsInternalDirPath() ConfigUtil.addLinkFallback(conf, fallbackTarget.toUri()); try (FileSystem vfs = FileSystem.get(viewFsDefaultClusterUri, conf)) { - Path p = new Path("/user1"); - assertFalse(fsTarget.exists(Path.mergePaths(fallbackTarget, p))); + Path vfsTestDir = new Path("/user1"); + assertFalse(fsTarget.exists(Path.mergePaths(fallbackTarget, vfsTestDir))); try { - vfs.createNewFile(p); + vfs.create(vfsTestDir); Assert.fail("Should fail to create file as this is an internal dir."); } catch (NotInMountpointException e){ // This tree is part of internal tree. The above expetion will be thrown diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsLinkFallback.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsLinkFallback.java index b8f0900bba8d0..d768b98f4bf12 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsLinkFallback.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsLinkFallback.java @@ -317,13 +317,13 @@ public void testCreateFileOnInternalMountDirWithSameDirTreeExistInFallback() AbstractFileSystem vfs = AbstractFileSystem.get(viewFsDefaultClusterUri, conf); - Path p = new Path("/user1/hive/warehouse/test.file"); - Path test = Path.mergePaths(fallbackTarget, p); - assertFalse(fsTarget.exists(test)); - assertTrue(fsTarget.exists(test.getParent())); - vfs.create(p, EnumSet.of(CREATE), - Options.CreateOpts.perms(FsPermission.getDefault())); - assertTrue(fsTarget.exists(test)); + Path vfsTestFile = new Path("/user1/hive/warehouse/test.file"); + Path testFileInFallback = Path.mergePaths(fallbackTarget, vfsTestFile); + assertFalse(fsTarget.exists(testFileInFallback)); + assertTrue(fsTarget.exists(testFileInFallback.getParent())); + vfs.create(vfsTestFile, EnumSet.of(CREATE), + Options.CreateOpts.perms(FsPermission.getDefault())).close(); + assertTrue(fsTarget.exists(testFileInFallback)); } @@ -342,16 +342,16 @@ public void testCreateNewFileWithOutMatchingToMountDirOrFallbackDirPath() ConfigUtil.addLinkFallback(conf, fallbackTarget.toUri()); AbstractFileSystem vfs = AbstractFileSystem.get(viewFsDefaultClusterUri, conf); - Path p = new Path("/user2/test.file"); - Path test = Path.mergePaths(fallbackTarget, p); - assertFalse(fsTarget.exists(test)); + Path vfsTestFile = new Path("/user2/test.file"); + Path testFileInFallback = Path.mergePaths(fallbackTarget, vfsTestFile); + assertFalse(fsTarget.exists(testFileInFallback)); // user2 does not exist in fallback - assertFalse(fsTarget.exists(test.getParent())); - vfs.create(p, EnumSet.of(CREATE), + assertFalse(fsTarget.exists(testFileInFallback.getParent())); + vfs.create(vfsTestFile, EnumSet.of(CREATE), Options.CreateOpts.perms(FsPermission.getDefault()), - Options.CreateOpts.createParent()); + Options.CreateOpts.createParent()).close(); // /user2/test.file should be created in fallback - assertTrue(fsTarget.exists(test)); + assertTrue(fsTarget.exists(testFileInFallback)); } /** @@ -371,13 +371,13 @@ public void testCreateFileOnRootWithFallbackEnabled() AbstractFileSystem vfs = AbstractFileSystem.get(viewFsDefaultClusterUri, conf); - Path p = new Path("/test.file"); - Path test = Path.mergePaths(fallbackTarget, p); - assertFalse(fsTarget.exists(test)); - vfs.create(p, EnumSet.of(CREATE), - Options.CreateOpts.perms(FsPermission.getDefault())); + Path vfsTestFile = new Path("/test.file"); + Path testFileInFallback = Path.mergePaths(fallbackTarget, vfsTestFile); + assertFalse(fsTarget.exists(testFileInFallback)); + vfs.create(vfsTestFile, EnumSet.of(CREATE), + Options.CreateOpts.perms(FsPermission.getDefault())).close(); // /test.file should be created in fallback - assertTrue(fsTarget.exists(test)); + assertTrue(fsTarget.exists(testFileInFallback)); } @@ -392,7 +392,7 @@ public void testCreateFileOnRootWithFallbackWithFileAlreadyExist() Path fallbackTarget = new Path(targetTestRoot, "fallbackDir"); Path testFile = new Path(fallbackTarget, "test.file"); // pre-creating test file in fallback. - fsTarget.createNewFile(testFile); + fsTarget.create(testFile).close(); ConfigUtil.addLink(conf, "/user1/hive/", new Path(targetTestRoot.toString()).toUri()); @@ -400,10 +400,10 @@ public void testCreateFileOnRootWithFallbackWithFileAlreadyExist() AbstractFileSystem vfs = AbstractFileSystem.get(viewFsDefaultClusterUri, conf); - Path p = new Path("/test.file"); - assertTrue(fsTarget.exists(testFile)); - vfs.create(p, EnumSet.of(CREATE), - Options.CreateOpts.perms(FsPermission.getDefault())); + Path vfsTestFile = new Path("/test.file"); + assertTrue(fsTarget.exists(testFile)); + vfs.create(vfsTestFile, EnumSet.of(CREATE), + Options.CreateOpts.perms(FsPermission.getDefault())).close(); } /** @@ -422,14 +422,14 @@ public void testCreateFileWhereThePathIsSameAsItsMountLinkPath() AbstractFileSystem vfs = AbstractFileSystem.get(viewFsDefaultClusterUri, conf); - Path p = new Path("/user1/hive"); - assertFalse(fsTarget.exists(Path.mergePaths(fallbackTarget, p))); - vfs.create(p, EnumSet.of(CREATE), - Options.CreateOpts.perms(FsPermission.getDefault())); + Path vfsTestDir = new Path("/user1/hive"); + assertFalse(fsTarget.exists(Path.mergePaths(fallbackTarget, vfsTestDir))); + vfs.create(vfsTestDir, EnumSet.of(CREATE), + Options.CreateOpts.perms(FsPermission.getDefault())).close(); } /** - * Tests the create of a file where he path is same as one of of the internal + * Tests the create of a file where the path is same as one of of the internal * dir path should fail. */ @Test(expected = FileAlreadyExistsException.class) @@ -444,9 +444,9 @@ public void testCreateFileSameAsInternalDirPath() AbstractFileSystem vfs = AbstractFileSystem.get(viewFsDefaultClusterUri, conf); - Path p = new Path("/user1"); - assertFalse(fsTarget.exists(Path.mergePaths(fallbackTarget, p))); - vfs.create(p, EnumSet.of(CREATE), - Options.CreateOpts.perms(FsPermission.getDefault())); + Path vfsTestDir = new Path("/user1"); + assertFalse(fsTarget.exists(Path.mergePaths(fallbackTarget, vfsTestDir))); + vfs.create(vfsTestDir, EnumSet.of(CREATE), + Options.CreateOpts.perms(FsPermission.getDefault())).close(); } } From 7c719a4777a304cd7e48f64a20119817367278c7 Mon Sep 17 00:00:00 2001 From: Uma Maheswara Rao G Date: Tue, 30 Jun 2020 17:26:37 -0700 Subject: [PATCH 3/5] Fixed a review comment. --- .../hadoop/fs/viewfs/TestViewFileSystemLinkFallback.java | 5 ++--- .../org/apache/hadoop/fs/viewfs/TestViewFsLinkFallback.java | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLinkFallback.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLinkFallback.java index 2e7ead20a9bc5..61680a37a0726 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLinkFallback.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLinkFallback.java @@ -778,10 +778,9 @@ public void testCreateFileOnInternalMountDirWithSameDirTreeExistInFallback() Configuration conf = new Configuration(); ConfigUtil.addLink(conf, "/user1/hive/warehouse/partition-0", new Path(targetTestRoot.toString()).toUri()); - Path dir1 = new Path(targetTestRoot, - "fallbackDir/user1/hive/warehouse/partition-0"); - fsTarget.mkdirs(dir1); Path fallbackTarget = new Path(targetTestRoot, "fallbackDir"); + Path dir1 = new Path(fallbackTarget, "user1/hive/warehouse/partition-0"); + fsTarget.mkdirs(dir1); ConfigUtil.addLinkFallback(conf, fallbackTarget.toUri()); try (FileSystem vfs = FileSystem.get(viewFsDefaultClusterUri, conf)) { diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsLinkFallback.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsLinkFallback.java index d768b98f4bf12..04d26b983ed6d 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsLinkFallback.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFsLinkFallback.java @@ -309,10 +309,9 @@ public void testCreateFileOnInternalMountDirWithSameDirTreeExistInFallback() Configuration conf = new Configuration(); ConfigUtil.addLink(conf, "/user1/hive/warehouse/partition-0", new Path(targetTestRoot.toString()).toUri()); - Path dir1 = new Path(targetTestRoot, - "fallbackDir/user1/hive/warehouse/partition-0"); - fsTarget.mkdirs(dir1); Path fallbackTarget = new Path(targetTestRoot, "fallbackDir"); + Path dir1 = new Path(fallbackTarget, "user1/hive/warehouse/partition-0"); + fsTarget.mkdirs(dir1); ConfigUtil.addLinkFallback(conf, fallbackTarget.toUri()); AbstractFileSystem vfs = From 3225add901ca57103cceb7ab752ad4c9c292790f Mon Sep 17 00:00:00 2001 From: Uma Maheswara Rao G Date: Wed, 1 Jul 2020 10:11:18 -0700 Subject: [PATCH 4/5] Addressed an invalid findbugs to make findbugs happy and removed a redundant test --- .../hadoop/fs/viewfs/ViewFileSystem.java | 6 ++-- .../org/apache/hadoop/fs/viewfs/ViewFs.java | 6 ++-- ...ileSystemOverloadSchemeWithHdfsScheme.java | 28 ------------------- 3 files changed, 7 insertions(+), 33 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 b1cfb77ae4807..d1b47cb807f02 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.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; @@ -1181,7 +1182,7 @@ 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 IOException { - + Preconditions.checkNotNull(f, "File cannot be null."); // Just a sanity check. This should not happen. if (InodeTree.SlashPath.equals(f)) { throw new FileAlreadyExistsException( @@ -1191,8 +1192,7 @@ public FSDataOutputStream create(final Path f, if (this.fsState.getRootFallbackLink() != null) { - if (f != null && theInternalDir.getChildren() - .containsKey(f.getName())) { + 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); 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 d5854a14e0d9b..a6e19185d5293 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.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,7 @@ public FSDataOutputStream createInternal(final Path f, FileAlreadyExistsException, FileNotFoundException, ParentNotDirectoryException, UnsupportedFileSystemException, UnresolvedLinkException, IOException { + Preconditions.checkNotNull(f, "File cannot be null."); // Just a sanity check. This should not happen. if (InodeTree.SlashPath.equals(f)) { throw new FileAlreadyExistsException( @@ -927,8 +930,7 @@ public FSDataOutputStream createInternal(final Path f, } if (this.fsState.getRootFallbackLink() != null) { - if (f != null && theInternalDir.getChildren() - .containsKey(f.getName())) { + 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); diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemOverloadSchemeWithHdfsScheme.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemOverloadSchemeWithHdfsScheme.java index f0f3aae1ba6c0..a44af768bdcd5 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemOverloadSchemeWithHdfsScheme.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemOverloadSchemeWithHdfsScheme.java @@ -39,7 +39,6 @@ import org.apache.hadoop.hdfs.DFSConfigKeys; import org.apache.hadoop.hdfs.DistributedFileSystem; import org.apache.hadoop.hdfs.MiniDFSCluster; -import org.apache.hadoop.security.AccessControlException; import org.apache.hadoop.test.PathUtils; import org.junit.After; import org.junit.Assert; @@ -346,33 +345,6 @@ public void testCreateOnRootShouldFailWhenMountLinkConfigured() } } - /** - * Create mount links as follows - * hdfs://localhost:xxx/HDFSUser --> hdfs://localhost:xxx/HDFSUser/ - * hdfs://localhost:xxx/local --> file://TEST_ROOT_DIR/root/ - * fallback --> hdfs://localhost:xxx/HDFSUser/ - * - * It will find fallback link, but root is not accessible and read only. - */ - @Test(expected = AccessControlException.class, timeout = 30000) - public void testCreateOnRootShouldFailEvenFallBackMountLinkConfigured() - throws Exception { - final Path hdfsTargetPath = new Path(defaultFSURI + HDFS_USER_FOLDER); - addMountLinks(defaultFSURI.getAuthority(), - new String[] {HDFS_USER_FOLDER, LOCAL_FOLDER, - Constants.CONFIG_VIEWFS_LINK_FALLBACK }, - new String[] {hdfsTargetPath.toUri().toString(), - localTargetDir.toURI().toString(), - hdfsTargetPath.toUri().toString() }, - conf); - try (FileSystem fs = FileSystem.get(conf)) { - fs.createNewFile(new Path("/onRootWhenFallBack")); - Assert.fail( - "It should fail as root is read only in viewFS, even when configured" - + " with fallback."); - } - } - /** * Create mount links as follows * hdfs://localhost:xxx/HDFSUser --> hdfs://localhost:xxx/HDFSUser/ From ad777c0deb49286f01c9becb04b340a0774c0045 Mon Sep 17 00:00:00 2001 From: Uma Maheswara Rao G Date: Sat, 4 Jul 2020 00:03:27 -0700 Subject: [PATCH 5/5] HDFS-15430. Few comments corrected --- .../java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java | 1 - .../src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java | 1 - .../hadoop/fs/viewfs/TestViewFileSystemLinkFallback.java | 6 +++--- 3 files changed, 3 insertions(+), 5 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 d1b47cb807f02..cb3696507afd9 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 @@ -1183,7 +1183,6 @@ public FSDataOutputStream create(final Path f, final int bufferSize, final short replication, final long blockSize, final Progressable progress) throws IOException { Preconditions.checkNotNull(f, "File cannot be null."); - // Just a sanity check. This should not happen. if (InodeTree.SlashPath.equals(f)) { throw new FileAlreadyExistsException( "/ is not a file. The directory / already exist at: " 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 a6e19185d5293..a63960c55de0c 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 @@ -922,7 +922,6 @@ public FSDataOutputStream createInternal(final Path f, ParentNotDirectoryException, UnsupportedFileSystemException, UnresolvedLinkException, IOException { Preconditions.checkNotNull(f, "File cannot be null."); - // Just a sanity check. This should not happen. if (InodeTree.SlashPath.equals(f)) { throw new FileAlreadyExistsException( "/ is not a file. The directory / already exist at: " diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLinkFallback.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLinkFallback.java index 61680a37a0726..bd2b5af02ad87 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLinkFallback.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/fs/viewfs/TestViewFileSystemLinkFallback.java @@ -907,9 +907,9 @@ public void testCreateFileSameAsInternalDirPath() throws Exception { vfs.create(vfsTestDir); Assert.fail("Should fail to create file as this is an internal dir."); } catch (NotInMountpointException e){ - // This tree is part of internal tree. The above expetion will be thrown - // from getDefaultReplication, getDefaultBlockSize APIs which was called - // in create API. + // This tree is part of internal tree. The above exception will be + // thrown from getDefaultReplication, getDefaultBlockSize APIs which was + // called in create API. } } }