fapifta commented on a change in pull request #2990:
URL: https://github.com/apache/ozone/pull/2990#discussion_r791187701



##########
File path: 
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/keys/PutKeyHandler.java
##########
@@ -83,8 +87,20 @@ protected void execute(OzoneClient client, OzoneAddress 
address)
       }
     }
 
-    ReplicationConfig replicationConfig =
-        ReplicationConfig.parse(replicationType, replication, getConf());
+    String clientConfiguredDefaultType = getConf().get(OZONE_REPLICATION_TYPE);
+    if (replicationType == null && clientConfiguredDefaultType != null) {

Review comment:
       Isn't this two condition remained here accidentally? Maybe I miss 
something, but if I am correct, we do the same in this two ifs as inside the 
method OzoneClientUtils#validateAndGetClientReplicationConfig(), which we call 
from here.
   
   

##########
File path: 
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/keys/PutKeyHandler.java
##########
@@ -83,8 +87,20 @@ protected void execute(OzoneClient client, OzoneAddress 
address)
       }
     }
 
-    ReplicationConfig replicationConfig =
-        ReplicationConfig.parse(replicationType, replication, getConf());
+    String clientConfiguredDefaultType = getConf().get(OZONE_REPLICATION_TYPE);
+    if (replicationType == null && clientConfiguredDefaultType != null) {

Review comment:
       Aren't this two condition remained here accidentally? Maybe I miss 
something, but if I am correct, we do the same in this two ifs as inside the 
method OzoneClientUtils#validateAndGetClientReplicationConfig(), which we call 
from here.
   
   

##########
File path: 
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHA.java
##########
@@ -910,6 +910,27 @@ public void testCreateBucketWithECReplicationConfig() 
throws Exception {
     }
   }
 
+  @Test
+  public void testPutKeyOnBucketWithECReplicationConfig() throws Exception {
+    final String volumeName = "volume1000";
+    getVolume(volumeName);
+    String[] args =
+        new String[] {"bucket", "create", "/volume1000/bucket0", "-t", "EC",
+            "-r", "rs-3-2-1024k"};
+    execute(ozoneShell, args);
+
+    args = new String[] {"key", "put", "/volume1000/bucket0/newECKey1",
+        testFilePathString};
+    execute(ozoneShell, args);
+    OzoneVolume volume =
+        cluster.getClient().getObjectStore().getVolume(volumeName);
+    OzoneBucket bucket = volume.getBucket("bucket0");
+    try (OzoneOutputStream out = bucket.createKey("newECKey1", 1024)) {

Review comment:
       Shouldn't we open the key we have created by executing the shell command 
to run putkey earlier instead of creating it? (Also that would mean we get an 
OzoneInputStream here and we can check its type.)

##########
File path: 
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/shell/TestOzoneShellHA.java
##########
@@ -910,6 +910,27 @@ public void testCreateBucketWithECReplicationConfig() 
throws Exception {
     }
   }
 
+  @Test
+  public void testPutKeyOnBucketWithECReplicationConfig() throws Exception {
+    final String volumeName = "volume1000";
+    getVolume(volumeName);
+    String[] args =
+        new String[] {"bucket", "create", "/volume1000/bucket0", "-t", "EC",
+            "-r", "rs-3-2-1024k"};
+    execute(ozoneShell, args);
+
+    args = new String[] {"key", "put", "/volume1000/bucket0/newECKey1",
+        testFilePathString};
+    execute(ozoneShell, args);
+    OzoneVolume volume =
+        cluster.getClient().getObjectStore().getVolume(volumeName);
+    OzoneBucket bucket = volume.getBucket("bucket0");
+    try (OzoneOutputStream out = bucket.createKey("newECKey1", 1024)) {
+      Assert.assertTrue(out.getOutputStream().getClass().getName()

Review comment:
       nit: we can use asserEquals here on the class instances




-- 
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.

To unsubscribe, e-mail: [email protected]

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