[3/8] hadoop git commit: Revert "Revert "HDFS-10346. Implement asynchronous setPermission/setOwner for DistributedFileSystem. Contributed by Xiaobing Zhou""
Revert "Revert "HDFS-10346. Implement asynchronous setPermission/setOwner for DistributedFileSystem. Contributed by Xiaobing Zhou"" This reverts commit ffa85f28a2ec612a3d63c890806a17cfd3a2e7e2. Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/5b054b1b Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/5b054b1b Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/5b054b1b Branch: refs/heads/branch-2.8 Commit: 5b054b1bfcf22a219d91781e2515acdf8a68a6d7 Parents: 8ccc8ae Author: Tsz-Wo Nicholas SzeAuthored: Mon Jun 6 16:53:36 2016 +0800 Committer: Tsz-Wo Nicholas Sze Committed: Mon Jun 6 16:53:36 2016 +0800 -- .../hadoop/hdfs/AsyncDistributedFileSystem.java | 59 .../ClientNamenodeProtocolTranslatorPB.java | 39 ++- .../apache/hadoop/hdfs/TestAsyncDFSRename.java | 267 +-- .../apache/hadoop/hdfs/TestDFSPermission.java | 29 +- 4 files changed, 351 insertions(+), 43 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hadoop/blob/5b054b1b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/AsyncDistributedFileSystem.java -- diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/AsyncDistributedFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/AsyncDistributedFileSystem.java index 356ae3f..4fe0861 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/AsyncDistributedFileSystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/AsyncDistributedFileSystem.java @@ -27,6 +27,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import org.apache.hadoop.classification.InterfaceStability.Unstable; import org.apache.hadoop.fs.Options; import org.apache.hadoop.fs.Path; +import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolTranslatorPB; import org.apache.hadoop.ipc.Client; @@ -37,6 +38,9 @@ import com.google.common.util.concurrent.AbstractFuture; * This instance of this class is the way end-user code interacts * with a Hadoop DistributedFileSystem in an asynchronous manner. * + * This class is unstable, so no guarantee is provided as to reliability, + * stability or compatibility across any level of release granularity. + * */ @Unstable public class AsyncDistributedFileSystem { @@ -111,4 +115,59 @@ public class AsyncDistributedFileSystem { Client.setAsynchronousMode(isAsync); } } + + /** + * Set permission of a path. + * + * @param p + * the path the permission is set to + * @param permission + * the permission that is set to a path. + * @return an instance of Future, #get of which is invoked to wait for + * asynchronous call being finished. + */ + public Future setPermission(Path p, final FsPermission permission) + throws IOException { +dfs.getFsStatistics().incrementWriteOps(1); +final Path absPath = dfs.fixRelativePart(p); +final boolean isAsync = Client.isAsynchronousMode(); +Client.setAsynchronousMode(true); +try { + dfs.getClient().setPermission(dfs.getPathName(absPath), permission); + return getReturnValue(); +} finally { + Client.setAsynchronousMode(isAsync); +} + } + + /** + * Set owner of a path (i.e. a file or a directory). The parameters username + * and groupname cannot both be null. + * + * @param p + * The path + * @param username + * If it is null, the original username remains unchanged. + * @param groupname + * If it is null, the original groupname remains unchanged. + * @return an instance of Future, #get of which is invoked to wait for + * asynchronous call being finished. + */ + public Future setOwner(Path p, String username, String groupname) + throws IOException { +if (username == null && groupname == null) { + throw new IOException("username == null && groupname == null"); +} + +dfs.getFsStatistics().incrementWriteOps(1); +final Path absPath = dfs.fixRelativePart(p); +final boolean isAsync = Client.isAsynchronousMode(); +Client.setAsynchronousMode(true); +try { + dfs.getClient().setOwner(dfs.getPathName(absPath), username, groupname); + return getReturnValue(); +} finally { + Client.setAsynchronousMode(isAsync); +} + } }
[3/8] hadoop git commit: Revert "Revert "HDFS-10346. Implement asynchronous setPermission/setOwner for DistributedFileSystem. Contributed by Xiaobing Zhou""
Revert "Revert "HDFS-10346. Implement asynchronous setPermission/setOwner for DistributedFileSystem. Contributed by Xiaobing Zhou"" This reverts commit 2529cabf12e2c37740723fe7f52cc7bd94d92f0d. Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/428dc52e Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/428dc52e Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/428dc52e Branch: refs/heads/branch-2 Commit: 428dc52e56f6eee83ca7fbbbe3d99fdd69df361c Parents: 7b9062f Author: Tsz-Wo Nicholas SzeAuthored: Mon Jun 6 16:51:54 2016 +0800 Committer: Tsz-Wo Nicholas Sze Committed: Mon Jun 6 16:51:54 2016 +0800 -- .../hadoop/hdfs/AsyncDistributedFileSystem.java | 59 .../ClientNamenodeProtocolTranslatorPB.java | 39 ++- .../apache/hadoop/hdfs/TestAsyncDFSRename.java | 267 +-- .../apache/hadoop/hdfs/TestDFSPermission.java | 29 +- 4 files changed, 351 insertions(+), 43 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hadoop/blob/428dc52e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/AsyncDistributedFileSystem.java -- diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/AsyncDistributedFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/AsyncDistributedFileSystem.java index 356ae3f..4fe0861 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/AsyncDistributedFileSystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/AsyncDistributedFileSystem.java @@ -27,6 +27,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import org.apache.hadoop.classification.InterfaceStability.Unstable; import org.apache.hadoop.fs.Options; import org.apache.hadoop.fs.Path; +import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolTranslatorPB; import org.apache.hadoop.ipc.Client; @@ -37,6 +38,9 @@ import com.google.common.util.concurrent.AbstractFuture; * This instance of this class is the way end-user code interacts * with a Hadoop DistributedFileSystem in an asynchronous manner. * + * This class is unstable, so no guarantee is provided as to reliability, + * stability or compatibility across any level of release granularity. + * */ @Unstable public class AsyncDistributedFileSystem { @@ -111,4 +115,59 @@ public class AsyncDistributedFileSystem { Client.setAsynchronousMode(isAsync); } } + + /** + * Set permission of a path. + * + * @param p + * the path the permission is set to + * @param permission + * the permission that is set to a path. + * @return an instance of Future, #get of which is invoked to wait for + * asynchronous call being finished. + */ + public Future setPermission(Path p, final FsPermission permission) + throws IOException { +dfs.getFsStatistics().incrementWriteOps(1); +final Path absPath = dfs.fixRelativePart(p); +final boolean isAsync = Client.isAsynchronousMode(); +Client.setAsynchronousMode(true); +try { + dfs.getClient().setPermission(dfs.getPathName(absPath), permission); + return getReturnValue(); +} finally { + Client.setAsynchronousMode(isAsync); +} + } + + /** + * Set owner of a path (i.e. a file or a directory). The parameters username + * and groupname cannot both be null. + * + * @param p + * The path + * @param username + * If it is null, the original username remains unchanged. + * @param groupname + * If it is null, the original groupname remains unchanged. + * @return an instance of Future, #get of which is invoked to wait for + * asynchronous call being finished. + */ + public Future setOwner(Path p, String username, String groupname) + throws IOException { +if (username == null && groupname == null) { + throw new IOException("username == null && groupname == null"); +} + +dfs.getFsStatistics().incrementWriteOps(1); +final Path absPath = dfs.fixRelativePart(p); +final boolean isAsync = Client.isAsynchronousMode(); +Client.setAsynchronousMode(true); +try { + dfs.getClient().setOwner(dfs.getPathName(absPath), username, groupname); + return getReturnValue(); +} finally { + Client.setAsynchronousMode(isAsync); +} + } }
[3/8] hadoop git commit: Revert "Revert "HDFS-10346. Implement asynchronous setPermission/setOwner for DistributedFileSystem. Contributed by Xiaobing Zhou""
Revert "Revert "HDFS-10346. Implement asynchronous setPermission/setOwner for DistributedFileSystem. Contributed by Xiaobing Zhou"" This reverts commit f23d5dfc60a017187ae57f3667ac0e688877c2dd. Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/cba9a018 Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/cba9a018 Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/cba9a018 Branch: refs/heads/trunk Commit: cba9a0188970cb33dcb95e9c49168ac4a83446d9 Parents: aa20fa1 Author: Tsz-Wo Nicholas SzeAuthored: Mon Jun 6 16:29:38 2016 +0800 Committer: Tsz-Wo Nicholas Sze Committed: Mon Jun 6 16:29:38 2016 +0800 -- .../hadoop/hdfs/AsyncDistributedFileSystem.java | 59 .../ClientNamenodeProtocolTranslatorPB.java | 39 ++- .../apache/hadoop/hdfs/TestAsyncDFSRename.java | 267 +-- .../apache/hadoop/hdfs/TestDFSPermission.java | 29 +- 4 files changed, 351 insertions(+), 43 deletions(-) -- http://git-wip-us.apache.org/repos/asf/hadoop/blob/cba9a018/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/AsyncDistributedFileSystem.java -- diff --git a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/AsyncDistributedFileSystem.java b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/AsyncDistributedFileSystem.java index 356ae3f..4fe0861 100644 --- a/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/AsyncDistributedFileSystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/AsyncDistributedFileSystem.java @@ -27,6 +27,7 @@ import java.util.concurrent.atomic.AtomicBoolean; import org.apache.hadoop.classification.InterfaceStability.Unstable; import org.apache.hadoop.fs.Options; import org.apache.hadoop.fs.Path; +import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolTranslatorPB; import org.apache.hadoop.ipc.Client; @@ -37,6 +38,9 @@ import com.google.common.util.concurrent.AbstractFuture; * This instance of this class is the way end-user code interacts * with a Hadoop DistributedFileSystem in an asynchronous manner. * + * This class is unstable, so no guarantee is provided as to reliability, + * stability or compatibility across any level of release granularity. + * */ @Unstable public class AsyncDistributedFileSystem { @@ -111,4 +115,59 @@ public class AsyncDistributedFileSystem { Client.setAsynchronousMode(isAsync); } } + + /** + * Set permission of a path. + * + * @param p + * the path the permission is set to + * @param permission + * the permission that is set to a path. + * @return an instance of Future, #get of which is invoked to wait for + * asynchronous call being finished. + */ + public Future setPermission(Path p, final FsPermission permission) + throws IOException { +dfs.getFsStatistics().incrementWriteOps(1); +final Path absPath = dfs.fixRelativePart(p); +final boolean isAsync = Client.isAsynchronousMode(); +Client.setAsynchronousMode(true); +try { + dfs.getClient().setPermission(dfs.getPathName(absPath), permission); + return getReturnValue(); +} finally { + Client.setAsynchronousMode(isAsync); +} + } + + /** + * Set owner of a path (i.e. a file or a directory). The parameters username + * and groupname cannot both be null. + * + * @param p + * The path + * @param username + * If it is null, the original username remains unchanged. + * @param groupname + * If it is null, the original groupname remains unchanged. + * @return an instance of Future, #get of which is invoked to wait for + * asynchronous call being finished. + */ + public Future setOwner(Path p, String username, String groupname) + throws IOException { +if (username == null && groupname == null) { + throw new IOException("username == null && groupname == null"); +} + +dfs.getFsStatistics().incrementWriteOps(1); +final Path absPath = dfs.fixRelativePart(p); +final boolean isAsync = Client.isAsynchronousMode(); +Client.setAsynchronousMode(true); +try { + dfs.getClient().setOwner(dfs.getPathName(absPath), username, groupname); + return getReturnValue(); +} finally { + Client.setAsynchronousMode(isAsync); +} + } }