[27/35] hadoop git commit: HDFS-13109. Support fully qualified hdfs path in EZ commands. Contributed by Hanisha Koneru.
HDFS-13109. Support fully qualified hdfs path in EZ commands. Contributed by Hanisha Koneru. Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/edf94457 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/edf94457 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/edf94457 Branch: refs/heads/HDFS-7240 Commit: edf9445708ffb7a9e59cb933e049b540f99add1e Parents: 346caa2 Author: Xiaoyu Yao Authored: Tue Mar 6 16:44:20 2018 -0800 Committer: Xiaoyu Yao Committed: Tue Mar 6 16:44:20 2018 -0800 -- .../hadoop/hdfs/DistributedFileSystem.java | 65 .../apache/hadoop/hdfs/client/HdfsAdmin.java| 46 +- .../apache/hadoop/hdfs/TestEncryptionZones.java | 44 + 3 files changed, 111 insertions(+), 44 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hadoop/blob/edf94457/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java -- diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java index fe2a565..03cb317 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java @@ -37,6 +37,7 @@ import org.apache.hadoop.fs.FSDataInputStream; import org.apache.hadoop.fs.FSDataOutputStream; import org.apache.hadoop.fs.FSDataOutputStreamBuilder; import org.apache.hadoop.fs.FSLinkResolver; +import org.apache.hadoop.fs.FileAlreadyExistsException; import org.apache.hadoop.fs.FileChecksum; import org.apache.hadoop.fs.FileEncryptionInfo; import org.apache.hadoop.fs.FileStatus; @@ -2600,6 +2601,70 @@ public class DistributedFileSystem extends FileSystem }.resolve(this, absF); } + /* HDFS only */ + public void provisionEZTrash(final Path path, + final FsPermission trashPermission) throws IOException { +Path absF = fixRelativePart(path); +new FileSystemLinkResolver() { + @Override + public Void doCall(Path p) throws IOException { +provisionEZTrash(getPathName(p), trashPermission); +return null; + } + + @Override + public Void next(FileSystem fs, Path p) throws IOException { +if (fs instanceof DistributedFileSystem) { + DistributedFileSystem myDfs = (DistributedFileSystem)fs; + myDfs.provisionEZTrash(p, trashPermission); + return null; +} +throw new UnsupportedOperationException("Cannot provisionEZTrash " + +"through a symlink to a non-DistributedFileSystem: " + fs + " -> " ++ p); + } +}.resolve(this, absF); + } + + private void provisionEZTrash(String path, FsPermission trashPermission) + throws IOException { +// make sure the path is an EZ +EncryptionZone ez = dfs.getEZForPath(path); +if (ez == null) { + throw new IllegalArgumentException(path + " is not an encryption zone."); +} + +String ezPath = ez.getPath(); +if (!path.toString().equals(ezPath)) { + throw new IllegalArgumentException(path + " is not the root of an " + + "encryption zone. Do you mean " + ez.getPath() + "?"); +} + +// check if the trash directory exists +Path trashPath = new Path(ez.getPath(), FileSystem.TRASH_PREFIX); +try { + FileStatus trashFileStatus = getFileStatus(trashPath); + String errMessage = "Will not provision new trash directory for " + + "encryption zone " + ez.getPath() + ". Path already exists."; + if (!trashFileStatus.isDirectory()) { +errMessage += "\r\n" + +"Warning: " + trashPath.toString() + " is not a directory"; + } + if (!trashFileStatus.getPermission().equals(trashPermission)) { +errMessage += "\r\n" + +"Warning: the permission of " + +trashPath.toString() + " is not " + trashPermission; + } + throw new FileAlreadyExistsException(errMessage); +} catch (FileNotFoundException ignored) { + // no trash path +} + +// Update the permission bits +mkdir(trashPath, trashPermission); +setPermission(trashPath, trashPermission); + } + @Override public void setXAttr(Path path, final String name, final byte[] value, final EnumSet flag) throws IOException { http://git-wip-us.apache.org/repos/asf/hadoop/blob/edf94457/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/client/HdfsAdmin.java -- diff --git a/
hadoop git commit: HDFS-13109. Support fully qualified hdfs path in EZ commands. Contributed by Hanisha Koneru.
Repository: hadoop Updated Branches: refs/heads/branch-2 4f3c4e451 -> 313fdb996 HDFS-13109. Support fully qualified hdfs path in EZ commands. Contributed by Hanisha Koneru. (cherry picked from commit edf9445708ffb7a9e59cb933e049b540f99add1e) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/313fdb99 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/313fdb99 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/313fdb99 Branch: refs/heads/branch-2 Commit: 313fdb9968c950560a79323484a8ee9218c077e9 Parents: 4f3c4e4 Author: Xiaoyu Yao Authored: Tue Mar 6 16:44:20 2018 -0800 Committer: Xiaoyu Yao Committed: Tue Mar 6 20:01:51 2018 -0800 -- .../hadoop/hdfs/DistributedFileSystem.java | 65 .../apache/hadoop/hdfs/client/HdfsAdmin.java| 46 +- .../apache/hadoop/hdfs/TestEncryptionZones.java | 44 + 3 files changed, 111 insertions(+), 44 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hadoop/blob/313fdb99/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java -- diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java index 497f770..46df7d5 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java @@ -43,6 +43,7 @@ import org.apache.hadoop.fs.FSDataInputStream; import org.apache.hadoop.fs.FSDataOutputStream; import org.apache.hadoop.fs.FSDataOutputStreamBuilder; import org.apache.hadoop.fs.FSLinkResolver; +import org.apache.hadoop.fs.FileAlreadyExistsException; import org.apache.hadoop.fs.FileChecksum; import org.apache.hadoop.fs.FileEncryptionInfo; import org.apache.hadoop.fs.FileStatus; @@ -2395,6 +2396,70 @@ public class DistributedFileSystem extends FileSystem }.resolve(this, absF); } + /* HDFS only */ + public void provisionEZTrash(final Path path, + final FsPermission trashPermission) throws IOException { +Path absF = fixRelativePart(path); +new FileSystemLinkResolver() { + @Override + public Void doCall(Path p) throws IOException { +provisionEZTrash(getPathName(p), trashPermission); +return null; + } + + @Override + public Void next(FileSystem fs, Path p) throws IOException { +if (fs instanceof DistributedFileSystem) { + DistributedFileSystem myDfs = (DistributedFileSystem)fs; + myDfs.provisionEZTrash(p, trashPermission); + return null; +} +throw new UnsupportedOperationException("Cannot provisionEZTrash " + +"through a symlink to a non-DistributedFileSystem: " + fs + " -> " ++ p); + } +}.resolve(this, absF); + } + + private void provisionEZTrash(String path, FsPermission trashPermission) + throws IOException { +// make sure the path is an EZ +EncryptionZone ez = dfs.getEZForPath(path); +if (ez == null) { + throw new IllegalArgumentException(path + " is not an encryption zone."); +} + +String ezPath = ez.getPath(); +if (!path.toString().equals(ezPath)) { + throw new IllegalArgumentException(path + " is not the root of an " + + "encryption zone. Do you mean " + ez.getPath() + "?"); +} + +// check if the trash directory exists +Path trashPath = new Path(ez.getPath(), FileSystem.TRASH_PREFIX); +try { + FileStatus trashFileStatus = getFileStatus(trashPath); + String errMessage = "Will not provision new trash directory for " + + "encryption zone " + ez.getPath() + ". Path already exists."; + if (!trashFileStatus.isDirectory()) { +errMessage += "\r\n" + +"Warning: " + trashPath.toString() + " is not a directory"; + } + if (!trashFileStatus.getPermission().equals(trashPermission)) { +errMessage += "\r\n" + +"Warning: the permission of " + +trashPath.toString() + " is not " + trashPermission; + } + throw new FileAlreadyExistsException(errMessage); +} catch (FileNotFoundException ignored) { + // no trash path +} + +// Update the permission bits +mkdir(trashPath, trashPermission); +setPermission(trashPath, trashPermission); + } + @Override public void setXAttr(Path path, final String name, final byte[] value, final EnumSet flag) throws IOException { http://git-wip-us.apache.org/repos/asf/hadoop/blob/313fdb99/hadoop-hdfs-project/hadoop-hdf
hadoop git commit: HDFS-13109. Support fully qualified hdfs path in EZ commands. Contributed by Hanisha Koneru.
Repository: hadoop Updated Branches: refs/heads/branch-2.8 749e106c1 -> 4b0b466f8 HDFS-13109. Support fully qualified hdfs path in EZ commands. Contributed by Hanisha Koneru. (cherry picked from commit edf9445708ffb7a9e59cb933e049b540f99add1e) (cherry picked from commit 321766bcc8f8c7ac3d0091a065ccabf8a16c13c5) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/4b0b466f Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/4b0b466f Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/4b0b466f Branch: refs/heads/branch-2.8 Commit: 4b0b466f83584aa7f87da61029b918ea530fc8fd Parents: 749e106 Author: Xiaoyu Yao Authored: Tue Mar 6 16:44:20 2018 -0800 Committer: Xiaoyu Yao Committed: Tue Mar 6 19:35:17 2018 -0800 -- .../hadoop/hdfs/DistributedFileSystem.java | 65 .../apache/hadoop/hdfs/client/HdfsAdmin.java| 45 +- .../apache/hadoop/hdfs/TestEncryptionZones.java | 44 + 3 files changed, 112 insertions(+), 42 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hadoop/blob/4b0b466f/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java -- diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java index 50a2576..d8a7419 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java @@ -41,6 +41,7 @@ import org.apache.hadoop.fs.CreateFlag; import org.apache.hadoop.fs.FSDataInputStream; import org.apache.hadoop.fs.FSDataOutputStream; import org.apache.hadoop.fs.FSLinkResolver; +import org.apache.hadoop.fs.FileAlreadyExistsException; import org.apache.hadoop.fs.FileChecksum; import org.apache.hadoop.fs.FileEncryptionInfo; import org.apache.hadoop.fs.FileStatus; @@ -2306,6 +2307,70 @@ public class DistributedFileSystem extends FileSystem }.resolve(this, absF); } + /* HDFS only */ + public void provisionEZTrash(final Path path, + final FsPermission trashPermission) throws IOException { +Path absF = fixRelativePart(path); +new FileSystemLinkResolver() { + @Override + public Void doCall(Path p) throws IOException { +provisionEZTrash(getPathName(p), trashPermission); +return null; + } + + @Override + public Void next(FileSystem fs, Path p) throws IOException { +if (fs instanceof DistributedFileSystem) { + DistributedFileSystem myDfs = (DistributedFileSystem)fs; + myDfs.provisionEZTrash(p, trashPermission); + return null; +} +throw new UnsupportedOperationException("Cannot provisionEZTrash " + +"through a symlink to a non-DistributedFileSystem: " + fs + " -> " ++ p); + } +}.resolve(this, absF); + } + + private void provisionEZTrash(String path, FsPermission trashPermission) + throws IOException { +// make sure the path is an EZ +EncryptionZone ez = dfs.getEZForPath(path); +if (ez == null) { + throw new IllegalArgumentException(path + " is not an encryption zone."); +} + +String ezPath = ez.getPath(); +if (!path.toString().equals(ezPath)) { + throw new IllegalArgumentException(path + " is not the root of an " + + "encryption zone. Do you mean " + ez.getPath() + "?"); +} + +// check if the trash directory exists +Path trashPath = new Path(ez.getPath(), FileSystem.TRASH_PREFIX); +try { + FileStatus trashFileStatus = getFileStatus(trashPath); + String errMessage = "Will not provision new trash directory for " + + "encryption zone " + ez.getPath() + ". Path already exists."; + if (!trashFileStatus.isDirectory()) { +errMessage += "\r\n" + +"Warning: " + trashPath.toString() + " is not a directory"; + } + if (!trashFileStatus.getPermission().equals(trashPermission)) { +errMessage += "\r\n" + +"Warning: the permission of " + +trashPath.toString() + " is not " + trashPermission; + } + throw new FileAlreadyExistsException(errMessage); +} catch (FileNotFoundException ignored) { + // no trash path +} + +// Update the permission bits +mkdir(trashPath, trashPermission); +setPermission(trashPath, trashPermission); + } + @Override public void setXAttr(Path path, final String name, final byte[] value, final EnumSet flag) throws IOException { http://git-wip-us.apache.org/rep
hadoop git commit: HDFS-13109. Support fully qualified hdfs path in EZ commands. Contributed by Hanisha Koneru.
Repository: hadoop Updated Branches: refs/heads/branch-2.9 ef54f7853 -> 321766bcc HDFS-13109. Support fully qualified hdfs path in EZ commands. Contributed by Hanisha Koneru. (cherry picked from commit edf9445708ffb7a9e59cb933e049b540f99add1e) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/321766bc Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/321766bc Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/321766bc Branch: refs/heads/branch-2.9 Commit: 321766bcc8f8c7ac3d0091a065ccabf8a16c13c5 Parents: ef54f78 Author: Xiaoyu Yao Authored: Tue Mar 6 16:44:20 2018 -0800 Committer: Xiaoyu Yao Committed: Tue Mar 6 18:33:11 2018 -0800 -- .../hadoop/hdfs/DistributedFileSystem.java | 65 .../apache/hadoop/hdfs/client/HdfsAdmin.java| 46 +- .../apache/hadoop/hdfs/TestEncryptionZones.java | 44 + 3 files changed, 111 insertions(+), 44 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hadoop/blob/321766bc/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java -- diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java index 497f770..46df7d5 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java @@ -43,6 +43,7 @@ import org.apache.hadoop.fs.FSDataInputStream; import org.apache.hadoop.fs.FSDataOutputStream; import org.apache.hadoop.fs.FSDataOutputStreamBuilder; import org.apache.hadoop.fs.FSLinkResolver; +import org.apache.hadoop.fs.FileAlreadyExistsException; import org.apache.hadoop.fs.FileChecksum; import org.apache.hadoop.fs.FileEncryptionInfo; import org.apache.hadoop.fs.FileStatus; @@ -2395,6 +2396,70 @@ public class DistributedFileSystem extends FileSystem }.resolve(this, absF); } + /* HDFS only */ + public void provisionEZTrash(final Path path, + final FsPermission trashPermission) throws IOException { +Path absF = fixRelativePart(path); +new FileSystemLinkResolver() { + @Override + public Void doCall(Path p) throws IOException { +provisionEZTrash(getPathName(p), trashPermission); +return null; + } + + @Override + public Void next(FileSystem fs, Path p) throws IOException { +if (fs instanceof DistributedFileSystem) { + DistributedFileSystem myDfs = (DistributedFileSystem)fs; + myDfs.provisionEZTrash(p, trashPermission); + return null; +} +throw new UnsupportedOperationException("Cannot provisionEZTrash " + +"through a symlink to a non-DistributedFileSystem: " + fs + " -> " ++ p); + } +}.resolve(this, absF); + } + + private void provisionEZTrash(String path, FsPermission trashPermission) + throws IOException { +// make sure the path is an EZ +EncryptionZone ez = dfs.getEZForPath(path); +if (ez == null) { + throw new IllegalArgumentException(path + " is not an encryption zone."); +} + +String ezPath = ez.getPath(); +if (!path.toString().equals(ezPath)) { + throw new IllegalArgumentException(path + " is not the root of an " + + "encryption zone. Do you mean " + ez.getPath() + "?"); +} + +// check if the trash directory exists +Path trashPath = new Path(ez.getPath(), FileSystem.TRASH_PREFIX); +try { + FileStatus trashFileStatus = getFileStatus(trashPath); + String errMessage = "Will not provision new trash directory for " + + "encryption zone " + ez.getPath() + ". Path already exists."; + if (!trashFileStatus.isDirectory()) { +errMessage += "\r\n" + +"Warning: " + trashPath.toString() + " is not a directory"; + } + if (!trashFileStatus.getPermission().equals(trashPermission)) { +errMessage += "\r\n" + +"Warning: the permission of " + +trashPath.toString() + " is not " + trashPermission; + } + throw new FileAlreadyExistsException(errMessage); +} catch (FileNotFoundException ignored) { + // no trash path +} + +// Update the permission bits +mkdir(trashPath, trashPermission); +setPermission(trashPath, trashPermission); + } + @Override public void setXAttr(Path path, final String name, final byte[] value, final EnumSet flag) throws IOException { http://git-wip-us.apache.org/repos/asf/hadoop/blob/321766bc/hadoop-hdfs-project/hadoop
hadoop git commit: HDFS-13109. Support fully qualified hdfs path in EZ commands. Contributed by Hanisha Koneru.
Repository: hadoop Updated Branches: refs/heads/branch-3.0 5aaf88d40 -> b74df5523 HDFS-13109. Support fully qualified hdfs path in EZ commands. Contributed by Hanisha Koneru. (cherry picked from commit edf9445708ffb7a9e59cb933e049b540f99add1e) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/b74df552 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/b74df552 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/b74df552 Branch: refs/heads/branch-3.0 Commit: b74df5523c6b25f1f4e1d6fafb340d511adc6a7c Parents: 5aaf88d Author: Xiaoyu Yao Authored: Tue Mar 6 16:44:20 2018 -0800 Committer: Xiaoyu Yao Committed: Tue Mar 6 18:30:10 2018 -0800 -- .../hadoop/hdfs/DistributedFileSystem.java | 65 .../apache/hadoop/hdfs/client/HdfsAdmin.java| 46 +- .../apache/hadoop/hdfs/TestEncryptionZones.java | 44 + 3 files changed, 111 insertions(+), 44 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hadoop/blob/b74df552/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java -- diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java index 369a5bd..c2cd4d7 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java @@ -36,6 +36,7 @@ import org.apache.hadoop.fs.FSDataInputStream; import org.apache.hadoop.fs.FSDataOutputStream; import org.apache.hadoop.fs.FSDataOutputStreamBuilder; import org.apache.hadoop.fs.FSLinkResolver; +import org.apache.hadoop.fs.FileAlreadyExistsException; import org.apache.hadoop.fs.FileChecksum; import org.apache.hadoop.fs.FileEncryptionInfo; import org.apache.hadoop.fs.FileStatus; @@ -2393,6 +2394,70 @@ public class DistributedFileSystem extends FileSystem }.resolve(this, absF); } + /* HDFS only */ + public void provisionEZTrash(final Path path, + final FsPermission trashPermission) throws IOException { +Path absF = fixRelativePart(path); +new FileSystemLinkResolver() { + @Override + public Void doCall(Path p) throws IOException { +provisionEZTrash(getPathName(p), trashPermission); +return null; + } + + @Override + public Void next(FileSystem fs, Path p) throws IOException { +if (fs instanceof DistributedFileSystem) { + DistributedFileSystem myDfs = (DistributedFileSystem)fs; + myDfs.provisionEZTrash(p, trashPermission); + return null; +} +throw new UnsupportedOperationException("Cannot provisionEZTrash " + +"through a symlink to a non-DistributedFileSystem: " + fs + " -> " ++ p); + } +}.resolve(this, absF); + } + + private void provisionEZTrash(String path, FsPermission trashPermission) + throws IOException { +// make sure the path is an EZ +EncryptionZone ez = dfs.getEZForPath(path); +if (ez == null) { + throw new IllegalArgumentException(path + " is not an encryption zone."); +} + +String ezPath = ez.getPath(); +if (!path.toString().equals(ezPath)) { + throw new IllegalArgumentException(path + " is not the root of an " + + "encryption zone. Do you mean " + ez.getPath() + "?"); +} + +// check if the trash directory exists +Path trashPath = new Path(ez.getPath(), FileSystem.TRASH_PREFIX); +try { + FileStatus trashFileStatus = getFileStatus(trashPath); + String errMessage = "Will not provision new trash directory for " + + "encryption zone " + ez.getPath() + ". Path already exists."; + if (!trashFileStatus.isDirectory()) { +errMessage += "\r\n" + +"Warning: " + trashPath.toString() + " is not a directory"; + } + if (!trashFileStatus.getPermission().equals(trashPermission)) { +errMessage += "\r\n" + +"Warning: the permission of " + +trashPath.toString() + " is not " + trashPermission; + } + throw new FileAlreadyExistsException(errMessage); +} catch (FileNotFoundException ignored) { + // no trash path +} + +// Update the permission bits +mkdir(trashPath, trashPermission); +setPermission(trashPath, trashPermission); + } + @Override public void setXAttr(Path path, final String name, final byte[] value, final EnumSet flag) throws IOException { http://git-wip-us.apache.org/repos/asf/hadoop/blob/b74df552/hadoop-hdfs-project/hadoop
hadoop git commit: HDFS-13109. Support fully qualified hdfs path in EZ commands. Contributed by Hanisha Koneru.
Repository: hadoop Updated Branches: refs/heads/branch-3.1 1a8e6a52a -> 07a966ede HDFS-13109. Support fully qualified hdfs path in EZ commands. Contributed by Hanisha Koneru. (cherry picked from commit edf9445708ffb7a9e59cb933e049b540f99add1e) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/07a966ed Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/07a966ed Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/07a966ed Branch: refs/heads/branch-3.1 Commit: 07a966ede3bb76cec86fd8727ee825b309f964ef Parents: 1a8e6a5 Author: Xiaoyu Yao Authored: Tue Mar 6 16:44:20 2018 -0800 Committer: Xiaoyu Yao Committed: Tue Mar 6 18:29:42 2018 -0800 -- .../hadoop/hdfs/DistributedFileSystem.java | 65 .../apache/hadoop/hdfs/client/HdfsAdmin.java| 46 +- .../apache/hadoop/hdfs/TestEncryptionZones.java | 44 + 3 files changed, 111 insertions(+), 44 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hadoop/blob/07a966ed/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java -- diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java index fe2a565..03cb317 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java @@ -37,6 +37,7 @@ import org.apache.hadoop.fs.FSDataInputStream; import org.apache.hadoop.fs.FSDataOutputStream; import org.apache.hadoop.fs.FSDataOutputStreamBuilder; import org.apache.hadoop.fs.FSLinkResolver; +import org.apache.hadoop.fs.FileAlreadyExistsException; import org.apache.hadoop.fs.FileChecksum; import org.apache.hadoop.fs.FileEncryptionInfo; import org.apache.hadoop.fs.FileStatus; @@ -2600,6 +2601,70 @@ public class DistributedFileSystem extends FileSystem }.resolve(this, absF); } + /* HDFS only */ + public void provisionEZTrash(final Path path, + final FsPermission trashPermission) throws IOException { +Path absF = fixRelativePart(path); +new FileSystemLinkResolver() { + @Override + public Void doCall(Path p) throws IOException { +provisionEZTrash(getPathName(p), trashPermission); +return null; + } + + @Override + public Void next(FileSystem fs, Path p) throws IOException { +if (fs instanceof DistributedFileSystem) { + DistributedFileSystem myDfs = (DistributedFileSystem)fs; + myDfs.provisionEZTrash(p, trashPermission); + return null; +} +throw new UnsupportedOperationException("Cannot provisionEZTrash " + +"through a symlink to a non-DistributedFileSystem: " + fs + " -> " ++ p); + } +}.resolve(this, absF); + } + + private void provisionEZTrash(String path, FsPermission trashPermission) + throws IOException { +// make sure the path is an EZ +EncryptionZone ez = dfs.getEZForPath(path); +if (ez == null) { + throw new IllegalArgumentException(path + " is not an encryption zone."); +} + +String ezPath = ez.getPath(); +if (!path.toString().equals(ezPath)) { + throw new IllegalArgumentException(path + " is not the root of an " + + "encryption zone. Do you mean " + ez.getPath() + "?"); +} + +// check if the trash directory exists +Path trashPath = new Path(ez.getPath(), FileSystem.TRASH_PREFIX); +try { + FileStatus trashFileStatus = getFileStatus(trashPath); + String errMessage = "Will not provision new trash directory for " + + "encryption zone " + ez.getPath() + ". Path already exists."; + if (!trashFileStatus.isDirectory()) { +errMessage += "\r\n" + +"Warning: " + trashPath.toString() + " is not a directory"; + } + if (!trashFileStatus.getPermission().equals(trashPermission)) { +errMessage += "\r\n" + +"Warning: the permission of " + +trashPath.toString() + " is not " + trashPermission; + } + throw new FileAlreadyExistsException(errMessage); +} catch (FileNotFoundException ignored) { + // no trash path +} + +// Update the permission bits +mkdir(trashPath, trashPermission); +setPermission(trashPath, trashPermission); + } + @Override public void setXAttr(Path path, final String name, final byte[] value, final EnumSet flag) throws IOException { http://git-wip-us.apache.org/repos/asf/hadoop/blob/07a966ed/hadoop-hdfs-project/hadoop
hadoop git commit: HDFS-13109. Support fully qualified hdfs path in EZ commands. Contributed by Hanisha Koneru.
Repository: hadoop Updated Branches: refs/heads/trunk 346caa209 -> edf944570 HDFS-13109. Support fully qualified hdfs path in EZ commands. Contributed by Hanisha Koneru. Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/edf94457 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/edf94457 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/edf94457 Branch: refs/heads/trunk Commit: edf9445708ffb7a9e59cb933e049b540f99add1e Parents: 346caa2 Author: Xiaoyu Yao Authored: Tue Mar 6 16:44:20 2018 -0800 Committer: Xiaoyu Yao Committed: Tue Mar 6 16:44:20 2018 -0800 -- .../hadoop/hdfs/DistributedFileSystem.java | 65 .../apache/hadoop/hdfs/client/HdfsAdmin.java| 46 +- .../apache/hadoop/hdfs/TestEncryptionZones.java | 44 + 3 files changed, 111 insertions(+), 44 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hadoop/blob/edf94457/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java -- diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java index fe2a565..03cb317 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DistributedFileSystem.java @@ -37,6 +37,7 @@ import org.apache.hadoop.fs.FSDataInputStream; import org.apache.hadoop.fs.FSDataOutputStream; import org.apache.hadoop.fs.FSDataOutputStreamBuilder; import org.apache.hadoop.fs.FSLinkResolver; +import org.apache.hadoop.fs.FileAlreadyExistsException; import org.apache.hadoop.fs.FileChecksum; import org.apache.hadoop.fs.FileEncryptionInfo; import org.apache.hadoop.fs.FileStatus; @@ -2600,6 +2601,70 @@ public class DistributedFileSystem extends FileSystem }.resolve(this, absF); } + /* HDFS only */ + public void provisionEZTrash(final Path path, + final FsPermission trashPermission) throws IOException { +Path absF = fixRelativePart(path); +new FileSystemLinkResolver() { + @Override + public Void doCall(Path p) throws IOException { +provisionEZTrash(getPathName(p), trashPermission); +return null; + } + + @Override + public Void next(FileSystem fs, Path p) throws IOException { +if (fs instanceof DistributedFileSystem) { + DistributedFileSystem myDfs = (DistributedFileSystem)fs; + myDfs.provisionEZTrash(p, trashPermission); + return null; +} +throw new UnsupportedOperationException("Cannot provisionEZTrash " + +"through a symlink to a non-DistributedFileSystem: " + fs + " -> " ++ p); + } +}.resolve(this, absF); + } + + private void provisionEZTrash(String path, FsPermission trashPermission) + throws IOException { +// make sure the path is an EZ +EncryptionZone ez = dfs.getEZForPath(path); +if (ez == null) { + throw new IllegalArgumentException(path + " is not an encryption zone."); +} + +String ezPath = ez.getPath(); +if (!path.toString().equals(ezPath)) { + throw new IllegalArgumentException(path + " is not the root of an " + + "encryption zone. Do you mean " + ez.getPath() + "?"); +} + +// check if the trash directory exists +Path trashPath = new Path(ez.getPath(), FileSystem.TRASH_PREFIX); +try { + FileStatus trashFileStatus = getFileStatus(trashPath); + String errMessage = "Will not provision new trash directory for " + + "encryption zone " + ez.getPath() + ". Path already exists."; + if (!trashFileStatus.isDirectory()) { +errMessage += "\r\n" + +"Warning: " + trashPath.toString() + " is not a directory"; + } + if (!trashFileStatus.getPermission().equals(trashPermission)) { +errMessage += "\r\n" + +"Warning: the permission of " + +trashPath.toString() + " is not " + trashPermission; + } + throw new FileAlreadyExistsException(errMessage); +} catch (FileNotFoundException ignored) { + // no trash path +} + +// Update the permission bits +mkdir(trashPath, trashPermission); +setPermission(trashPath, trashPermission); + } + @Override public void setXAttr(Path path, final String name, final byte[] value, final EnumSet flag) throws IOException { http://git-wip-us.apache.org/repos/asf/hadoop/blob/edf94457/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/client/HdfsAdmin.java