This is an automated email from the ASF dual-hosted git repository.

siyao 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 80f544b704 HDDS-7570. Provide a shareable ofs://temp directory (#4027)
80f544b704 is described below

commit 80f544b70478bd39753fdd04ce663b322c137f04
Author: Neil Joshi <[email protected]>
AuthorDate: Thu Jan 12 10:55:14 2023 -0700

    HDDS-7570. Provide a shareable ofs://temp directory (#4027)
---
 .../common/src/main/resources/ozone-default.xml    |  10 ++
 .../main/java/org/apache/hadoop/ozone/OFSPath.java |  20 ++-
 .../org/apache/hadoop/ozone/om/OMConfigKeys.java   |   5 +
 .../main/smoketest/security/ozone-secure-fs.robot  |  51 ++++++++
 .../hadoop/fs/ozone/TestRootedOzoneFileSystem.java | 143 +++++++++++++++++++--
 .../hadoop/ozone/shell/TestOzoneShellHA.java       |  12 +-
 .../hadoop/ozone/om/TrashOzoneFileSystem.java      |  22 ++--
 .../apache/hadoop/ozone/om/TrashPolicyOzone.java   |   6 +-
 .../ozone/BasicRootedOzoneClientAdapterImpl.java   |  42 +++---
 .../fs/ozone/BasicRootedOzoneFileSystem.java       |  31 +++--
 .../org/apache/hadoop/fs/ozone/TestOFSPath.java    |  26 ++--
 .../ozone/admin/nssummary/NSSummaryAdmin.java      |   9 +-
 12 files changed, 304 insertions(+), 73 deletions(-)

diff --git a/hadoop-hdds/common/src/main/resources/ozone-default.xml 
b/hadoop-hdds/common/src/main/resources/ozone-default.xml
index a1c8787775..0bdb5fe91a 100644
--- a/hadoop-hdds/common/src/main/resources/ozone-default.xml
+++ b/hadoop-hdds/common/src/main/resources/ozone-default.xml
@@ -3466,6 +3466,16 @@
     </description>
   </property>
 
+  <property>
+    <name>ozone.om.enable.ofs.shared.tmp.dir</name>
+    <value>false</value>
+    <tag>OZONE, OM</tag>
+    <description>
+      Enable shared ofs tmp directory ofs://tmp.  Allows a root tmp
+      directory with sticky-bit behaviour.
+    </description>
+  </property>
+
   <property>
     <name>ozone.fs.listing.page.size</name>
     <value>1024</value>
diff --git 
a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OFSPath.java 
b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OFSPath.java
index 636bd1379d..3c6bd1fa10 100644
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OFSPath.java
+++ b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OFSPath.java
@@ -21,6 +21,7 @@ import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.hadoop.fs.Path;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.http.ParseException;
 import org.apache.hadoop.hdds.annotation.InterfaceAudience;
@@ -35,6 +36,8 @@ import java.security.NoSuchAlgorithmException;
 import java.util.StringTokenizer;
 
 import static org.apache.hadoop.fs.FileSystem.TRASH_PREFIX;
+import static 
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_ENABLE_OFS_SHARED_TMP_DIR;
+import static 
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_ENABLE_OFS_SHARED_TMP_DIR_DEFAULT;
 import static org.apache.hadoop.ozone.OzoneConsts.OZONE_OFS_URI_SCHEME;
 import static org.apache.hadoop.ozone.OzoneConsts.OZONE_URI_DELIMITER;
 
@@ -63,16 +66,22 @@ public class OFSPath {
   private String bucketName = "";
   private String mountName = "";
   private String keyName = "";
+  private OzoneConfiguration conf;
   private static final String OFS_MOUNT_NAME_TMP = "tmp";
   // Hard-code the volume name to tmp for the first implementation
   @VisibleForTesting
   public static final String OFS_MOUNT_TMP_VOLUMENAME = "tmp";
+  private static final String OFS_SHARED_TMP_BUCKETNAME = "tmp";
+  // Hard-coded bucket name to use when OZONE_OM_ENABLE_OFS_SHARED_TMP_DIR
+  // enabled;  HDDS-7746 to make this name configurable.
 
-  public OFSPath(Path path) {
+  public OFSPath(Path path, OzoneConfiguration conf) {
+    this.conf = conf;
     initOFSPath(path.toUri(), false);
   }
 
-  public OFSPath(String pathStr) {
+  public OFSPath(String pathStr, OzoneConfiguration conf) {
+    this.conf = conf;
     if (StringUtils.isEmpty(pathStr)) {
       return;
     }
@@ -102,7 +111,12 @@ public class OFSPath {
         // TODO: Make this configurable in the future.
         volumeName = OFS_MOUNT_TMP_VOLUMENAME;
         try {
-          bucketName = getTempMountBucketNameOfCurrentUser();
+          if (conf.getBoolean(OZONE_OM_ENABLE_OFS_SHARED_TMP_DIR,
+              OZONE_OM_ENABLE_OFS_SHARED_TMP_DIR_DEFAULT)) {
+            bucketName = OFS_SHARED_TMP_BUCKETNAME;
+          } else {
+            bucketName = getTempMountBucketNameOfCurrentUser();
+          }
         } catch (IOException ex) {
           throw new ParseException(
               "Failed to get temp bucket name for current user.");
diff --git 
a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/OMConfigKeys.java
 
b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/OMConfigKeys.java
index e72630a324..d4a843f3b0 100644
--- 
a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/OMConfigKeys.java
+++ 
b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/OMConfigKeys.java
@@ -405,4 +405,9 @@ public final class OMConfigKeys {
 
   public static final TimeDuration 
OZONE_OM_CONTAINER_LOCATION_CACHE_TTL_DEFAULT
       = TimeDuration.valueOf(360, TimeUnit.MINUTES);
+
+  public static final String OZONE_OM_ENABLE_OFS_SHARED_TMP_DIR
+      = "ozone.om.enable.ofs.shared.tmp.dir";
+  public static final boolean OZONE_OM_ENABLE_OFS_SHARED_TMP_DIR_DEFAULT
+      = false;
 }
diff --git 
a/hadoop-ozone/dist/src/main/smoketest/security/ozone-secure-fs.robot 
b/hadoop-ozone/dist/src/main/smoketest/security/ozone-secure-fs.robot
index 32cda0917e..df5cdfaafd 100644
--- a/hadoop-ozone/dist/src/main/smoketest/security/ozone-secure-fs.robot
+++ b/hadoop-ozone/dist/src/main/smoketest/security/ozone-secure-fs.robot
@@ -19,11 +19,15 @@ Library             OperatingSystem
 Library             String
 Library             BuiltIn
 Resource            ../commonlib.robot
+Resource            ../lib/fs.robot
 Test Timeout        5 minutes
 
 *** Variables ***
 ${ENDPOINT_URL}    http://s3g:9878
 ${SCM}             scm
+${TMP_MOUNT}       tmp
+${TMP_DIR}         tmp
+${SCHEME}          ofs
 
 *** Keywords ***
 Setup volume names
@@ -33,6 +37,17 @@ Setup volume names
     Set Suite Variable   ${volume3}            fstest3${random}
     Set Suite Variable   ${volume4}            fstest4${random}
 
+Format ofs TMPMOUNT
+    [arguments]    ${volume}  ${path}=${EMPTY}    ${om}=${OM_SERVICE_ID}
+
+    ${om_with_trailing} =     Run Keyword If    '${om}' != '${EMPTY}'      
Ensure Trailing   /    ${om}
+    ...                       ELSE              Set Variable    ${EMPTY}
+
+    ${path_with_leading} =    Run Keyword If    '${path}' != '${EMPTY}'    
Ensure Leading    /    ${path}
+    ...                       ELSE              Set Variable    ${EMPTY}
+
+    [return]       ofs://${om_with_trailing}${volume}/${path_with_leading}
+
 *** Test Cases ***
 Create volume bucket with wrong credentials
     Execute             kdestroy
@@ -153,3 +168,39 @@ Test native authorizer
     Execute         ozone sh key list /${volume3}/bk1
     Execute         kdestroy
     Run Keyword     Kinit test user     testuser    testuser.keytab
+
+Test tmp mount for shared ofs tmp dir
+   ${result} =      Execute And Ignore Error    ozone getconf confKey 
ozone.om.enable.ofs.shared.tmp.dir
+   ${contains} =    Evaluate        "true" in """${result}"""
+   IF   ${contains} == ${True}
+        Run Keyword   Kinit test user     testuser     testuser.keytab
+        Execute       ozone sh volume create /${TMP_MOUNT} -u testuser
+        Execute       ozone sh bucket create /${TMP_MOUNT}/${TMP_DIR} -u 
testuser
+        Execute       ozone sh volume addacl /${TMP_MOUNT} -a 
user:testuser/[email protected]:a,user:testuser2/[email protected]:rw
+        Execute       ozone sh bucket addacl /${TMP_MOUNT}/${TMP_DIR} -a 
user:testuser/[email protected]:a,user:testuser2/[email protected]:rwlc
+
+        ${tmpdirmount} =        Format ofs TMPMOUNT     ${TMP_MOUNT}
+        ${result} =    Execute               ozone fs -put ./NOTICE.txt 
${tmpdirmount}
+                   Should Be Empty       ${result}
+        Run Keyword   Kinit test user     testuser2     testuser2.keytab
+        ${result} =    Execute               ozone fs -put ./LICENSE.txt 
${tmpdirmount}
+                   Should Be Empty       ${result}
+
+        ${result} =    Execute               ozone fs -ls ${tmpdirmount}
+                   Should contain        ${result}         NOTICE.txt
+                   Should contain        ${result}         LICENSE.txt
+
+
+        ${result} =     Execute And Ignore Error         ozone fs -rm 
-skipTrash ${tmpdirmount}/NOTICE.txt
+                    Should contain      ${result}    error
+        ${result} =    Execute               ozone fs -rm -skipTrash 
${tmpdirmount}/LICENSE.txt
+                   Should contain        ${result}         Deleted
+
+        Run Keyword   Kinit test user     testuser     testuser.keytab
+        ${result} =    Execute               ozone fs -rm -skipTrash 
${tmpdirmount}/NOTICE.txt
+                   Should contain        ${result}         Deleted
+
+        Execute       ozone fs -rm -r -skipTrash ${tmpdirmount}
+        Execute       ozone sh volume delete /${TMP_MOUNT}
+   END
+
diff --git 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestRootedOzoneFileSystem.java
 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestRootedOzoneFileSystem.java
index 3dbec994fe..9f34eb89ac 100644
--- 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestRootedOzoneFileSystem.java
+++ 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/fs/ozone/TestRootedOzoneFileSystem.java
@@ -87,6 +87,7 @@ import java.io.IOException;
 import java.security.PrivilegedExceptionAction;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.BitSet;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -110,8 +111,14 @@ import static 
org.apache.hadoop.ozone.OzoneAcl.AclScope.ACCESS;
 import static 
org.apache.hadoop.ozone.OzoneConfigKeys.OZONE_FS_ITERATE_BATCH_SIZE;
 import static org.apache.hadoop.ozone.OzoneConsts.OZONE_URI_DELIMITER;
 import static org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_ADDRESS_KEY;
+import static 
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_ENABLE_OFS_SHARED_TMP_DIR;
 import static 
org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.BUCKET_NOT_FOUND;
 import static 
org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.VOLUME_NOT_FOUND;
+import static 
org.apache.hadoop.ozone.om.exceptions.OMException.ResultCodes.PERMISSION_DENIED;
+import static 
org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLType.READ;
+import static 
org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLType.WRITE;
+import static 
org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLType.DELETE;
+import static 
org.apache.hadoop.ozone.security.acl.IAccessAuthorizer.ACLType.LIST;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -296,7 +303,7 @@ public class TestRootedOzoneFileSystem {
     ContractTestUtils.touch(fs, child);
 
     OzoneKeyDetails key = getKey(child, false);
-    OFSPath childOFSPath = new OFSPath(child);
+    OFSPath childOFSPath = new OFSPath(child, conf);
     Assert.assertEquals(key.getName(), childOFSPath.getKeyName());
 
     // Creating a child should not add parent keys to the bucket
@@ -382,7 +389,7 @@ public class TestRootedOzoneFileSystem {
 
     // Deleting the only child should create the parent dir key if it does
     // not exist
-    OFSPath parentOFSPath = new OFSPath(parent);
+    OFSPath parentOFSPath = new OFSPath(parent, conf);
     String parentKey = parentOFSPath.getKeyName() + "/";
     OzoneKeyDetails parentKeyInfo = getKey(parent, true);
     Assert.assertEquals(parentKey, parentKeyInfo.getName());
@@ -695,7 +702,7 @@ public class TestRootedOzoneFileSystem {
     // Check volume and bucket existence, they should both be created.
     OzoneVolume ozoneVolume = objectStore.getVolume(volumeNameLocal);
     OzoneBucket ozoneBucket = ozoneVolume.getBucket(bucketNameLocal);
-    OFSPath ofsPathDir1 = new OFSPath(dir12);
+    OFSPath ofsPathDir1 = new OFSPath(dir12, conf);
     String key = ofsPathDir1.getKeyName() + "/";
     OzoneKeyDetails ozoneKeyDetails = ozoneBucket.getKey(key);
     Assert.assertEquals(key, ozoneKeyDetails.getName());
@@ -965,7 +972,7 @@ public class TestRootedOzoneFileSystem {
     if (isDirectory) {
       key = key + OZONE_URI_DELIMITER;
     }
-    OFSPath ofsPath = new OFSPath(key);
+    OFSPath ofsPath = new OFSPath(key, conf);
     String keyInBucket = ofsPath.getKeyName();
     return cluster.getClient().getObjectStore().getVolume(volumeName)
         .getBucket(bucketName).getKey(keyInBucket);
@@ -1006,7 +1013,7 @@ public class TestRootedOzoneFileSystem {
       throws IOException {
     fs.delete(new Path(bucketPath1, "dir1"), true);
     fs.delete(new Path(bucketPath1, "dir2"), true);
-    OFSPath ofsPath = new OFSPath(bucketPath1);
+    OFSPath ofsPath = new OFSPath(bucketPath1, conf);
     OzoneVolume volume = objectStore.getVolume(ofsPath.getVolumeName());
     volume.deleteBucket(ofsPath.getBucketName());
     objectStore.deleteVolume(ofsPath.getVolumeName());
@@ -1029,7 +1036,7 @@ public class TestRootedOzoneFileSystem {
     Assert.assertEquals(2, fileStatusBucket.length);
     // listStatus("/volume")
     Path volume = new Path(
-        OZONE_URI_DELIMITER + new OFSPath(bucketPath1).getVolumeName());
+        OZONE_URI_DELIMITER + new OFSPath(bucketPath1, conf).getVolumeName());
     FileStatus[] fileStatusVolume = ofs.listStatus(volume);
     Assert.assertEquals(1, fileStatusVolume.length);
     Assert.assertEquals(ownerShort, fileStatusVolume[0].getOwner());
@@ -1130,7 +1137,7 @@ public class TestRootedOzoneFileSystem {
     listStatusCheckHelper(bucketPath1);
     // listStatus("/volume")
     Path volume = new Path(
-        OZONE_URI_DELIMITER + new OFSPath(bucketPath1).getVolumeName());
+        OZONE_URI_DELIMITER + new OFSPath(bucketPath1, conf).getVolumeName());
     listStatusCheckHelper(volume);
     // listStatus("/")
     Path root = new Path(OZONE_URI_DELIMITER);
@@ -1216,7 +1223,123 @@ public class TestRootedOzoneFileSystem {
     }
   }
 
-   /*
+  @Test
+  public void testSharedTmpDir() throws IOException {
+    // Prep
+    conf.setBoolean(OZONE_OM_ENABLE_OFS_SHARED_TMP_DIR, true);
+    // Use ClientProtocol to pass in volume ACL, ObjectStore won't do it
+    ClientProtocol proxy = objectStore.getClientProxy();
+    // Get default acl rights for user
+    OzoneAclConfig aclConfig = conf.getObject(OzoneAclConfig.class);
+    ACLType userRights = aclConfig.getUserDefaultRights();
+    // Construct ACL for world access
+    // ACL admin owner, world read+write
+    BitSet aclRights = new BitSet();
+    aclRights.set(READ.ordinal());
+    aclRights.set(WRITE.ordinal());
+    List<OzoneAcl> objectAcls = new ArrayList<>();
+    objectAcls.add(new OzoneAcl(ACLIdentityType.WORLD, "",
+        aclRights, ACCESS));
+    objectAcls.add(new OzoneAcl(ACLIdentityType.USER, "admin", userRights,
+        ACCESS));
+    // volume acls have all access to admin and read+write access to world
+
+    // Construct VolumeArgs
+    VolumeArgs volumeArgs = new VolumeArgs.Builder()
+        .setAdmin("admin")
+        .setOwner("admin")
+        .setAcls(Collections.unmodifiableList(objectAcls))
+        .setQuotaInNamespace(1000)
+        .setQuotaInBytes(Long.MAX_VALUE).build();
+    // Sanity check
+    Assert.assertEquals("admin", volumeArgs.getOwner());
+    Assert.assertEquals("admin", volumeArgs.getAdmin());
+    Assert.assertEquals(Long.MAX_VALUE, volumeArgs.getQuotaInBytes());
+    Assert.assertEquals(1000, volumeArgs.getQuotaInNamespace());
+    Assert.assertEquals(0, volumeArgs.getMetadata().size());
+    Assert.assertEquals(2, volumeArgs.getAcls().size());
+    // Create volume "tmp" with world access read+write to access tmp mount
+    // admin has all access to tmp mount
+    proxy.createVolume(OFSPath.OFS_MOUNT_TMP_VOLUMENAME, volumeArgs);
+
+    OzoneVolume vol = objectStore.getVolume(OFSPath.OFS_MOUNT_TMP_VOLUMENAME);
+    Assert.assertNotNull(vol);
+
+    // Begin test
+    String hashedUsername = OFSPath.getTempMountBucketNameOfCurrentUser();
+
+    // Expect failure since temp bucket for current user is not created yet
+    try {
+      vol.getBucket(hashedUsername);
+    } catch (OMException ex) {
+      // Expect BUCKET_NOT_FOUND
+      if (!ex.getResult().equals(BUCKET_NOT_FOUND)) {
+        Assert.fail("Temp bucket for current user shouldn't have been 
created");
+      }
+    }
+
+    // set acls for shared tmp mount under the tmp volume
+    objectAcls.clear();
+    objectAcls.add(new OzoneAcl(ACLIdentityType.USER, "admin", userRights,
+        ACCESS));
+    aclRights.clear(DELETE.ordinal());
+    aclRights.set(LIST.ordinal());
+    objectAcls.add(new OzoneAcl(ACLIdentityType.WORLD, "",
+        aclRights, ACCESS));
+    objectAcls.add(new OzoneAcl(ACLIdentityType.USER, "admin", userRights,
+        ACCESS));
+    // bucket acls have all access to admin and read+write+list access to world
+
+    BucketArgs bucketArgs = new BucketArgs.Builder()
+        .setOwner("admin")
+        .setAcls(Collections.unmodifiableList(objectAcls))
+        .setQuotaInNamespace(1000)
+        .setQuotaInBytes(Long.MAX_VALUE).build();
+
+    // Create bucket "tmp" with world access read+write+list to tmp directory
+    // admin has all access to tmp mount
+    proxy.createBucket(OFSPath.OFS_MOUNT_TMP_VOLUMENAME,
+        OFSPath.OFS_MOUNT_TMP_VOLUMENAME, bucketArgs);
+
+    // Write under /tmp/
+    Path dir1 = new Path("/tmp/dir1");
+    userOfs.mkdirs(dir1);
+
+    try (FSDataOutputStream stream = userOfs.create(new Path(
+        "/tmp/dir1/file1"))) {
+      stream.write(1);
+    }
+
+    // Verify temp bucket creation
+    OzoneBucket bucket = vol.getBucket("tmp");
+    Assert.assertNotNull(bucket);
+    // Verify dir1 creation
+    FileStatus[] fileStatuses = fs.listStatus(new Path("/tmp/"));
+    Assert.assertEquals(1, fileStatuses.length);
+    Assert.assertEquals(
+        "/tmp/dir1", fileStatuses[0].getPath().toUri().getPath());
+    // Verify file1 creation
+    FileStatus[] fileStatusesInDir1 = fs.listStatus(dir1);
+    Assert.assertEquals(1, fileStatusesInDir1.length);
+    Assert.assertEquals("/tmp/dir1/file1",
+        fileStatusesInDir1[0].getPath().toUri().getPath());
+
+    // Cleanup
+    userOfs.delete(dir1, true);
+    try {
+      userOfs.delete(new Path("/tmp"), true);
+    } catch (OMException ex) {
+      // Expect PERMISSION_DENIED, User regularuser1 doesn't have DELETE
+      // permission for /tmp
+      if (!ex.getResult().equals(PERMISSION_DENIED)) {
+        Assert.fail("Temp bucket cannot be deleted by current user");
+      }
+    }
+    fs.delete(new Path("/tmp"), true);
+    proxy.deleteVolume(OFSPath.OFS_MOUNT_TMP_VOLUMENAME);
+  }
+
+  /*
    * OFS: Test /tmp mount behavior.
    */
   @Test
@@ -1916,7 +2039,7 @@ public class TestRootedOzoneFileSystem {
         .createFile(vol + "/" + buck + "/test", (short) 3, true, false)) {
       file.write(new byte[1024]);
     }
-    OFSPath ofsPath = new OFSPath(vol + "/" + buck + "/test");
+    OFSPath ofsPath = new OFSPath(vol + "/" + buck + "/test", conf);
     final OzoneBucket bucket = adapter.getBucket(ofsPath, false);
     final OzoneKeyDetails key = bucket.getKey(ofsPath.getKeyName());
     Assert.assertEquals(key.getReplicationConfig().getReplicationType().name(),
@@ -1946,7 +2069,7 @@ public class TestRootedOzoneFileSystem {
         .createFile(vol + "/" + buck + "/test", (short) 3, true, false)) {
       file.write(new byte[1024]);
     }
-    OFSPath ofsPath = new OFSPath(vol + "/" + buck + "/test");
+    OFSPath ofsPath = new OFSPath(vol + "/" + buck + "/test", conf);
     final OzoneBucket bucket = adapter.getBucket(ofsPath, false);
     final OzoneKeyDetails key = bucket.getKey(ofsPath.getKeyName());
     Assert.assertEquals(ReplicationType.EC.name(),
diff --git 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHA.java
 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHA.java
index a559266a88..4996371a3c 100644
--- 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHA.java
+++ 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHA.java
@@ -590,14 +590,14 @@ public class TestOzoneShellHA {
     final String strKey1 = strDir1 + "/key1";
     final Path pathKey1 = new Path(strKey1);
     final Path trashPathKey1 = Path.mergePaths(
-        new Path(new OFSPath(strKey1).getTrashRoot(), trashCurrent),
-        new Path(dir1, "key1"));
+        new Path(new OFSPath(strKey1, clientConf).getTrashRoot(),
+            trashCurrent), new Path(dir1, "key1"));
 
     final String strKey2 = strDir1 + "/key2";
     final Path pathKey2 = new Path(strKey2);
     final Path trashPathKey2 = Path.mergePaths(
-        new Path(new OFSPath(strKey2).getTrashRoot(), trashCurrent),
-        new Path(dir1, "key2"));
+        new Path(new OFSPath(strKey2, clientConf).getTrashRoot(),
+            trashCurrent), new Path(dir1, "key2"));
 
     int res;
     try {
@@ -694,8 +694,8 @@ public class TestOzoneShellHA {
     final String[] rmTrashArgs = new String[] {"-rm", "-R",
                                                testVolBucket + "/.Trash"};
     final Path trashPathKey1 = Path.mergePaths(new Path(
-            new OFSPath(testKey).getTrashRoot(), new Path("Current")),
-            new Path(keyName));
+            new OFSPath(testKey, clientConf).getTrashRoot(),
+            new Path("Current")), new Path(keyName));
     FileSystem fs = FileSystem.get(clientConf);
 
     try {
diff --git 
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/TrashOzoneFileSystem.java
 
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/TrashOzoneFileSystem.java
index 46bc57d0ef..6779c3378b 100644
--- 
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/TrashOzoneFileSystem.java
+++ 
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/TrashOzoneFileSystem.java
@@ -18,6 +18,7 @@ package org.apache.hadoop.ozone.om;
 
 import com.google.common.base.Preconditions;
 import com.google.protobuf.RpcController;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
 import org.apache.hadoop.ozone.ClientVersion;
 import org.apache.hadoop.ozone.om.exceptions.OMException;
 import org.apache.hadoop.fs.FSDataInputStream;
@@ -90,6 +91,7 @@ public class TrashOzoneFileSystem extends FileSystem {
     this.userName =
           UserGroupInformation.getCurrentUser().getShortUserName();
     this.runCount = new AtomicLong(0);
+    setConf(ozoneManager.getConfiguration());
   }
 
   private RaftClientRequest getRatisRequest(
@@ -154,8 +156,8 @@ public class TrashOzoneFileSystem extends FileSystem {
     ozoneManager.getMetrics().incNumTrashRenames();
     LOG.trace("Src:" + src + "Dst:" + dst);
     // check whether the src and dst belong to the same bucket & trashroot.
-    OFSPath srcPath = new OFSPath(src);
-    OFSPath dstPath = new OFSPath(dst);
+    OFSPath srcPath = new OFSPath(src, OzoneConfiguration.of(getConf()));
+    OFSPath dstPath = new OFSPath(dst, OzoneConfiguration.of(getConf()));
     OmBucketInfo bucket = ozoneManager.getBucketInfo(srcPath.getVolumeName(),
         srcPath.getBucketName());
     if (bucket.getBucketLayout().isFileSystemOptimized()) {
@@ -190,7 +192,7 @@ public class TrashOzoneFileSystem extends FileSystem {
   @Override
   public boolean delete(Path path, boolean b) throws IOException {
     ozoneManager.getMetrics().incNumTrashDeletes();
-    OFSPath srcPath = new OFSPath(path);
+    OFSPath srcPath = new OFSPath(path, OzoneConfiguration.of(getConf()));
     OmBucketInfo bucket = ozoneManager.getBucketInfo(srcPath.getVolumeName(),
         srcPath.getBucketName());
     if (bucket.getBucketLayout().isFileSystemOptimized()) {
@@ -283,7 +285,7 @@ public class TrashOzoneFileSystem extends FileSystem {
   }
 
   private OmKeyArgs constructOmKeyArgs(Path path) {
-    OFSPath ofsPath = new OFSPath(path);
+    OFSPath ofsPath = new OFSPath(path, OzoneConfiguration.of(getConf()));
     String volume = ofsPath.getVolumeName();
     String bucket = ofsPath.getBucketName();
     String key = ofsPath.getKeyName();
@@ -388,7 +390,8 @@ public class TrashOzoneFileSystem extends FileSystem {
       List<String> keyPathList = new ArrayList<>();
       if (status.isDirectory()) {
         LOG.trace("Iterating directory: {}", pathKey);
-        OFSPath ofsPath = new OFSPath(pathKey);
+        OFSPath ofsPath = new OFSPath(pathKey,
+            OzoneConfiguration.of(getConf()));
         String ofsPathprefix =
             ofsPath.getNonKeyPathNoPrefixDelim() + OZONE_URI_DELIMITER;
         while (keyIterator.hasNext()) {
@@ -482,8 +485,10 @@ public class TrashOzoneFileSystem extends FileSystem {
     boolean processKeyPath(List<String> keyPathList) {
       for (String keyPath : keyPathList) {
         String newPath = dstPath.concat(keyPath.substring(srcPath.length()));
-        OFSPath src = new OFSPath(keyPath);
-        OFSPath dst = new OFSPath(newPath);
+        OFSPath src = new OFSPath(keyPath,
+            OzoneConfiguration.of(getConf()));
+        OFSPath dst = new OFSPath(newPath,
+            OzoneConfiguration.of(getConf()));
 
         OzoneManagerProtocolProtos.OMRequest omRequest =
             getRenameKeyRequest(src, dst);
@@ -552,7 +557,8 @@ public class TrashOzoneFileSystem extends FileSystem {
     boolean processKeyPath(List<String> keyPathList) {
       LOG.trace("Deleting keys: {}", keyPathList);
       for (String keyPath : keyPathList) {
-        OFSPath path = new OFSPath(keyPath);
+        OFSPath path = new OFSPath(keyPath,
+            OzoneConfiguration.of(getConf()));
         OzoneManagerProtocolProtos.OMRequest omRequest =
             getDeleteKeysRequest(path);
         try {
diff --git 
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/TrashPolicyOzone.java
 
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/TrashPolicyOzone.java
index da42265438..83a1ee5c16 100644
--- 
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/TrashPolicyOzone.java
+++ 
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/TrashPolicyOzone.java
@@ -151,7 +151,8 @@ public class TrashPolicyOzone extends TrashPolicyDefault {
       Path trashPath;
       Path baseTrashPath;
       if (fs.getUri().getScheme().equals(OzoneConsts.OZONE_OFS_URI_SCHEME)) {
-        OFSPath ofsPath = new OFSPath(path);
+        OFSPath ofsPath = new OFSPath(path,
+            OzoneConfiguration.of(configuration));
         // trimming volume and bucket in order to be compatible with o3fs
         // Also including volume and bucket name in the path is redundant as
         // the key is already in a particular volume and bucket.
@@ -222,7 +223,8 @@ public class TrashPolicyOzone extends TrashPolicyDefault {
     // Check to see if bucket is path item to be deleted.
     // Cannot moveToTrash if bucket is deleted,
     // return error for this condition
-    OFSPath ofsPath = new OFSPath(key.substring(1));
+    OFSPath ofsPath = new OFSPath(key.substring(1),
+        OzoneConfiguration.of(configuration));
     if (path.isRoot() || ofsPath.isBucket()) {
       throw new IOException("Recursive rm of bucket "
           + path.toString() + " not permitted");
diff --git 
a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java
 
b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java
index b14c781009..2606bd4fdf 100644
--- 
a/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java
+++ 
b/hadoop-ozone/ozonefs-common/src/main/java/org/apache/hadoop/fs/ozone/BasicRootedOzoneClientAdapterImpl.java
@@ -345,7 +345,8 @@ public class BasicRootedOzoneClientAdapterImpl
   @Override
   public InputStream readFile(String pathStr) throws IOException {
     incrementCounter(Statistic.OBJECTS_READ, 1);
-    OFSPath ofsPath = new OFSPath(pathStr);
+    OFSPath ofsPath = new OFSPath(pathStr,
+        config);
     String key = ofsPath.getKeyName();
     try {
       OzoneBucket bucket = getBucket(ofsPath, false);
@@ -370,7 +371,7 @@ public class BasicRootedOzoneClientAdapterImpl
   public OzoneFSOutputStream createFile(String pathStr, short replication,
       boolean overWrite, boolean recursive) throws IOException {
     incrementCounter(Statistic.OBJECTS_CREATED, 1);
-    OFSPath ofsPath = new OFSPath(pathStr);
+    OFSPath ofsPath = new OFSPath(pathStr, config);
     if (ofsPath.isRoot() || ofsPath.isVolume() || ofsPath.isBucket()) {
       throw new IOException("Cannot create file under root or volume.");
     }
@@ -399,7 +400,7 @@ public class BasicRootedOzoneClientAdapterImpl
       short replication, boolean overWrite, boolean recursive)
       throws IOException {
     incrementCounter(Statistic.OBJECTS_CREATED, 1);
-    OFSPath ofsPath = new OFSPath(pathStr);
+    OFSPath ofsPath = new OFSPath(pathStr, config);
     if (ofsPath.isRoot() || ofsPath.isVolume() || ofsPath.isBucket()) {
       throw new IOException("Cannot create file under root or volume.");
     }
@@ -444,8 +445,8 @@ public class BasicRootedOzoneClientAdapterImpl
   @Override
   public void rename(String path, String newPath) throws IOException {
     incrementCounter(Statistic.OBJECTS_RENAMED, 1);
-    OFSPath ofsPath = new OFSPath(path);
-    OFSPath ofsNewPath = new OFSPath(newPath);
+    OFSPath ofsPath = new OFSPath(path, config);
+    OFSPath ofsNewPath = new OFSPath(newPath, config);
 
     // Check path and newPathName are in the same volume and same bucket.
     // This should have been checked in BasicRootedOzoneFileSystem#rename
@@ -470,8 +471,8 @@ public class BasicRootedOzoneClientAdapterImpl
   void rename(OzoneBucket bucket, String path, String newPath)
       throws IOException {
     incrementCounter(Statistic.OBJECTS_RENAMED, 1);
-    OFSPath ofsPath = new OFSPath(path);
-    OFSPath ofsNewPath = new OFSPath(newPath);
+    OFSPath ofsPath = new OFSPath(path, config);
+    OFSPath ofsNewPath = new OFSPath(newPath, config);
     // No same-bucket policy check here since this call path is controlled
     String key = ofsPath.getKeyName();
     String newKey = ofsNewPath.getKeyName();
@@ -488,7 +489,7 @@ public class BasicRootedOzoneClientAdapterImpl
   public boolean createDirectory(String pathStr) throws IOException {
     LOG.trace("creating dir for path: {}", pathStr);
     incrementCounter(Statistic.OBJECTS_CREATED, 1);
-    OFSPath ofsPath = new OFSPath(pathStr);
+    OFSPath ofsPath = new OFSPath(pathStr, config);
     if (ofsPath.getVolumeName().isEmpty()) {
       // Volume name unspecified, invalid param, return failure
       return false;
@@ -530,7 +531,7 @@ public class BasicRootedOzoneClientAdapterImpl
       throws IOException {
     LOG.trace("issuing delete for path to key: {}", path);
     incrementCounter(Statistic.OBJECTS_DELETED, 1);
-    OFSPath ofsPath = new OFSPath(path);
+    OFSPath ofsPath = new OFSPath(path, config);
     String keyName = ofsPath.getKeyName();
     if (keyName.length() == 0) {
       return false;
@@ -565,11 +566,12 @@ public class BasicRootedOzoneClientAdapterImpl
       return true;
     }
     String firstKeyPath = keyNameList.get(0);
-    final String volAndBucket = new OFSPath(firstKeyPath).getNonKeyPath();
+    final String volAndBucket = new OFSPath(firstKeyPath, config)
+        .getNonKeyPath();
     // return true only if all key paths' volume and bucket in the list match
     // the first element's
     return keyNameList.stream().skip(1).allMatch(p ->
-        new OFSPath(p).getNonKeyPath().equals(volAndBucket));
+        new OFSPath(p, config).getNonKeyPath().equals(volAndBucket));
   }
 
   /**
@@ -595,7 +597,7 @@ public class BasicRootedOzoneClientAdapterImpl
       return false;
     }
     try {
-      OFSPath firstKeyPath = new OFSPath(keyNameList.get(0));
+      OFSPath firstKeyPath = new OFSPath(keyNameList.get(0), config);
       OzoneBucket bucket = getBucket(firstKeyPath, false);
       return deleteObjects(bucket, keyNameList);
     } catch (IOException ioe) {
@@ -616,7 +618,7 @@ public class BasicRootedOzoneClientAdapterImpl
    */
   boolean deleteObjects(OzoneBucket bucket, List<String> keyNameList) {
     List<String> keyList = keyNameList.stream()
-        .map(p -> new OFSPath(p).getKeyName())
+        .map(p -> new OFSPath(p, config).getKeyName())
         .collect(Collectors.toList());
     try {
       incrementCounter(Statistic.OBJECTS_DELETED, keyNameList.size());
@@ -632,7 +634,7 @@ public class BasicRootedOzoneClientAdapterImpl
   public FileStatusAdapter getFileStatus(String path, URI uri,
       Path qualifiedPath, String userName) throws IOException {
     incrementCounter(Statistic.OBJECTS_QUERY, 1);
-    OFSPath ofsPath = new OFSPath(path);
+    OFSPath ofsPath = new OFSPath(path, config);
     String key = ofsPath.getKeyName();
     if (ofsPath.isRoot()) {
       return getFileStatusAdapterForRoot(uri);
@@ -717,7 +719,7 @@ public class BasicRootedOzoneClientAdapterImpl
   @Override
   public Iterator<BasicKeyInfo> listKeys(String pathStr) throws IOException {
     incrementCounter(Statistic.OBJECTS_LIST, 1);
-    OFSPath ofsPath = new OFSPath(pathStr);
+    OFSPath ofsPath = new OFSPath(pathStr, config);
     String key = ofsPath.getKeyName();
     OzoneBucket bucket;
     try {
@@ -736,7 +738,7 @@ public class BasicRootedOzoneClientAdapterImpl
       boolean recursive, String startPath, long numEntries,
       URI uri, Path workingDir, String username) throws IOException {
 
-    OFSPath ofsStartPath = new OFSPath(startPath);
+    OFSPath ofsStartPath = new OFSPath(startPath, config);
     // list volumes
     Iterator<? extends OzoneVolume> iter = objectStore.listVolumesByUser(
         username, null, ofsStartPath.getVolumeName());
@@ -760,7 +762,7 @@ public class BasicRootedOzoneClientAdapterImpl
       boolean recursive, String startPath, long numEntries,
       URI uri, Path workingDir, String username) throws IOException {
 
-    OFSPath ofsStartPath = new OFSPath(startPath);
+    OFSPath ofsStartPath = new OFSPath(startPath, config);
     // list buckets in the volume
     OzoneVolume volume = objectStore.getVolume(volumeStr);
     UserGroupInformation ugi =
@@ -824,12 +826,12 @@ public class BasicRootedOzoneClientAdapterImpl
     //  OFSPath initializer will error out.
     //  The goal is to refuse processing startPaths from other authorities.
 
-    OFSPath ofsPath = new OFSPath(pathStr);
+    OFSPath ofsPath = new OFSPath(pathStr, config);
     if (ofsPath.isRoot()) {
       return listStatusRoot(
           recursive, startPath, numEntries, uri, workingDir, username);
     }
-    OFSPath ofsStartPath = new OFSPath(startPath);
+    OFSPath ofsStartPath = new OFSPath(startPath, config);
     if (ofsPath.isVolume()) {
       String startBucket = ofsStartPath.getBucketName();
       return listStatusVolume(ofsPath.getVolumeName(),
@@ -1148,7 +1150,7 @@ public class BasicRootedOzoneClientAdapterImpl
     OzoneClientConfig.ChecksumCombineMode combineMode =
         config.getObject(OzoneClientConfig.class).getChecksumCombineMode();
 
-    OFSPath ofsPath = new OFSPath(keyName);
+    OFSPath ofsPath = new OFSPath(keyName, config);
 
     OzoneVolume volume = objectStore.getVolume(ofsPath.getVolumeName());
     OzoneBucket bucket = getBucket(ofsPath, false);
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 b78936678f..764098451c 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
@@ -283,7 +283,8 @@ public class BasicRootedOzoneFileSystem extends FileSystem {
       this.dstPath = pathToKey(dstPath);
       LOG.trace("rename from:{} to:{}", this.srcPath, this.dstPath);
       // Initialize bucket here to reduce number of RPC calls
-      OFSPath ofsPath = new OFSPath(srcPath);
+      OFSPath ofsPath = new OFSPath(srcPath,
+          OzoneConfiguration.of(getConfSource()));
       // TODO: Refactor later.
       adapterImpl = (BasicRootedOzoneClientAdapterImpl) adapter;
       this.bucket = adapterImpl.getBucket(ofsPath, false);
@@ -328,8 +329,10 @@ public class BasicRootedOzoneFileSystem extends FileSystem 
{
     }
 
     // src and dst should be in the same bucket
-    OFSPath ofsSrc = new OFSPath(src);
-    OFSPath ofsDst = new OFSPath(dst);
+    OFSPath ofsSrc = new OFSPath(src,
+        OzoneConfiguration.of(getConfSource()));
+    OFSPath ofsDst = new OFSPath(dst,
+        OzoneConfiguration.of(getConfSource()));
     if (!ofsSrc.isInSameBucketAs(ofsDst)) {
       throw new IOException("Cannot rename a key to a different bucket");
     }
@@ -476,7 +479,8 @@ public class BasicRootedOzoneFileSystem extends FileSystem {
         throw new PathIsNotEmptyDirectoryException(f.toString());
       }
       // Initialize bucket here to reduce number of RPC calls
-      OFSPath ofsPath = new OFSPath(f);
+      OFSPath ofsPath = new OFSPath(f,
+          OzoneConfiguration.of(getConfSource()));
       // TODO: Refactor later.
       adapterImpl = (BasicRootedOzoneClientAdapterImpl) adapter;
       this.bucket = adapterImpl.getBucket(ofsPath, false);
@@ -506,7 +510,8 @@ public class BasicRootedOzoneFileSystem extends FileSystem {
       this.f = f;
       this.recursive = recursive;
       // Initialize bucket here to reduce number of RPC calls
-      OFSPath ofsPath = new OFSPath(f);
+      OFSPath ofsPath = new OFSPath(f,
+          OzoneConfiguration.of(getConfSource()));
       adapterImpl = (BasicRootedOzoneClientAdapterImpl) adapter;
       this.bucket = adapterImpl.getBucket(ofsPath, false);
       LOG.debug("Deleting bucket with name {} is via DeleteIteratorWithFSO.",
@@ -537,7 +542,8 @@ public class BasicRootedOzoneFileSystem extends FileSystem {
     DeleteIteratorFactory(Path f, boolean recursive) {
       this.path = f;
       this.recursive = recursive;
-      this.ofsPath = new OFSPath(f);
+      this.ofsPath = new OFSPath(f,
+          OzoneConfiguration.of(getConfSource()));
     }
 
     OzoneListingIterator getDeleteIterator()
@@ -602,7 +608,9 @@ public class BasicRootedOzoneFileSystem extends FileSystem {
 
     if (status.isDirectory()) {
       LOG.debug("delete: Path is a directory: {}", f);
-      OFSPath ofsPath = new OFSPath(key);
+
+      OFSPath ofsPath = new OFSPath(key,
+          OzoneConfiguration.of(getConfSource()));
 
       // Handle rm root
       if (ofsPath.isRoot()) {
@@ -843,7 +851,8 @@ public class BasicRootedOzoneFileSystem extends FileSystem {
    */
   @Override
   public Path getTrashRoot(Path path) {
-    OFSPath ofsPath = new OFSPath(path);
+    OFSPath ofsPath = new OFSPath(path,
+        OzoneConfiguration.of(getConfSource()));
     return ofsPath.getTrashRoot();
   }
 
@@ -1250,7 +1259,8 @@ public class BasicRootedOzoneFileSystem extends 
FileSystem {
           OZONE_FS_ITERATE_BATCH_SIZE_DEFAULT);
       if (status.isDir()) {
         LOG.trace("Iterating directory: {}", pathKey);
-        OFSPath ofsPath = new OFSPath(pathKey);
+        OFSPath ofsPath = new OFSPath(pathKey,
+            OzoneConfiguration.of(getConfSource()));
         String ofsPathPrefix =
             ofsPath.getNonKeyPathNoPrefixDelim() + OZONE_URI_DELIMITER;
         if (isFSO) {
@@ -1258,7 +1268,8 @@ public class BasicRootedOzoneFileSystem extends 
FileSystem {
           fileStatuses = listStatusAdapter(path);
           for (FileStatusAdapter fileStatus : fileStatuses) {
             String keyName =
-                new OFSPath(fileStatus.getPath().toString()).getKeyName();
+                new OFSPath(fileStatus.getPath().toString(),
+                    OzoneConfiguration.of(getConfSource())).getKeyName();
             keyPathList.add(ofsPathPrefix + keyName);
           }
           if (keyPathList.size() >= batchSize) {
diff --git 
a/hadoop-ozone/ozonefs-common/src/test/java/org/apache/hadoop/fs/ozone/TestOFSPath.java
 
b/hadoop-ozone/ozonefs-common/src/test/java/org/apache/hadoop/fs/ozone/TestOFSPath.java
index bfa968c5bb..5fcd4710bc 100644
--- 
a/hadoop-ozone/ozonefs-common/src/test/java/org/apache/hadoop/fs/ozone/TestOFSPath.java
+++ 
b/hadoop-ozone/ozonefs-common/src/test/java/org/apache/hadoop/fs/ozone/TestOFSPath.java
@@ -17,6 +17,7 @@
  */
 package org.apache.hadoop.fs.ozone;
 
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
 import org.apache.hadoop.ozone.OFSPath;
 import org.junit.Assert;
 import org.junit.Test;
@@ -28,10 +29,12 @@ import java.io.IOException;
  */
 public class TestOFSPath {
 
+  private OzoneConfiguration conf = new OzoneConfiguration();
+
   @Test
   public void testParsingPathWithSpace() {
     // Two most common cases: file key and dir key inside a bucket
-    OFSPath ofsPath = new OFSPath("/volume1/bucket2/dir3/key4 space");
+    OFSPath ofsPath = new OFSPath("/volume1/bucket2/dir3/key4 space", conf);
     Assert.assertEquals("", ofsPath.getAuthority());
     Assert.assertEquals("volume1", ofsPath.getVolumeName());
     Assert.assertEquals("bucket2", ofsPath.getBucketName());
@@ -44,7 +47,7 @@ public class TestOFSPath {
   @Test
   public void testParsingVolumeBucketWithKey() {
     // Two most common cases: file key and dir key inside a bucket
-    OFSPath ofsPath = new OFSPath("/volume1/bucket2/dir3/key4");
+    OFSPath ofsPath = new OFSPath("/volume1/bucket2/dir3/key4", conf);
     Assert.assertEquals("", ofsPath.getAuthority());
     Assert.assertEquals("volume1", ofsPath.getVolumeName());
     Assert.assertEquals("bucket2", ofsPath.getBucketName());
@@ -54,7 +57,7 @@ public class TestOFSPath {
     Assert.assertEquals("/volume1/bucket2/dir3/key4", ofsPath.toString());
 
     // The ending '/' matters for key inside a bucket, indicating directory
-    ofsPath = new OFSPath("/volume1/bucket2/dir3/dir5/");
+    ofsPath = new OFSPath("/volume1/bucket2/dir3/dir5/", conf);
     Assert.assertEquals("", ofsPath.getAuthority());
     Assert.assertEquals("volume1", ofsPath.getVolumeName());
     Assert.assertEquals("bucket2", ofsPath.getBucketName());
@@ -68,7 +71,7 @@ public class TestOFSPath {
   @Test
   public void testParsingVolumeBucketOnly() {
     // Volume and bucket only
-    OFSPath ofsPath = new OFSPath("/volume1/bucket2/");
+    OFSPath ofsPath = new OFSPath("/volume1/bucket2/", conf);
     Assert.assertEquals("", ofsPath.getAuthority());
     Assert.assertEquals("volume1", ofsPath.getVolumeName());
     Assert.assertEquals("bucket2", ofsPath.getBucketName());
@@ -79,7 +82,7 @@ public class TestOFSPath {
     Assert.assertEquals("/volume1/bucket2/", ofsPath.toString());
 
     // The trailing '/' doesn't matter when parsing a bucket path
-    ofsPath = new OFSPath("/volume1/bucket2");
+    ofsPath = new OFSPath("/volume1/bucket2", conf);
     Assert.assertEquals("", ofsPath.getAuthority());
     Assert.assertEquals("volume1", ofsPath.getVolumeName());
     Assert.assertEquals("bucket2", ofsPath.getBucketName());
@@ -93,7 +96,7 @@ public class TestOFSPath {
   @Test
   public void testParsingVolumeOnly() {
     // Volume only
-    OFSPath ofsPath = new OFSPath("/volume1/");
+    OFSPath ofsPath = new OFSPath("/volume1/", conf);
     Assert.assertEquals("", ofsPath.getAuthority());
     Assert.assertEquals("volume1", ofsPath.getVolumeName());
     Assert.assertEquals("", ofsPath.getBucketName());
@@ -104,7 +107,7 @@ public class TestOFSPath {
     Assert.assertEquals("/volume1/", ofsPath.toString());
 
     // The trailing '/' doesn't matter when parsing a volume path
-    ofsPath = new OFSPath("/volume1");
+    ofsPath = new OFSPath("/volume1", conf);
     Assert.assertEquals("", ofsPath.getAuthority());
     Assert.assertEquals("volume1", ofsPath.getVolumeName());
     Assert.assertEquals("", ofsPath.getBucketName());
@@ -120,7 +123,7 @@ public class TestOFSPath {
 
   @Test
   public void testParsingEmptyInput() {
-    OFSPath ofsPath = new OFSPath("");
+    OFSPath ofsPath = new OFSPath("", conf);
     Assert.assertEquals("", ofsPath.getAuthority());
     Assert.assertEquals("", ofsPath.getVolumeName());
     Assert.assertEquals("", ofsPath.getBucketName());
@@ -133,7 +136,8 @@ public class TestOFSPath {
 
   @Test
   public void testParsingWithAuthority() {
-    OFSPath ofsPath = new OFSPath("ofs://svc1:9876/volume1/bucket2/dir3/");
+    OFSPath ofsPath = new OFSPath("ofs://svc1:9876/volume1/bucket2/dir3/",
+        conf);
     Assert.assertEquals("svc1:9876", ofsPath.getAuthority());
     Assert.assertEquals("volume1", ofsPath.getVolumeName());
     Assert.assertEquals("bucket2", ofsPath.getBucketName());
@@ -155,7 +159,7 @@ public class TestOFSPath {
       bucketName = "";  // Make javac happy
     }
     // Mount only
-    OFSPath ofsPath = new OFSPath("/tmp/");
+    OFSPath ofsPath = new OFSPath("/tmp/", conf);
     Assert.assertEquals("", ofsPath.getAuthority());
     Assert.assertEquals(
         OFSPath.OFS_MOUNT_TMP_VOLUMENAME, ofsPath.getVolumeName());
@@ -167,7 +171,7 @@ public class TestOFSPath {
     Assert.assertEquals("/tmp/", ofsPath.toString());
 
     // Mount with key
-    ofsPath = new OFSPath("/tmp/key1");
+    ofsPath = new OFSPath("/tmp/key1", conf);
     Assert.assertEquals("", ofsPath.getAuthority());
     Assert.assertEquals(
         OFSPath.OFS_MOUNT_TMP_VOLUMENAME, ofsPath.getVolumeName());
diff --git 
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/nssummary/NSSummaryAdmin.java
 
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/nssummary/NSSummaryAdmin.java
index 727be27670..14f38d71e8 100644
--- 
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/nssummary/NSSummaryAdmin.java
+++ 
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/nssummary/NSSummaryAdmin.java
@@ -87,7 +87,8 @@ public class NSSummaryAdmin extends GenericCli implements 
SubcommandWithParent {
   }
 
   public boolean isFileSystemOptimizedBucket(String path) throws IOException {
-    OFSPath ofsPath = new OFSPath(path);
+    OFSPath ofsPath = new OFSPath(path,
+        OzoneConfiguration.of(getOzoneConfig()));
 
     OzoneClient ozoneClient = 
OzoneClientFactory.getRpcClient(getOzoneConfig());
     ObjectStore objectStore = ozoneClient.getObjectStore();
@@ -111,7 +112,8 @@ public class NSSummaryAdmin extends GenericCli implements 
SubcommandWithParent {
   }
 
   public boolean isObjectStoreBucket(String path) throws IOException {
-    OFSPath ofsPath = new OFSPath(path);
+    OFSPath ofsPath = new OFSPath(path,
+        OzoneConfiguration.of(getOzoneConfig()));
 
     boolean enableFileSystemPaths = getOzoneConfig()
         .getBoolean(OMConfigKeys.OZONE_OM_ENABLE_FILESYSTEM_PATHS,
@@ -147,7 +149,8 @@ public class NSSummaryAdmin extends GenericCli implements 
SubcommandWithParent {
    * @throws IOException
    */
   public boolean bucketIsPresentInThePath(String path) throws IOException {
-    OFSPath ofsPath = new OFSPath(path);
+    OFSPath ofsPath = new OFSPath(path,
+        OzoneConfiguration.of(getOzoneConfig()));
 
     OzoneClient ozoneClient = 
OzoneClientFactory.getRpcClient(getOzoneConfig());
     ObjectStore objectStore = ozoneClient.getObjectStore();


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


Reply via email to