You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by br...@apache.org on 2016/11/25 15:01:59 UTC
[1/3] hadoop git commit: HADOOP-13820. Replace ugi.getUsername() with
ugi.getShortUserName() in viewFS. Contributed By Brahma Reddy Battula.
Repository: hadoop
Updated Branches:
refs/heads/branch-2 9701ab48e -> 1c0fa25dc
refs/heads/branch-2.8 db37ad0eb -> 713d800e7
refs/heads/trunk bb1b5e083 -> ee3d437a3
HADOOP-13820. Replace ugi.getUsername() with ugi.getShortUserName() in viewFS. Contributed By Brahma Reddy Battula.
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/ee3d437a
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/ee3d437a
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/ee3d437a
Branch: refs/heads/trunk
Commit: ee3d437a33c2106ea416078e722ff6184106a0bc
Parents: bb1b5e0
Author: Brahma Reddy Battula <br...@apache.org>
Authored: Fri Nov 25 19:54:50 2016 +0530
Committer: Brahma Reddy Battula <br...@apache.org>
Committed: Fri Nov 25 19:54:50 2016 +0530
----------------------------------------------------------------------
.../apache/hadoop/fs/viewfs/ViewFileSystem.java | 8 +++----
.../org/apache/hadoop/fs/viewfs/ViewFs.java | 12 +++++------
.../fs/viewfs/ViewFileSystemBaseTest.java | 20 ++++++++++++++++++
.../apache/hadoop/fs/viewfs/ViewFsBaseTest.java | 22 ++++++++++++++++++++
4 files changed, 52 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ee3d437a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
----------------------------------------------------------------------
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 fa9f712..9061b2a 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
@@ -951,7 +951,7 @@ public class ViewFileSystem extends FileSystem {
public FileStatus getFileStatus(Path f) throws IOException {
checkPathIsSlash(f);
return new FileStatus(0, true, 0, 0, creationTime, creationTime,
- PERMISSION_555, ugi.getUserName(), ugi.getPrimaryGroupName(),
+ PERMISSION_555, ugi.getShortUserName(), ugi.getPrimaryGroupName(),
new Path(theInternalDir.fullPath).makeQualified(
myUri, ROOT_PATH));
@@ -972,14 +972,14 @@ public class ViewFileSystem extends FileSystem {
result[i++] = new FileStatus(0, false, 0, 0,
creationTime, creationTime, PERMISSION_555,
- ugi.getUserName(), ugi.getPrimaryGroupName(),
+ ugi.getShortUserName(), ugi.getPrimaryGroupName(),
link.getTargetLink(),
new Path(inode.fullPath).makeQualified(
myUri, null));
} else {
result[i++] = new FileStatus(0, true, 0, 0,
creationTime, creationTime, PERMISSION_555,
- ugi.getUserName(), ugi.getGroupNames()[0],
+ ugi.getShortUserName(), ugi.getGroupNames()[0],
new Path(inode.fullPath).makeQualified(
myUri, null));
}
@@ -1103,7 +1103,7 @@ public class ViewFileSystem extends FileSystem {
@Override
public AclStatus getAclStatus(Path path) throws IOException {
checkPathIsSlash(path);
- return new AclStatus.Builder().owner(ugi.getUserName())
+ return new AclStatus.Builder().owner(ugi.getShortUserName())
.group(ugi.getPrimaryGroupName())
.addEntries(AclUtil.getMinimalAcl(PERMISSION_555))
.stickyBit(false).build();
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ee3d437a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java
----------------------------------------------------------------------
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 6195540..d5f8e81 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
@@ -845,7 +845,7 @@ public class ViewFs extends AbstractFileSystem {
public FileStatus getFileStatus(final Path f) throws IOException {
checkPathIsSlash(f);
return new FileStatus(0, true, 0, 0, creationTime, creationTime,
- PERMISSION_555, ugi.getUserName(), ugi.getPrimaryGroupName(),
+ PERMISSION_555, ugi.getShortUserName(), ugi.getPrimaryGroupName(),
new Path(theInternalDir.fullPath).makeQualified(
myUri, null));
}
@@ -865,13 +865,13 @@ public class ViewFs extends AbstractFileSystem {
INodeLink<AbstractFileSystem> inodelink =
(INodeLink<AbstractFileSystem>) inode;
result = new FileStatus(0, false, 0, 0, creationTime, creationTime,
- PERMISSION_555, ugi.getUserName(), ugi.getPrimaryGroupName(),
+ PERMISSION_555, ugi.getShortUserName(), ugi.getPrimaryGroupName(),
inodelink.getTargetLink(),
new Path(inode.fullPath).makeQualified(
myUri, null));
} else {
result = new FileStatus(0, true, 0, 0, creationTime, creationTime,
- PERMISSION_555, ugi.getUserName(), ugi.getPrimaryGroupName(),
+ PERMISSION_555, ugi.getShortUserName(), ugi.getPrimaryGroupName(),
new Path(inode.fullPath).makeQualified(
myUri, null));
}
@@ -910,14 +910,14 @@ public class ViewFs extends AbstractFileSystem {
result[i++] = new FileStatus(0, false, 0, 0,
creationTime, creationTime,
- PERMISSION_555, ugi.getUserName(), ugi.getPrimaryGroupName(),
+ PERMISSION_555, ugi.getShortUserName(), ugi.getPrimaryGroupName(),
link.getTargetLink(),
new Path(inode.fullPath).makeQualified(
myUri, null));
} else {
result[i++] = new FileStatus(0, true, 0, 0,
creationTime, creationTime,
- PERMISSION_555, ugi.getUserName(), ugi.getGroupNames()[0],
+ PERMISSION_555, ugi.getShortUserName(), ugi.getGroupNames()[0],
new Path(inode.fullPath).makeQualified(
myUri, null));
}
@@ -1043,7 +1043,7 @@ public class ViewFs extends AbstractFileSystem {
@Override
public AclStatus getAclStatus(Path path) throws IOException {
checkPathIsSlash(path);
- return new AclStatus.Builder().owner(ugi.getUserName())
+ return new AclStatus.Builder().owner(ugi.getShortUserName())
.group(ugi.getPrimaryGroupName())
.addEntries(AclUtil.getMinimalAcl(PERMISSION_555))
.stickyBit(false).build();
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ee3d437a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java
index 407b885..06f9868 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java
@@ -20,6 +20,7 @@ package org.apache.hadoop.fs.viewfs;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
+import java.security.PrivilegedExceptionAction;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
@@ -1088,4 +1089,23 @@ abstract public class ViewFileSystemBaseTest {
// Case 7: Verify FsStatus of a non MountPoint path throws exception
ViewFileSystemUtil.getStatus(fileSystem, new Path("/non-existing"));
}
+
+ @Test
+ public void testCheckOwnerWithFileStatus()
+ throws IOException, InterruptedException {
+ final UserGroupInformation userUgi = UserGroupInformation
+ .createUserForTesting("user@HADOOP.COM", new String[]{"hadoop"});
+ userUgi.doAs(new PrivilegedExceptionAction<Object>() {
+ @Override
+ public Object run() throws IOException {
+ UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
+ String doAsUserName = ugi.getUserName();
+ assertEquals(doAsUserName, "user@HADOOP.COM");
+ FileSystem vfs = FileSystem.get(FsConstants.VIEWFS_URI, conf);
+ FileStatus stat = vfs.getFileStatus(new Path("/internalDir"));
+ assertEquals(userUgi.getShortUserName(), stat.getOwner());
+ return null;
+ }
+ });
+ }
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/ee3d437a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java
index ceebb26..16d2644 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java
@@ -29,6 +29,8 @@ import static org.junit.Assert.assertFalse;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
+import java.net.URISyntaxException;
+import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.List;
@@ -798,4 +800,24 @@ abstract public class ViewFsBaseTest {
public void testInternalDeleteSnapshot() throws IOException {
fcView.deleteSnapshot(new Path("/internalDir"), "snap1");
}
+
+ @Test
+ public void testOwnerForInternalDir()
+ throws IOException, InterruptedException, URISyntaxException {
+ final UserGroupInformation userUgi = UserGroupInformation
+ .createUserForTesting("user@HADOOP.COM", new String[]{"hadoop"});
+ userUgi.doAs(new PrivilegedExceptionAction<Object>() {
+ @Override
+ public Object run() throws IOException, URISyntaxException {
+ UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
+ String doAsUserName = ugi.getUserName();
+ assertEquals(doAsUserName, "user@HADOOP.COM");
+ FileContext
+ viewFS = FileContext.getFileContext(FsConstants.VIEWFS_URI, conf);
+ FileStatus stat = viewFS.getFileStatus(new Path("/internalDir"));
+ assertEquals(userUgi.getShortUserName(), stat.getOwner());
+ return null;
+ }
+ });
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[2/3] hadoop git commit: HADOOP-13820. Replace ugi.getUsername() with
ugi.getShortUserName() in viewFS. Contributed By Brahma Reddy Battula.
Posted by br...@apache.org.
HADOOP-13820. Replace ugi.getUsername() with ugi.getShortUserName() in viewFS. Contributed By Brahma Reddy Battula.
(cherry picked from commit ee3d437a33c2106ea416078e722ff6184106a0bc)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/1c0fa25d
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/1c0fa25d
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/1c0fa25d
Branch: refs/heads/branch-2
Commit: 1c0fa25dc1c4bc787fe4d2809f162bea475a8b76
Parents: 9701ab4
Author: Brahma Reddy Battula <br...@apache.org>
Authored: Fri Nov 25 19:54:50 2016 +0530
Committer: Brahma Reddy Battula <br...@apache.org>
Committed: Fri Nov 25 20:00:46 2016 +0530
----------------------------------------------------------------------
.../apache/hadoop/fs/viewfs/ViewFileSystem.java | 8 +++----
.../org/apache/hadoop/fs/viewfs/ViewFs.java | 12 +++++------
.../fs/viewfs/ViewFileSystemBaseTest.java | 22 +++++++++++++++++++-
.../apache/hadoop/fs/viewfs/ViewFsBaseTest.java | 22 ++++++++++++++++++++
4 files changed, 53 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/1c0fa25d/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
----------------------------------------------------------------------
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 0f090a5..c315dc5 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
@@ -862,7 +862,7 @@ public class ViewFileSystem extends FileSystem {
public FileStatus getFileStatus(Path f) throws IOException {
checkPathIsSlash(f);
return new FileStatus(0, true, 0, 0, creationTime, creationTime,
- PERMISSION_555, ugi.getUserName(), ugi.getPrimaryGroupName(),
+ PERMISSION_555, ugi.getShortUserName(), ugi.getPrimaryGroupName(),
new Path(theInternalDir.fullPath).makeQualified(
myUri, ROOT_PATH));
@@ -883,14 +883,14 @@ public class ViewFileSystem extends FileSystem {
result[i++] = new FileStatus(0, false, 0, 0,
creationTime, creationTime, PERMISSION_555,
- ugi.getUserName(), ugi.getPrimaryGroupName(),
+ ugi.getShortUserName(), ugi.getPrimaryGroupName(),
link.getTargetLink(),
new Path(inode.fullPath).makeQualified(
myUri, null));
} else {
result[i++] = new FileStatus(0, true, 0, 0,
creationTime, creationTime, PERMISSION_555,
- ugi.getUserName(), ugi.getGroupNames()[0],
+ ugi.getShortUserName(), ugi.getGroupNames()[0],
new Path(inode.fullPath).makeQualified(
myUri, null));
}
@@ -1014,7 +1014,7 @@ public class ViewFileSystem extends FileSystem {
@Override
public AclStatus getAclStatus(Path path) throws IOException {
checkPathIsSlash(path);
- return new AclStatus.Builder().owner(ugi.getUserName())
+ return new AclStatus.Builder().owner(ugi.getShortUserName())
.group(ugi.getPrimaryGroupName())
.addEntries(AclUtil.getMinimalAcl(PERMISSION_555))
.stickyBit(false).build();
http://git-wip-us.apache.org/repos/asf/hadoop/blob/1c0fa25d/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java
----------------------------------------------------------------------
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 6195540..d5f8e81 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
@@ -845,7 +845,7 @@ public class ViewFs extends AbstractFileSystem {
public FileStatus getFileStatus(final Path f) throws IOException {
checkPathIsSlash(f);
return new FileStatus(0, true, 0, 0, creationTime, creationTime,
- PERMISSION_555, ugi.getUserName(), ugi.getPrimaryGroupName(),
+ PERMISSION_555, ugi.getShortUserName(), ugi.getPrimaryGroupName(),
new Path(theInternalDir.fullPath).makeQualified(
myUri, null));
}
@@ -865,13 +865,13 @@ public class ViewFs extends AbstractFileSystem {
INodeLink<AbstractFileSystem> inodelink =
(INodeLink<AbstractFileSystem>) inode;
result = new FileStatus(0, false, 0, 0, creationTime, creationTime,
- PERMISSION_555, ugi.getUserName(), ugi.getPrimaryGroupName(),
+ PERMISSION_555, ugi.getShortUserName(), ugi.getPrimaryGroupName(),
inodelink.getTargetLink(),
new Path(inode.fullPath).makeQualified(
myUri, null));
} else {
result = new FileStatus(0, true, 0, 0, creationTime, creationTime,
- PERMISSION_555, ugi.getUserName(), ugi.getPrimaryGroupName(),
+ PERMISSION_555, ugi.getShortUserName(), ugi.getPrimaryGroupName(),
new Path(inode.fullPath).makeQualified(
myUri, null));
}
@@ -910,14 +910,14 @@ public class ViewFs extends AbstractFileSystem {
result[i++] = new FileStatus(0, false, 0, 0,
creationTime, creationTime,
- PERMISSION_555, ugi.getUserName(), ugi.getPrimaryGroupName(),
+ PERMISSION_555, ugi.getShortUserName(), ugi.getPrimaryGroupName(),
link.getTargetLink(),
new Path(inode.fullPath).makeQualified(
myUri, null));
} else {
result[i++] = new FileStatus(0, true, 0, 0,
creationTime, creationTime,
- PERMISSION_555, ugi.getUserName(), ugi.getGroupNames()[0],
+ PERMISSION_555, ugi.getShortUserName(), ugi.getGroupNames()[0],
new Path(inode.fullPath).makeQualified(
myUri, null));
}
@@ -1043,7 +1043,7 @@ public class ViewFs extends AbstractFileSystem {
@Override
public AclStatus getAclStatus(Path path) throws IOException {
checkPathIsSlash(path);
- return new AclStatus.Builder().owner(ugi.getUserName())
+ return new AclStatus.Builder().owner(ugi.getShortUserName())
.group(ugi.getPrimaryGroupName())
.addEntries(AclUtil.getMinimalAcl(PERMISSION_555))
.stickyBit(false).build();
http://git-wip-us.apache.org/repos/asf/hadoop/blob/1c0fa25d/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java
index ea4d9b1..8c4ddc3 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java
@@ -20,8 +20,8 @@ package org.apache.hadoop.fs.viewfs;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
+import java.security.PrivilegedExceptionAction;
import java.util.Arrays;
-import java.util.ArrayList;
import java.util.List;
@@ -885,4 +885,24 @@ abstract public class ViewFileSystemBaseTest {
public void testInternalDeleteSnapshot() throws IOException {
fsView.deleteSnapshot(new Path("/internalDir"), "snap1");
}
+
+ @Test
+ public void testCheckOwnerWithFileStatus()
+ throws IOException, InterruptedException {
+ final UserGroupInformation userUgi = UserGroupInformation
+ .createUserForTesting("user@HADOOP.COM", new String[]{"hadoop"});
+ userUgi.doAs(new PrivilegedExceptionAction<Object>() {
+ @Override
+ public Object run() throws IOException {
+ UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
+ String doAsUserName = ugi.getUserName();
+ assertEquals(doAsUserName, "user@HADOOP.COM");
+ FileSystem vfs = FileSystem.get(FsConstants.VIEWFS_URI, conf);
+ FileStatus stat = vfs.getFileStatus(new Path("/internalDir"));
+ assertEquals(userUgi.getShortUserName(), stat.getOwner());
+ return null;
+ }
+ });
+ }
+
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/1c0fa25d/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java
index ceebb26..16d2644 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java
@@ -29,6 +29,8 @@ import static org.junit.Assert.assertFalse;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
+import java.net.URISyntaxException;
+import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.List;
@@ -798,4 +800,24 @@ abstract public class ViewFsBaseTest {
public void testInternalDeleteSnapshot() throws IOException {
fcView.deleteSnapshot(new Path("/internalDir"), "snap1");
}
+
+ @Test
+ public void testOwnerForInternalDir()
+ throws IOException, InterruptedException, URISyntaxException {
+ final UserGroupInformation userUgi = UserGroupInformation
+ .createUserForTesting("user@HADOOP.COM", new String[]{"hadoop"});
+ userUgi.doAs(new PrivilegedExceptionAction<Object>() {
+ @Override
+ public Object run() throws IOException, URISyntaxException {
+ UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
+ String doAsUserName = ugi.getUserName();
+ assertEquals(doAsUserName, "user@HADOOP.COM");
+ FileContext
+ viewFS = FileContext.getFileContext(FsConstants.VIEWFS_URI, conf);
+ FileStatus stat = viewFS.getFileStatus(new Path("/internalDir"));
+ assertEquals(userUgi.getShortUserName(), stat.getOwner());
+ return null;
+ }
+ });
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org
[3/3] hadoop git commit: HADOOP-13820. Replace ugi.getUsername() with
ugi.getShortUserName() in viewFS. Contributed By Brahma Reddy Battula.
Posted by br...@apache.org.
HADOOP-13820. Replace ugi.getUsername() with ugi.getShortUserName() in viewFS. Contributed By Brahma Reddy Battula.
(cherry picked from commit ee3d437a33c2106ea416078e722ff6184106a0bc)
(cherry picked from commit 1c0fa25dc1c4bc787fe4d2809f162bea475a8b76)
Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/713d800e
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/713d800e
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/713d800e
Branch: refs/heads/branch-2.8
Commit: 713d800e7b02a2233f3f1766460a838b410c4b29
Parents: db37ad0
Author: Brahma Reddy Battula <br...@apache.org>
Authored: Fri Nov 25 19:54:50 2016 +0530
Committer: Brahma Reddy Battula <br...@apache.org>
Committed: Fri Nov 25 20:20:37 2016 +0530
----------------------------------------------------------------------
.../apache/hadoop/fs/viewfs/ViewFileSystem.java | 8 +++----
.../org/apache/hadoop/fs/viewfs/ViewFs.java | 12 +++++------
.../fs/viewfs/ViewFileSystemBaseTest.java | 22 +++++++++++++++++++-
.../apache/hadoop/fs/viewfs/ViewFsBaseTest.java | 22 ++++++++++++++++++++
4 files changed, 53 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hadoop/blob/713d800e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFileSystem.java
----------------------------------------------------------------------
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 0f090a5..c315dc5 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
@@ -862,7 +862,7 @@ public class ViewFileSystem extends FileSystem {
public FileStatus getFileStatus(Path f) throws IOException {
checkPathIsSlash(f);
return new FileStatus(0, true, 0, 0, creationTime, creationTime,
- PERMISSION_555, ugi.getUserName(), ugi.getPrimaryGroupName(),
+ PERMISSION_555, ugi.getShortUserName(), ugi.getPrimaryGroupName(),
new Path(theInternalDir.fullPath).makeQualified(
myUri, ROOT_PATH));
@@ -883,14 +883,14 @@ public class ViewFileSystem extends FileSystem {
result[i++] = new FileStatus(0, false, 0, 0,
creationTime, creationTime, PERMISSION_555,
- ugi.getUserName(), ugi.getPrimaryGroupName(),
+ ugi.getShortUserName(), ugi.getPrimaryGroupName(),
link.getTargetLink(),
new Path(inode.fullPath).makeQualified(
myUri, null));
} else {
result[i++] = new FileStatus(0, true, 0, 0,
creationTime, creationTime, PERMISSION_555,
- ugi.getUserName(), ugi.getGroupNames()[0],
+ ugi.getShortUserName(), ugi.getGroupNames()[0],
new Path(inode.fullPath).makeQualified(
myUri, null));
}
@@ -1014,7 +1014,7 @@ public class ViewFileSystem extends FileSystem {
@Override
public AclStatus getAclStatus(Path path) throws IOException {
checkPathIsSlash(path);
- return new AclStatus.Builder().owner(ugi.getUserName())
+ return new AclStatus.Builder().owner(ugi.getShortUserName())
.group(ugi.getPrimaryGroupName())
.addEntries(AclUtil.getMinimalAcl(PERMISSION_555))
.stickyBit(false).build();
http://git-wip-us.apache.org/repos/asf/hadoop/blob/713d800e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/viewfs/ViewFs.java
----------------------------------------------------------------------
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 6195540..d5f8e81 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
@@ -845,7 +845,7 @@ public class ViewFs extends AbstractFileSystem {
public FileStatus getFileStatus(final Path f) throws IOException {
checkPathIsSlash(f);
return new FileStatus(0, true, 0, 0, creationTime, creationTime,
- PERMISSION_555, ugi.getUserName(), ugi.getPrimaryGroupName(),
+ PERMISSION_555, ugi.getShortUserName(), ugi.getPrimaryGroupName(),
new Path(theInternalDir.fullPath).makeQualified(
myUri, null));
}
@@ -865,13 +865,13 @@ public class ViewFs extends AbstractFileSystem {
INodeLink<AbstractFileSystem> inodelink =
(INodeLink<AbstractFileSystem>) inode;
result = new FileStatus(0, false, 0, 0, creationTime, creationTime,
- PERMISSION_555, ugi.getUserName(), ugi.getPrimaryGroupName(),
+ PERMISSION_555, ugi.getShortUserName(), ugi.getPrimaryGroupName(),
inodelink.getTargetLink(),
new Path(inode.fullPath).makeQualified(
myUri, null));
} else {
result = new FileStatus(0, true, 0, 0, creationTime, creationTime,
- PERMISSION_555, ugi.getUserName(), ugi.getPrimaryGroupName(),
+ PERMISSION_555, ugi.getShortUserName(), ugi.getPrimaryGroupName(),
new Path(inode.fullPath).makeQualified(
myUri, null));
}
@@ -910,14 +910,14 @@ public class ViewFs extends AbstractFileSystem {
result[i++] = new FileStatus(0, false, 0, 0,
creationTime, creationTime,
- PERMISSION_555, ugi.getUserName(), ugi.getPrimaryGroupName(),
+ PERMISSION_555, ugi.getShortUserName(), ugi.getPrimaryGroupName(),
link.getTargetLink(),
new Path(inode.fullPath).makeQualified(
myUri, null));
} else {
result[i++] = new FileStatus(0, true, 0, 0,
creationTime, creationTime,
- PERMISSION_555, ugi.getUserName(), ugi.getGroupNames()[0],
+ PERMISSION_555, ugi.getShortUserName(), ugi.getGroupNames()[0],
new Path(inode.fullPath).makeQualified(
myUri, null));
}
@@ -1043,7 +1043,7 @@ public class ViewFs extends AbstractFileSystem {
@Override
public AclStatus getAclStatus(Path path) throws IOException {
checkPathIsSlash(path);
- return new AclStatus.Builder().owner(ugi.getUserName())
+ return new AclStatus.Builder().owner(ugi.getShortUserName())
.group(ugi.getPrimaryGroupName())
.addEntries(AclUtil.getMinimalAcl(PERMISSION_555))
.stickyBit(false).build();
http://git-wip-us.apache.org/repos/asf/hadoop/blob/713d800e/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java
index ea4d9b1..8c4ddc3 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFileSystemBaseTest.java
@@ -20,8 +20,8 @@ package org.apache.hadoop.fs.viewfs;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
+import java.security.PrivilegedExceptionAction;
import java.util.Arrays;
-import java.util.ArrayList;
import java.util.List;
@@ -885,4 +885,24 @@ abstract public class ViewFileSystemBaseTest {
public void testInternalDeleteSnapshot() throws IOException {
fsView.deleteSnapshot(new Path("/internalDir"), "snap1");
}
+
+ @Test
+ public void testCheckOwnerWithFileStatus()
+ throws IOException, InterruptedException {
+ final UserGroupInformation userUgi = UserGroupInformation
+ .createUserForTesting("user@HADOOP.COM", new String[]{"hadoop"});
+ userUgi.doAs(new PrivilegedExceptionAction<Object>() {
+ @Override
+ public Object run() throws IOException {
+ UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
+ String doAsUserName = ugi.getUserName();
+ assertEquals(doAsUserName, "user@HADOOP.COM");
+ FileSystem vfs = FileSystem.get(FsConstants.VIEWFS_URI, conf);
+ FileStatus stat = vfs.getFileStatus(new Path("/internalDir"));
+ assertEquals(userUgi.getShortUserName(), stat.getOwner());
+ return null;
+ }
+ });
+ }
+
}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/713d800e/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java
----------------------------------------------------------------------
diff --git a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java
index ceebb26..16d2644 100644
--- a/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java
+++ b/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/viewfs/ViewFsBaseTest.java
@@ -29,6 +29,8 @@ import static org.junit.Assert.assertFalse;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
+import java.net.URISyntaxException;
+import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.List;
@@ -798,4 +800,24 @@ abstract public class ViewFsBaseTest {
public void testInternalDeleteSnapshot() throws IOException {
fcView.deleteSnapshot(new Path("/internalDir"), "snap1");
}
+
+ @Test
+ public void testOwnerForInternalDir()
+ throws IOException, InterruptedException, URISyntaxException {
+ final UserGroupInformation userUgi = UserGroupInformation
+ .createUserForTesting("user@HADOOP.COM", new String[]{"hadoop"});
+ userUgi.doAs(new PrivilegedExceptionAction<Object>() {
+ @Override
+ public Object run() throws IOException, URISyntaxException {
+ UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
+ String doAsUserName = ugi.getUserName();
+ assertEquals(doAsUserName, "user@HADOOP.COM");
+ FileContext
+ viewFS = FileContext.getFileContext(FsConstants.VIEWFS_URI, conf);
+ FileStatus stat = viewFS.getFileStatus(new Path("/internalDir"));
+ assertEquals(userUgi.getShortUserName(), stat.getOwner());
+ return null;
+ }
+ });
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org