aryangupta1998 commented on code in PR #8559:
URL: https://github.com/apache/ozone/pull/8559#discussion_r2132063819


##########
hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/container/CreateSubcommand.java:
##########
@@ -39,9 +44,18 @@ public class CreateSubcommand extends ScmSubcommand {
       names = { "-o", "--owner"})
   private String owner;
 
+  @CommandLine.Mixin
+  private ShellReplicationOptions containerReplicationOptions;
+
   @Override
   public void execute(ScmClient scmClient) throws IOException {
-    ContainerWithPipeline container = scmClient.createContainer(owner);
+    ReplicationConfig replicationConfig = 
containerReplicationOptions.fromParamsOrConfig(new OzoneConfiguration());
+    if (replicationConfig == null) {
+      // if replication options not provided via command then by default 
STAND_ALONE container will be created.
+      replicationConfig = 
ReplicationConfig.fromProtoTypeAndFactor(HddsProtos.ReplicationType.STAND_ALONE,
 
+          HddsProtos.ReplicationFactor.ONE);
+    }
+    ContainerWithPipeline container = 
scmClient.createContainer(replicationConfig, owner);
     System.out.printf("Container %s is created.%n",
         container.getContainerInfo().getContainerID());

Review Comment:
   ```suggestion
       System.out.printf("Container %s is created with replication config 
%s.%n",
           container.getContainerInfo().getContainerID(), replicationConfig);
   ```



##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/scm/protocolPB/StorageContainerLocationProtocolClientSideTranslatorPB.java:
##########
@@ -222,13 +223,33 @@ private ScmContainerLocationResponse submitRpcRequest(
   public ContainerWithPipeline allocateContainer(
       HddsProtos.ReplicationType type, HddsProtos.ReplicationFactor factor,
       String owner) throws IOException {
+    ReplicationConfig replicationConfig =
+        ReplicationConfig.fromProtoTypeAndFactor(type, factor);
+    return allocateContainer(replicationConfig, owner);
+  }
 
-    ContainerRequestProto request = ContainerRequestProto.newBuilder()
-        .setTraceID(TracingUtil.exportCurrentSpan())
-        .setReplicationFactor(factor)
-        .setReplicationType(type)
-        .setOwner(owner)
-        .build();
+  @Override
+  public ContainerWithPipeline allocateContainer(
+      ReplicationConfig replicationConfig, String owner) throws IOException {
+
+    ContainerRequestProto request;
+    if (replicationConfig.getReplicationType() == 
HddsProtos.ReplicationType.EC) {
+      HddsProtos.ECReplicationConfig ecProto = ((ECReplicationConfig) 
replicationConfig).toProto();
+      request = ContainerRequestProto.newBuilder()
+          .setTraceID(TracingUtil.exportCurrentSpan())
+          .setEcReplicationConfig(ecProto)
+          .setReplicationFactor(ReplicationFactor.valueOf(1))// Set for 
backward compatibility, ignored for EC.

Review Comment:
   ```suggestion
             .setReplicationFactor(ReplicationFactor.ONE)
   ```



##########
hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/container/CreateSubcommand.java:
##########
@@ -39,9 +44,18 @@ public class CreateSubcommand extends ScmSubcommand {
       names = { "-o", "--owner"})
   private String owner;
 
+  @CommandLine.Mixin
+  private ShellReplicationOptions containerReplicationOptions;
+
   @Override
   public void execute(ScmClient scmClient) throws IOException {
-    ContainerWithPipeline container = scmClient.createContainer(owner);
+    ReplicationConfig replicationConfig = 
containerReplicationOptions.fromParamsOrConfig(new OzoneConfiguration());
+    if (replicationConfig == null) {
+      // if replication options not provided via command then by default 
STAND_ALONE container will be created.

Review Comment:
   ```suggestion
         // if replication options not provided via command then by default 
STAND_ALONE container will be created.
         LOG.warn("No replication config provided. Defaulting to STAND_ALONE 
with replication factor ONE.");
   ```



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