This is an automated email from the ASF dual-hosted git repository.
adoroszlai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new cc55a70104 HDDS-10905. Override getHomeDirectory() in Ozone FileSystem
implementations (#6718)
cc55a70104 is described below
commit cc55a701040028132c254fcada9f4d7fa09af358
Author: SaketaChalamchala <[email protected]>
AuthorDate: Fri May 24 00:15:17 2024 -0700
HDDS-10905. Override getHomeDirectory() in Ozone FileSystem implementations
(#6718)
---
.../hadoop/fs/ozone/AbstractOzoneFileSystemTest.java | 15 +++++++++++++++
.../fs/ozone/AbstractRootedOzoneFileSystemTest.java | 6 ++++++
.../org/apache/hadoop/fs/ozone/BasicOzoneFileSystem.java | 6 ++++++
.../hadoop/fs/ozone/BasicRootedOzoneFileSystem.java | 6 ++++++
4 files changed, 33 insertions(+)
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractOzoneFileSystemTest.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractOzoneFileSystemTest.java
index 9f81adc6cc..dd29fb7e4d 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractOzoneFileSystemTest.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractOzoneFileSystemTest.java
@@ -83,6 +83,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
import java.nio.charset.StandardCharsets;
+import java.security.PrivilegedExceptionAction;
import java.time.Instant;
import java.time.ZoneOffset;
import java.util.ArrayList;
@@ -172,6 +173,10 @@ abstract class AbstractOzoneFileSystemTest {
private String bucketName;
private Trash trash;
private OMMetrics omMetrics;
+ private static final String USER1 = "regularuser1";
+ private static final UserGroupInformation UGI_USER1 = UserGroupInformation
+ .createUserForTesting(USER1, new String[] {"usergroup"});
+ private OzoneFileSystem userO3fs;
@BeforeAll
void init() throws Exception {
@@ -217,6 +222,10 @@ abstract class AbstractOzoneFileSystemTest {
statistics = (OzoneFSStorageStatistics)
o3fs.getOzoneFSOpsCountStatistics();
assertEquals(OzoneConsts.OZONE_URI_SCHEME, fs.getUri().getScheme());
assertEquals(OzoneConsts.OZONE_URI_SCHEME, statistics.getScheme());
+
+ userO3fs = UGI_USER1.doAs(
+ (PrivilegedExceptionAction<OzoneFileSystem>)()
+ -> (OzoneFileSystem) FileSystem.get(conf));
}
@AfterAll
@@ -258,6 +267,12 @@ abstract class AbstractOzoneFileSystemTest {
return bucketLayout;
}
+ @Test
+ void testUserHomeDirectory() {
+ assertEquals(new Path(fsRoot + "user/" + USER1),
+ userO3fs.getHomeDirectory());
+ }
+
@Test
public void testCreateFileShouldCheckExistenceOfDirWithSameName()
throws Exception {
diff --git
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractRootedOzoneFileSystemTest.java
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractRootedOzoneFileSystemTest.java
index ff136b3cae..2b2604535f 100644
---
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractRootedOzoneFileSystemTest.java
+++
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/AbstractRootedOzoneFileSystemTest.java
@@ -299,6 +299,12 @@ abstract class AbstractRootedOzoneFileSystemTest {
OzoneConsts.OZONE_OFS_URI_SCHEME, confTestLoader),
RootedOzoneFileSystem.class);
}
+ @Test
+ void testUserHomeDirectory() {
+ assertEquals(new Path(rootPath + "user/" + USER1),
+ userOfs.getHomeDirectory());
+ }
+
@Test
void testCreateDoesNotAddParentDirKeys() throws Exception {
Path grandparent = new Path(bucketPath,
diff --git
a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneFileSystem.java
b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneFileSystem.java
index cd09cf1d5a..aabf17d086 100644
---
a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneFileSystem.java
+++
b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicOzoneFileSystem.java
@@ -721,6 +721,12 @@ public class BasicOzoneFileSystem extends FileSystem {
return workingDir;
}
+ @Override
+ public Path getHomeDirectory() {
+ return makeQualified(new Path(OZONE_USER_DIR + "/"
+ + this.userName));
+ }
+
@Override
public Token<?> getDelegationToken(String renewer) throws IOException {
return adapter.getDelegationToken(renewer);
diff --git
a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneFileSystem.java
b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneFileSystem.java
index 8ad50058f1..23a921aaa1 100644
---
a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneFileSystem.java
+++
b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneFileSystem.java
@@ -970,6 +970,12 @@ public class BasicRootedOzoneFileSystem extends FileSystem
{
return workingDir;
}
+ @Override
+ public Path getHomeDirectory() {
+ return makeQualified(new Path(OZONE_USER_DIR + "/"
+ + this.userName));
+ }
+
@Override
public Token<?> getDelegationToken(String renewer) throws IOException {
return TracingUtil.executeInNewSpan("ofs getDelegationToken",
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]