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 d3e2e59c1c HDDS-10319. Also consider bucket layout deciding whether to 
normalize path for listKeys (#6195)
d3e2e59c1c is described below

commit d3e2e59c1c78866165819fcc6774631316f2e586
Author: Devesh Kumar Singh <[email protected]>
AuthorDate: Fri Feb 9 23:33:20 2024 +0530

    HDDS-10319. Also consider bucket layout deciding whether to normalize path 
for listKeys (#6195)
---
 .../hadoop/ozone/freon/TestOmBucketReadWriteKeyOps.java     | 13 ++++++++-----
 .../java/org/apache/hadoop/ozone/om/KeyManagerImpl.java     | 10 +++++++---
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/freon/TestOmBucketReadWriteKeyOps.java
 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/freon/TestOmBucketReadWriteKeyOps.java
index b74022b83e..3c7a04071b 100644
--- 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/freon/TestOmBucketReadWriteKeyOps.java
+++ 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/freon/TestOmBucketReadWriteKeyOps.java
@@ -34,7 +34,8 @@ import org.apache.ozone.test.GenericTestUtils;
 import org.apache.ratis.server.RaftServer;
 import org.apache.ratis.server.raftlog.RaftLog;
 import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.event.Level;
@@ -88,8 +89,9 @@ public class TestOmBucketReadWriteKeyOps {
    *
    * @throws IOException
    */
-  private void startCluster() throws Exception {
+  private void startCluster(boolean fsPathsEnabled) throws Exception {
     conf = getOzoneConfiguration();
+    conf.setBoolean(OMConfigKeys.OZONE_OM_ENABLE_FILESYSTEM_PATHS, 
fsPathsEnabled);
     conf.set(OMConfigKeys.OZONE_DEFAULT_BUCKET_LAYOUT,
         BucketLayout.OBJECT_STORE.name());
     cluster = MiniOzoneCluster.newBuilder(conf).setNumDatanodes(5).build();
@@ -104,10 +106,11 @@ public class TestOmBucketReadWriteKeyOps {
     return new OzoneConfiguration();
   }
 
-  @Test
-  public void testOmBucketReadWriteKeyOps() throws Exception {
+  @ParameterizedTest(name = "Filesystem Paths Enabled: {0}")
+  @ValueSource(booleans = {false, true})
+  public void testOmBucketReadWriteKeyOps(boolean fsPathsEnabled) throws 
Exception {
     try {
-      startCluster();
+      startCluster(fsPathsEnabled);
       FileOutputStream out = FileUtils.openOutputStream(new File(path,
           "conf"));
       cluster.getConf().writeXml(out);
diff --git 
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java
 
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java
index a84fdaf1a6..d932ed1eff 100644
--- 
a/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java
+++ 
b/hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java
@@ -609,13 +609,17 @@ public class KeyManagerImpl implements KeyManager {
       int maxKeys) throws IOException {
     Preconditions.checkNotNull(volumeName);
     Preconditions.checkNotNull(bucketName);
-
+    OmBucketInfo omBucketInfo = getBucketInfo(volumeName, bucketName);
+    if (omBucketInfo == null) {
+      throw new OMException("Bucket " + bucketName + " not found.",
+          ResultCodes.BUCKET_NOT_FOUND);
+    }
+    BucketLayout bucketLayout = omBucketInfo.getBucketLayout();
     // We don't take a lock in this path, since we walk the
     // underlying table using an iterator. That automatically creates a
     // snapshot of the data, so we don't need these locks at a higher level
     // when we iterate.
-
-    if (enableFileSystemPaths) {
+    if (bucketLayout.shouldNormalizePaths(enableFileSystemPaths)) {
       startKey = OmUtils.normalizeKey(startKey, true);
       keyPrefix = OmUtils.normalizeKey(keyPrefix, true);
     }


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

Reply via email to