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

ritesh 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 0a0cffcc6e HDDS-11964. Allow ozone sh bucket create to take obs and 
fso as options. (#7599)
0a0cffcc6e is described below

commit 0a0cffcc6e49e4f642f88b72cdeaefd6ae467989
Author: Ritesh H Shukla <[email protected]>
AuthorDate: Thu Dec 19 22:00:03 2024 -0800

    HDDS-11964. Allow ozone sh bucket create to take obs and fso as options. 
(#7599)
---
 .../dist/src/main/smoketest/createmrenv.robot      |  2 +-
 .../src/main/smoketest/debug/ozone-debug-ldb.robot |  2 +-
 .../ozone/shell/bucket/CreateBucketHandler.java    | 33 +++++++++++++++++-----
 3 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/hadoop-ozone/dist/src/main/smoketest/createmrenv.robot 
b/hadoop-ozone/dist/src/main/smoketest/createmrenv.robot
index 7fcf3619ef..2d68be00e6 100644
--- a/hadoop-ozone/dist/src/main/smoketest/createmrenv.robot
+++ b/hadoop-ozone/dist/src/main/smoketest/createmrenv.robot
@@ -32,7 +32,7 @@ Create volume
     ${result} =     Execute             ozone sh volume create /${volume} 
--user hadoop --space-quota 100TB --namespace-quota 100
                     Should not contain  ${result}       Failed
 Create bucket
-                    Execute             ozone sh bucket create 
/${volume}/${bucket} --space-quota 1TB --layout FILE_SYSTEM_OPTIMIZED
+                    Execute             ozone sh bucket create 
/${volume}/${bucket} --space-quota 1TB --layout fso
 
 *** Test Cases ***
 Create test volume, bucket and key
diff --git a/hadoop-ozone/dist/src/main/smoketest/debug/ozone-debug-ldb.robot 
b/hadoop-ozone/dist/src/main/smoketest/debug/ozone-debug-ldb.robot
index 0fa43dee6c..4380a3cf94 100644
--- a/hadoop-ozone/dist/src/main/smoketest/debug/ozone-debug-ldb.robot
+++ b/hadoop-ozone/dist/src/main/smoketest/debug/ozone-debug-ldb.robot
@@ -31,7 +31,7 @@ ${TESTFILE}         testfile
 Write keys
     Run Keyword if      '${SECURITY_ENABLED}' == 'true'     Kinit test user    
 testuser     testuser.keytab
     Execute             ozone sh volume create ${VOLUME}
-    Execute             ozone sh bucket create ${VOLUME}/${BUCKET} -l 
OBJECT_STORE
+    Execute             ozone sh bucket create ${VOLUME}/${BUCKET} -l obs
     Execute             dd if=/dev/urandom of=${TEMP_DIR}/${TESTFILE}1 bs=100 
count=10
     Execute             ozone sh key put ${VOLUME}/${BUCKET}/${TESTFILE}1 
${TEMP_DIR}/${TESTFILE}1
     Execute             dd if=/dev/urandom of=${TEMP_DIR}/${TESTFILE}2 bs=100 
count=15
diff --git 
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/bucket/CreateBucketHandler.java
 
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/bucket/CreateBucketHandler.java
index 277c5afff2..02f5e80f6e 100644
--- 
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/bucket/CreateBucketHandler.java
+++ 
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/bucket/CreateBucketHandler.java
@@ -59,11 +59,32 @@ public class CreateBucketHandler extends BucketHandler {
               " user if not specified")
   private String ownerName;
 
-  enum AllowedBucketLayouts { FILE_SYSTEM_OPTIMIZED, OBJECT_STORE, LEGACY }
+  private static class LayoutConverter implements 
CommandLine.ITypeConverter<BucketLayout> {
+    @Override
+    public BucketLayout convert(String value) {
+      if (value == null) {
+        return null;
+      }
+      switch (value) {
+      case "fso":
+        return BucketLayout.FILE_SYSTEM_OPTIMIZED;
+      case "obs":
+        return BucketLayout.OBJECT_STORE;
+      default:
+        for (BucketLayout candidate : BucketLayout.values()) {
+          if (candidate.name().equalsIgnoreCase(value)) {
+            return candidate;
+          }
+        }
+        throw new IllegalArgumentException("Unknown bucket layout: " + value);
+      }
+    }
+  }
 
-  @Option(names = { "--layout", "-l" },
-      description = "Allowed Bucket Layouts: ${COMPLETION-CANDIDATES}")
-  private AllowedBucketLayouts allowedBucketLayout;
+  @Option(names = { "--layout", "-l" }, converter = LayoutConverter.class,
+          description = "Allowed Bucket Layouts: fso (for file system 
optimized buckets FILE_SYSTEM_OPTIMIZED), " +
+                  "obs (for object store optimized OBJECT_STORE) and legacy 
(LEGACY is Deprecated)")
+  private BucketLayout allowedBucketLayout;
 
   @CommandLine.Mixin
   private ShellReplicationOptions replication;
@@ -86,9 +107,7 @@ public class CreateBucketHandler extends BucketHandler {
         new BucketArgs.Builder().setStorageType(StorageType.DEFAULT)
             .setVersioning(false).setOwner(ownerName);
     if (allowedBucketLayout != null) {
-      BucketLayout bucketLayout =
-          BucketLayout.fromString(allowedBucketLayout.toString());
-      bb.setBucketLayout(bucketLayout);
+      bb.setBucketLayout(allowedBucketLayout);
     }
     // TODO: New Client talking to old server, will it create a LEGACY bucket?
 


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

Reply via email to