You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by ri...@apache.org on 2022/09/14 22:43:53 UTC

[ozone] branch master updated: HDDS-7114. CHAINED and STAND_ALONE replication-type should be removed from help message (#3672)

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 9ad75b2300 HDDS-7114. CHAINED and STAND_ALONE replication-type should be removed from help message (#3672)
9ad75b2300 is described below

commit 9ad75b2300cdf81a19d243326c99e2b5bfc6125e
Author: DaveTeng0 <10...@users.noreply.github.com>
AuthorDate: Wed Sep 14 15:43:46 2022 -0700

    HDDS-7114. CHAINED and STAND_ALONE replication-type should be removed from help message (#3672)
---
 hadoop-ozone/dist/src/main/smoketest/ec/basic.robot |  6 ++----
 .../apache/hadoop/ozone/shell/TestOzoneShellHA.java | 21 +++++++++------------
 .../hadoop/ozone/freon/FreonReplicationOptions.java |  2 +-
 .../hadoop/ozone/shell/ReplicationOptions.java      | 18 ++++++++++++++++--
 .../hadoop/ozone/shell/ShellReplicationOptions.java |  3 +--
 5 files changed, 29 insertions(+), 21 deletions(-)

diff --git a/hadoop-ozone/dist/src/main/smoketest/ec/basic.robot b/hadoop-ozone/dist/src/main/smoketest/ec/basic.robot
index dee0db6a96..93124ab6c6 100644
--- a/hadoop-ozone/dist/src/main/smoketest/ec/basic.robot
+++ b/hadoop-ozone/dist/src/main/smoketest/ec/basic.robot
@@ -74,9 +74,7 @@ Test RATIS or STAND_ALONE Type with EC Replication
                     Should contain              ${message}          not supported
     ${message} =    Execute And Ignore Error    ozone sh bucket create --replication=rs-6-3-1024k --type=STAND_ALONE /${prefix}vol1/${prefix}foo
                     Should contain              ${message}          STAND_ALONE
-                    Should contain              ${message}          rs-6-3-1024k
-                    Should contain              ${message}          not supported
+                    Should contain              ${message}          Invalid value
     ${message} =    Execute And Ignore Error    ozone sh key put --replication=rs-3-2-1024k --type=STAND_ALONE /${prefix}vol1/${prefix}foo/${prefix}bar /tmp/1mb
                     Should contain              ${message}          STAND_ALONE
-                    Should contain              ${message}          rs-3-2-1024k
-                    Should contain              ${message}          not supported
+                    Should contain              ${message}          Invalid value
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 f901e7f5a7..81a01190d1 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
@@ -388,17 +388,14 @@ public class TestOzoneShellHA {
 
   @Test
   public void testRATISTypeECReplication() {
-    for (ReplicationType type : new ReplicationType[]{
-        ReplicationType.RATIS, ReplicationType.STAND_ALONE}) {
-      String[] args = new String[]{"bucket", "create", "/vol/bucket",
-          "--type=" + type, "--replication=rs-3-2-1024k"};
-      Throwable t = assertThrows(ExecutionException.class,
-          () -> execute(ozoneShell, args));
-      Throwable c = t.getCause();
-      assertTrue(c instanceof IllegalArgumentException);
-      assertEquals("rs-3-2-1024k is not supported for " +
-              type + " replication type", c.getMessage());
-    }
+    String[] args = new String[]{"bucket", "create", "/vol/bucket",
+        "--type=" + ReplicationType.RATIS, "--replication=rs-3-2-1024k"};
+    Throwable t = assertThrows(ExecutionException.class,
+        () -> execute(ozoneShell, args));
+    Throwable c = t.getCause();
+    assertTrue(c instanceof IllegalArgumentException);
+    assertEquals("rs-3-2-1024k is not supported for " +
+            ReplicationType.RATIS + " replication type", c.getMessage());
   }
 
   /**
@@ -1009,7 +1006,7 @@ public class TestOzoneShellHA {
     }
 
     args = new String[] {"bucket", "set-replication-config", bucketPath, "-t",
-        "STAND_ALONE", "-r", "ONE"};
+        "RATIS", "-r", "THREE"};
     execute(ozoneShell, args);
     bucket = volume.getBucket("bucket0");
     try (OzoneOutputStream out = bucket.createKey("newNonECKey", 1024)) {
diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/FreonReplicationOptions.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/FreonReplicationOptions.java
index 13682df77f..d26e3f6cfb 100644
--- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/FreonReplicationOptions.java
+++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/FreonReplicationOptions.java
@@ -54,7 +54,7 @@ public class FreonReplicationOptions extends ReplicationOptions {
   @Option(names = {"--type", "--replication-type"},
       description = "Replication type. Supported types are: RATIS, EC")
   @Override
-  public void setType(ReplicationType type) {
+  public void setType(String type) {
     super.setType(type);
   }
 
diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/ReplicationOptions.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/ReplicationOptions.java
index bb4e0a7e2e..7af32dd604 100644
--- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/ReplicationOptions.java
+++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/ReplicationOptions.java
@@ -81,7 +81,21 @@ public abstract class ReplicationOptions {
   }
 
   // Option is defined in subclasses
-  public void setType(ReplicationType type) {
-    this.type = type;
+  public void setType(String type) {
+    try {
+      ReplicationType replicationType = ReplicationType.valueOf(type);
+      if (replicationType == ReplicationType.CHAINED
+              || replicationType == ReplicationType.STAND_ALONE) {
+        throw new IllegalArgumentException(
+                String.format("Unsupported replication type %s",
+                        replicationType.name()));
+      }
+      this.type = replicationType;
+    } catch (IllegalArgumentException ex) {
+      throw new IllegalArgumentException(
+              String.format("Invalid value '%s' for option '--type'. %s." +
+                      " Supported values are: RATIS, EC.",
+                      type, ex.getMessage()));
+    }
   }
 }
diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/ShellReplicationOptions.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/ShellReplicationOptions.java
index 3ee20c8b39..c905bd8885 100644
--- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/ShellReplicationOptions.java
+++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/ShellReplicationOptions.java
@@ -17,7 +17,6 @@
  */
 package org.apache.hadoop.ozone.shell;
 
-import org.apache.hadoop.hdds.client.ReplicationType;
 import picocli.CommandLine.Option;
 
 /**
@@ -28,7 +27,7 @@ public class ShellReplicationOptions extends ReplicationOptions {
   @Option(names = {"-t", "--type", "--replication-type"},
       description = "Replication type. Supported types are: RATIS, EC")
   @Override
-  public void setType(ReplicationType type) {
+  public void setType(String type) {
     super.setType(type);
   }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@ozone.apache.org
For additional commands, e-mail: commits-help@ozone.apache.org