elek commented on a change in pull request #2136:
URL: https://github.com/apache/ozone/pull/2136#discussion_r620235297



##########
File path: 
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/RatisReplicationConfig.java
##########
@@ -35,6 +35,16 @@ public RatisReplicationConfig(ReplicationFactor 
replicationFactor) {
     this.replicationFactor = replicationFactor;
   }
 
+  public RatisReplicationConfig(String factorString) {
+    ReplicationFactor factor = null;
+    try {
+      factor = ReplicationFactor.valueOf(Integer.parseInt(factorString));
+    } catch (NumberFormatException ex) {
+      factor = ReplicationFactor.valueOf(factorString);

Review comment:
       > Should we throw an exception explicitly here?
   
   Currently, `IllegalArgumentException` is thrown with the message:
   
   ```
   Exception in thread "main" java.lang.IllegalArgumentException: No enum 
constant org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor.asd
   ```
   I think the type (`IllegalArgumentException`) is fine, but I modified the 
error message with throwing explicit exception:
   
   ```
   Exception in thread "main" java.lang.IllegalArgumentException: Invalid 
RatisReplicationFactor 'xxx'. Please use ONE or THREE
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



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

Reply via email to