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 7981060f1e HDDS-6827. Need proper error message when "RATIS"
replication-type is passed with EC codec (#3491)
7981060f1e is described below
commit 7981060f1e4f0c380fe0fe28faec60e72bd97dd1
Author: Kaijie Chen <[email protected]>
AuthorDate: Thu Jun 9 03:04:02 2022 +0800
HDDS-6827. Need proper error message when "RATIS" replication-type is
passed with EC codec (#3491)
---
.../apache/hadoop/hdds/client/ReplicationConfig.java | 7 ++++++-
hadoop-ozone/dist/src/main/smoketest/ec/basic.robot | 20 +++++++++++++++++++-
.../apache/hadoop/ozone/shell/TestOzoneShellHA.java | 18 ++++++++++++++++++
3 files changed, 43 insertions(+), 2 deletions(-)
diff --git
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/ReplicationConfig.java
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/ReplicationConfig.java
index c9a12a64e6..e3e69b44f3 100644
---
a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/ReplicationConfig.java
+++
b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/ReplicationConfig.java
@@ -182,7 +182,12 @@ public interface ReplicationConfig {
try {
factor = ReplicationFactor.valueOf(Integer.parseInt(replication));
} catch (NumberFormatException ex) {
- factor = ReplicationFactor.valueOf(replication);
+ try {
+ factor = ReplicationFactor.valueOf(replication);
+ } catch (IllegalArgumentException e) {
+ throw new IllegalArgumentException(replication +
+ " is not supported for " + type + " replication type", e);
+ }
}
replicationConfig = fromTypeAndFactor(type, factor);
break;
diff --git a/hadoop-ozone/dist/src/main/smoketest/ec/basic.robot
b/hadoop-ozone/dist/src/main/smoketest/ec/basic.robot
index 751211d25d..dee0db6a96 100644
--- a/hadoop-ozone/dist/src/main/smoketest/ec/basic.robot
+++ b/hadoop-ozone/dist/src/main/smoketest/ec/basic.robot
@@ -61,4 +61,22 @@ Test Ratis Key EC Bucket
Test EC Key Ratis Bucket
Execute ozone sh key put
--replication=rs-3-2-1024k --type=EC
/${prefix}vol1/${prefix}ratis/${prefix}1mbEC /tmp/1mb
Key Should Match Local File
/${prefix}vol1/${prefix}ratis/${prefix}1mbEC /tmp/1mb
- Verify Key EC Replication Config
/${prefix}vol1/${prefix}ratis/${prefix}1mbEC RS 3 2 1048576
\ No newline at end of file
+ Verify Key EC Replication Config
/${prefix}vol1/${prefix}ratis/${prefix}1mbEC RS 3 2 1048576
+
+Test RATIS or STAND_ALONE Type with EC Replication
+ ${message} = Execute And Ignore Error ozone sh bucket create
--replication=rs-3-2-1024k --type=RATIS /${prefix}vol1/${prefix}foo
+ Should contain ${message} RATIS
+ Should contain ${message}
rs-3-2-1024k
+ Should contain ${message} not
supported
+ ${message} = Execute And Ignore Error ozone sh key put
--replication=rs-6-3-1024k --type=RATIS
/${prefix}vol1/${prefix}foo/${prefix}bar /tmp/1mb
+ Should contain ${message} RATIS
+ Should contain ${message}
rs-6-3-1024k
+ 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
+ ${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
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 10df7a8d5b..f901e7f5a7 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
@@ -35,6 +35,7 @@ import org.apache.hadoop.fs.FileUtil;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdds.cli.GenericCli;
import org.apache.hadoop.hdds.cli.OzoneAdmin;
+import org.apache.hadoop.hdds.client.ReplicationType;
import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
import org.apache.hadoop.ozone.OFSPath;
import org.apache.hadoop.fs.ozone.OzoneFsShell;
@@ -72,6 +73,8 @@ import org.junit.Assert;
import static org.apache.hadoop.ozone.OzoneConsts.OZONE_URI_DELIMITER;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThrows;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -383,6 +386,21 @@ public class TestOzoneShellHA {
return new Gson().fromJson(out.toString(DEFAULT_ENCODING),
ArrayList.class);
}
+ @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());
+ }
+ }
+
/**
* Tests ozone sh command URI parsing with volume and bucket create commands.
*/
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]