This is an automated email from the ASF dual-hosted git repository.

amaliujia 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 d1047a57de1 HDDS-17809. Add ReplicationType to ContainerStateMachine. 
(#12075)
d1047a57de1 is described below

commit d1047a57de1e1ccf8921c27e4f68a27b84a54aeb
Author: Tsz-Wo Nicholas Sze <[email protected]>
AuthorDate: Thu Nov 19 11:00:35 2026 -0800

    HDDS-17809. Add ReplicationType to ContainerStateMachine. (#12075)
---
 .../common/statemachine/DatanodeStateMachine.java  |   2 +-
 .../ClosePipelineCommandHandler.java               |  51 +-------
 .../CreatePipelineCommandHandler.java              |  95 ++++++++-------
 .../common/transport/server/XceiverServerSpi.java  |   4 +-
 .../server/ratis/ContainerStateMachine.java        |  10 ++
 .../transport/server/ratis/XceiverServerRatis.java |  61 ++++++++--
 .../TestClosePipelineCommandHandler.java           |  56 ++-------
 .../TestCreatePipelineCommandHandler.java          |  19 ++-
 .../server/ratis/ContainerStateMachineTests.java   |   5 +-
 .../TestXceiverServerRatisReplicationType.java     | 135 +++++++++++++++++++++
 .../hadoop/ozone/container/OzoneTestHelper.java    |   3 +-
 11 files changed, 287 insertions(+), 154 deletions(-)

diff --git 
a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/DatanodeStateMachine.java
 
b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/DatanodeStateMachine.java
index 7ccf49db010..f08705b9ad8 100644
--- 
a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/DatanodeStateMachine.java
+++ 
b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/DatanodeStateMachine.java
@@ -258,7 +258,7 @@ public DatanodeStateMachine(HddsDatanodeService 
hddsDatanodeService,
         .addHandler(new DeleteContainerCommandHandler(
             dnConf.getContainerDeleteThreads(), clock,
             dnConf.getCommandQueueLimit(), threadNamePrefix))
-        .addHandler(new ClosePipelineCommandHandler(conf,
+        .addHandler(new ClosePipelineCommandHandler(
             closePipelineCommandExecutorService))
         .addHandler(new CreatePipelineCommandHandler(conf,
             createPipelineCommandExecutorService))
diff --git 
a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/ClosePipelineCommandHandler.java
 
b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/ClosePipelineCommandHandler.java
index c6b79ef5f4e..c6e613f2643 100644
--- 
a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/ClosePipelineCommandHandler.java
+++ 
b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/ClosePipelineCommandHandler.java
@@ -18,7 +18,6 @@
 package org.apache.hadoop.ozone.container.common.statemachine.commandhandler;
 
 import java.io.IOException;
-import java.util.Collection;
 import java.util.Set;
 import java.util.UUID;
 import java.util.concurrent.CompletableFuture;
@@ -27,11 +26,8 @@
 import java.util.concurrent.RejectedExecutionException;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicLong;
-import java.util.function.BiFunction;
-import org.apache.hadoop.hdds.conf.ConfigurationSource;
 import org.apache.hadoop.hdds.protocol.DatanodeDetails;
 import 
org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMCommandProto;
-import org.apache.hadoop.hdds.ratis.RatisHelper;
 import org.apache.hadoop.hdds.scm.client.HddsClientUtils;
 import org.apache.hadoop.hdds.scm.pipeline.PipelineID;
 import org.apache.hadoop.metrics2.lib.MetricsRegistry;
@@ -44,10 +40,6 @@
 import org.apache.hadoop.ozone.protocol.commands.ClosePipelineCommand;
 import org.apache.hadoop.ozone.protocol.commands.SCMCommand;
 import org.apache.hadoop.util.Time;
-import org.apache.ratis.client.RaftClient;
-import org.apache.ratis.grpc.GrpcTlsConfig;
-import org.apache.ratis.protocol.RaftGroupId;
-import org.apache.ratis.protocol.RaftPeer;
 import org.apache.ratis.protocol.exceptions.GroupMismatchException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -63,25 +55,13 @@ public class ClosePipelineCommandHandler implements 
CommandHandler {
   private final AtomicLong invocationCount = new AtomicLong(0);
   private final AtomicInteger queuedCount = new AtomicInteger(0);
   private final Executor executor;
-  private final BiFunction<RaftPeer, GrpcTlsConfig, RaftClient> newRaftClient;
   private final MutableRate opsLatencyMs;
   private final Set<UUID> pipelinesInProgress;
 
   /**
    * Constructs a closePipelineCommand handler.
    */
-  public ClosePipelineCommandHandler(ConfigurationSource conf,
-                                     Executor executor) {
-    this(RatisHelper.newRaftClientNoRetry(conf), executor);
-  }
-
-  /**
-   * Constructs a closePipelineCommand handler.
-   */
-  public ClosePipelineCommandHandler(
-      BiFunction<RaftPeer, GrpcTlsConfig, RaftClient> newRaftClient,
-      Executor executor) {
-    this.newRaftClient = newRaftClient;
+  public ClosePipelineCommandHandler(Executor executor) {
     this.executor = executor;
     MetricsRegistry registry = new MetricsRegistry(
         ClosePipelineCommandHandler.class.getSimpleName());
@@ -131,34 +111,7 @@ public void handle(SCMCommand<?> command, OzoneContainer 
ozoneContainer,
           XceiverServerSpi server = ozoneContainer.getWriteChannel();
           if (server.isExist(pipelineID)) {
             if (server instanceof XceiverServerRatis) {
-              // TODO: Refactor Ratis logic to XceiverServerRatis
-              // Propagate the group remove to the other Raft peers in the 
pipeline
-              XceiverServerRatis ratisServer = (XceiverServerRatis) server;
-              final RaftGroupId raftGroupId = pipelineID.getGroupId();
-              final boolean shouldDeleteRatisLogDirectory = 
ratisServer.getShouldDeleteRatisLogDirectory();
-              // This might throw GroupMismatchException if the Ratis group 
has been closed by other datanodes
-              final Collection<RaftPeer> peers = 
ratisServer.getRaftPeers(raftGroupId);
-              // Try to send remove group for the other datanodes first, 
ignoring GroupMismatchException
-              // if the Ratis group has been closed in the other datanodes
-              peers.stream()
-                  .filter(peer -> 
!peer.getId().equals(ratisServer.getServer().getId()))
-                  .forEach(peer -> {
-                    try (RaftClient client = newRaftClient.apply(peer, 
ozoneContainer.getTlsClientConfig())) {
-                      client.getGroupManagementApi(peer.getId())
-                          .remove(raftGroupId, shouldDeleteRatisLogDirectory, 
!shouldDeleteRatisLogDirectory);
-                    } catch (GroupMismatchException ae) {
-                      // ignore silently since this means that the group has 
been closed by earlier close pipeline
-                      // command in another datanode
-                      LOG.debug("Failed to remove group {} for pipeline {} on 
peer {} since the group has " +
-                          "been removed by earlier close pipeline command 
handled in another datanode", raftGroupId,
-                          pipelineID, peer);
-                    } catch (IOException ioe) {
-                      LOG.warn("Failed to remove group {} of pipeline {} on 
peer {}",
-                          raftGroupId, pipelineID, peer, ioe);
-                    }
-                  });
-              // Remove group locally, might throw GroupMismatchException as 
well.
-              ratisServer.removeGroup(raftGroupId);
+              ((XceiverServerRatis) 
server).removeGroup(pipelineID.getGroupId(), 
ozoneContainer.getTlsClientConfig());
             }
             LOG.info("Close Pipeline {} command on datanode {}.", pipelineID, 
dn);
           } else {
diff --git 
a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/CreatePipelineCommandHandler.java
 
b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/CreatePipelineCommandHandler.java
index 3e30f599032..354da2ac69e 100644
--- 
a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/CreatePipelineCommandHandler.java
+++ 
b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/CreatePipelineCommandHandler.java
@@ -30,6 +30,7 @@
 import java.util.function.BiFunction;
 import org.apache.hadoop.hdds.conf.ConfigurationSource;
 import org.apache.hadoop.hdds.protocol.DatanodeDetails;
+import org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationType;
 import 
org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.SCMCommandProto;
 import org.apache.hadoop.hdds.ratis.RatisHelper;
 import org.apache.hadoop.hdds.scm.pipeline.PipelineID;
@@ -109,50 +110,12 @@ public void handle(SCMCommand<?> command, OzoneContainer 
ozoneContainer,
     
     try {
       queuedCount.incrementAndGet();
-      CompletableFuture.runAsync(() -> {
-        invocationCount.incrementAndGet();
-        final long startTime = Time.monotonicNow();
-        final DatanodeDetails dn = context.getParent().getDatanodeDetails();
-        final List<DatanodeDetails> peers = createCommand.getNodeList();
-        final List<Integer> priorityList = createCommand.getPriorityList();
-
-        try {
-          XceiverServerSpi server = ozoneContainer.getWriteChannel();
-          if (!server.isExist(pipelineID)) {
-            final RaftGroup group = 
RatisHelper.newRaftGroup(pipelineID.getGroupId(), peers, priorityList);
-            server.addGroup(pipelineID, peers, priorityList);
-            peers.stream().filter(d -> !d.getID().equals(dn.getID()))
-                .forEach(d -> {
-                  final RaftPeer peer = RatisHelper.toRaftPeer(d);
-                  try (RaftClient client = newRaftClient.apply(peer,
-                      ozoneContainer.getTlsClientConfig())) {
-                    client.getGroupManagementApi(peer.getId()).add(group);
-                  } catch (AlreadyExistsException ae) {
-                    // do not log
-                  } catch (IOException ioe) {
-                    LOG.warn("Add group failed for {}", d, ioe);
-                  }
-                });
-            LOG.info("Created Pipeline {} {} {}.",
-                createCommand.getReplicationType(), createCommand.getFactor(),
-                pipelineID);
-          }
-        } catch (IOException e) {
-          // The server.addGroup may exec after a getGroupManagementApi call
-          // from another peer, so we may got an AlreadyExistsException.
-          if (!(e.getCause() instanceof AlreadyExistsException)) {
-            LOG.error("Can't create pipeline {} {} {}",
-                createCommand.getReplicationType(),
-                createCommand.getFactor(), pipelineID, e);
-          }
-        } finally {
-          long endTime = Time.monotonicNow();
-          this.opsLatencyMs.add(endTime - startTime);
-        }
-      }, executor).whenComplete((v, e) -> {
-        queuedCount.decrementAndGet();
-        pipelinesInProgress.remove(pipelineUUID);
-      });
+      CompletableFuture.runAsync(
+          () -> addGroup(createCommand, 
context.getParent().getDatanodeDetails(), ozoneContainer), executor)
+          .whenComplete((v, e) -> {
+            queuedCount.decrementAndGet();
+            pipelinesInProgress.remove(pipelineUUID);
+          });
     } catch (RejectedExecutionException ex) {
       queuedCount.decrementAndGet();
       pipelinesInProgress.remove(pipelineUUID);
@@ -161,6 +124,50 @@ public void handle(SCMCommand<?> command, OzoneContainer 
ozoneContainer,
     }
   }
 
+  private void addGroup(CreatePipelineCommand command, DatanodeDetails dn, 
OzoneContainer container) {
+    invocationCount.incrementAndGet();
+    final long startTime = Time.monotonicNow();
+    final PipelineID pipelineID = command.getPipelineID();
+    final ReplicationType type = command.getReplicationType();
+
+    try {
+      final XceiverServerSpi server = container.getWriteChannel();
+      if (!server.isExist(pipelineID)) {
+        final List<DatanodeDetails> peers = command.getNodeList();
+        final List<Integer> priorityList = command.getPriorityList();
+        final RaftGroup group = 
RatisHelper.newRaftGroup(pipelineID.getGroupId(), peers, priorityList);
+        server.addGroup(pipelineID, type, peers, priorityList);
+        // For RATIS  , fan-out to addGroup for the other datanodes (faster)
+        // For CHAINED, fan-out not working since it needs ReplicationType 
from CreatePipelineCommand
+        if (type == ReplicationType.RATIS) {
+          peers.stream()
+              .filter(d -> !d.getID().equals(dn.getID()))
+              .map(RatisHelper::toRaftPeer)
+              .forEach(peer -> sendAddGroup(peer, group, 
container.getTlsClientConfig()));
+        }
+        LOG.info("Created {}/{} {}: {}", type, command.getFactor(), 
pipelineID, group);
+      }
+    } catch (IOException e) {
+      // Ignore AlreadyExistsException since server.addGroup may be called 
from another peer
+      if (!(e.getCause() instanceof AlreadyExistsException)) {
+        LOG.error("Failed to create {}/{} {}", type, command.getFactor(), 
pipelineID, e);
+      }
+    } finally {
+      long endTime = Time.monotonicNow();
+      this.opsLatencyMs.add(endTime - startTime);
+    }
+  }
+
+  private void sendAddGroup(RaftPeer peer, RaftGroup group, GrpcTlsConfig 
tlsConfig) {
+    try (RaftClient client = newRaftClient.apply(peer, tlsConfig)) {
+      client.getGroupManagementApi(peer.getId()).add(group);
+    } catch (AlreadyExistsException ae) {
+      // do not log
+    } catch (IOException ioe) {
+      LOG.warn("Add group failed for datanode {}", peer, ioe);
+    }
+  }
+
   /**
    * Returns the command type that this command handler handles.
    *
diff --git 
a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/XceiverServerSpi.java
 
b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/XceiverServerSpi.java
index 84d1cfb148e..06ed3f6e4bb 100644
--- 
a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/XceiverServerSpi.java
+++ 
b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/XceiverServerSpi.java
@@ -21,6 +21,7 @@
 import java.util.List;
 import org.apache.hadoop.hdds.protocol.DatanodeDetails;
 import 
org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandRequestProto;
+import org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationType;
 import 
org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.MetadataStorageReportProto;
 import 
org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.PipelineReport;
 import org.apache.hadoop.hdds.scm.pipeline.PipelineID;
@@ -50,9 +51,10 @@ public interface XceiverServerSpi {
   boolean isExist(PipelineID pipelineId);
 
   /**
-   * Join a new pipeline with priority.
+   * Join a new pipeline of the given type with priority.
    */
   default void addGroup(PipelineID pipelineId,
+      ReplicationType type,
       List<DatanodeDetails> peers,
       List<Integer> priorityList) throws IOException {
   }
diff --git 
a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/ContainerStateMachine.java
 
b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/ContainerStateMachine.java
index d35916e9457..8c0dcd8305f 100644
--- 
a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/ContainerStateMachine.java
+++ 
b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/ContainerStateMachine.java
@@ -65,6 +65,7 @@
 import 
org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ReadChunkResponseProto;
 import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.Type;
 import 
org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.WriteChunkRequestProto;
+import org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationType;
 import org.apache.hadoop.hdds.ratis.ContainerCommandRequestMessage;
 import org.apache.hadoop.hdds.scm.ScmConfigKeys;
 import 
org.apache.hadoop.hdds.scm.container.common.helpers.ContainerNotOpenException;
@@ -148,6 +149,7 @@ public class ContainerStateMachine extends BaseStateMachine 
{
   private final ContainerDispatcher dispatcher;
   private final ContainerController containerController;
   private final XceiverServerRatis ratisServer;
+  private final ReplicationType replicationType;
   private final NavigableMap<Long, WriteFutures> writeChunkFutureMap;
 
   private final long writeChunkWaitMaxNs;
@@ -251,12 +253,16 @@ long getStartTime() {
 
   @SuppressWarnings("parameternumber")
   public ContainerStateMachine(HddsDatanodeService hddsDatanodeService, 
RaftGroupId gid,
+      ReplicationType replicationType,
       ContainerDispatcher dispatcher,
       ContainerController containerController,
       List<ThreadPoolExecutor> chunkExecutors,
       XceiverServerRatis ratisServer,
       ConfigurationSource conf,
       String threadNamePrefix) {
+    Preconditions.checkArgument(replicationType == ReplicationType.RATIS || 
replicationType == ReplicationType.CHAINED,
+        "Unexpected replicationType %s", replicationType);
+    this.replicationType = replicationType;
     this.datanodeService = hddsDatanodeService;
     this.dispatcher = dispatcher;
     this.containerController = containerController;
@@ -310,6 +316,10 @@ public ContainerStateMachine(HddsDatanodeService 
hddsDatanodeService, RaftGroupI
         
ScmConfigKeys.HDDS_CONTAINER_RATIS_STATEMACHINE_WRITE_WAIT_INTERVAL_NS_DEFAULT, 
TimeUnit.NANOSECONDS);
   }
 
+  ReplicationType getReplicationType() {
+    return replicationType;
+  }
+
   private void validatePeers() throws IOException {
     if (this.peersValidated.get()) {
       return;
diff --git 
a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/XceiverServerRatis.java
 
b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/XceiverServerRatis.java
index 114affc314b..efcfa6ebc96 100644
--- 
a/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/XceiverServerRatis.java
+++ 
b/hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/XceiverServerRatis.java
@@ -52,6 +52,7 @@
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
 import java.util.concurrent.atomic.AtomicLong;
+import java.util.function.BiFunction;
 import org.apache.hadoop.hdds.HddsConfigKeys;
 import org.apache.hadoop.hdds.HddsUtils;
 import org.apache.hadoop.hdds.conf.ConfigurationSource;
@@ -62,6 +63,7 @@
 import org.apache.hadoop.hdds.protocol.DatanodeDetails.Port;
 import 
org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos.ContainerCommandRequestProto;
 import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
+import org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationType;
 import 
org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ClosePipelineInfo;
 import 
org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.PipelineAction;
 import 
org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.PipelineReport;
@@ -79,6 +81,7 @@
 import org.apache.hadoop.ozone.container.common.statemachine.StateContext;
 import 
org.apache.hadoop.ozone.container.common.transport.server.XceiverServerSpi;
 import org.apache.hadoop.ozone.container.ozoneimpl.ContainerController;
+import org.apache.ratis.client.RaftClient;
 import org.apache.ratis.conf.Parameters;
 import org.apache.ratis.conf.RaftProperties;
 import org.apache.ratis.grpc.GrpcConfigKeys;
@@ -99,6 +102,7 @@
 import org.apache.ratis.protocol.RaftGroupMemberId;
 import org.apache.ratis.protocol.RaftPeer;
 import org.apache.ratis.protocol.RaftPeerId;
+import org.apache.ratis.protocol.exceptions.GroupMismatchException;
 import org.apache.ratis.protocol.exceptions.NotLeaderException;
 import org.apache.ratis.protocol.exceptions.StateMachineException;
 import org.apache.ratis.rpc.RpcType;
@@ -135,6 +139,8 @@ public final class XceiverServerRatis implements 
XceiverServerSpi {
   private final ContainerDispatcher dispatcher;
   private final ContainerController containerController;
   private final ClientId clientId = ClientId.randomId();
+  /** The {@link ReplicationType} of the groups being added by {@link 
#addGroup}. */
+  private final ConcurrentMap<RaftGroupId, ReplicationType> addingGroups = new 
ConcurrentHashMap<>();
   private final StateContext context;
   private boolean isStarted = false;
   private final DatanodeDetails datanodeDetails;
@@ -148,6 +154,7 @@ public final class XceiverServerRatis implements 
XceiverServerSpi {
   private final boolean streamEnable;
   private final DatanodeRatisServerConfig ratisServerConfig;
   private final HddsDatanodeService datanodeService;
+  private final BiFunction<RaftPeer, GrpcTlsConfig, RaftClient> newRaftClient;
 
   private static class ActivePipelineContext {
     /** The current datanode is the current leader of the pipeline. */
@@ -183,6 +190,7 @@ private XceiverServerRatis(HddsDatanodeService 
hddsDatanodeService, DatanodeDeta
     datanodeDetails = dd;
     ratisServerConfig = conf.getObject(DatanodeRatisServerConfig.class);
     assignPorts();
+    this.newRaftClient = RatisHelper.newRaftClientNoRetry(conf);
     this.streamEnable = conf.getBoolean(
         OzoneConfigKeys.HDDS_CONTAINER_RATIS_DATASTREAM_ENABLED,
         OzoneConfigKeys.HDDS_CONTAINER_RATIS_DATASTREAM_ENABLED_DEFAULT);
@@ -237,7 +245,14 @@ private int determinePort(String key, int defaultValue) {
   }
 
   private ContainerStateMachine getStateMachine(RaftGroupId gid) {
-    return new ContainerStateMachine(datanodeService, gid, dispatcher, 
containerController,
+    ReplicationType type = addingGroups.get(gid);
+    if (type == null) {
+      // The type is unknown when the group is reloaded on restart or added by 
a peer.
+      // TODO HDDS-17845: support restart for CHAINED.
+      LOG.info("{}: ReplicationType is unknown, use {}", gid, 
ReplicationType.RATIS);
+      type = ReplicationType.RATIS;
+    }
+    return new ContainerStateMachine(datanodeService, gid, type, dispatcher, 
containerController,
         chunkExecutors, this, conf, datanodeDetails.threadNamePrefix());
   }
 
@@ -792,25 +807,28 @@ public List<PipelineReport> getPipelineReport() {
 
   @Override
   public void addGroup(PipelineID pipelineID,
+      ReplicationType type,
       List<DatanodeDetails> peers,
       List<Integer> priorityList) throws IOException {
-    final RaftGroup group = RatisHelper.newRaftGroup(pipelineID.getGroupId(), 
peers, priorityList);
+    final RaftGroupId groupId = pipelineID.getGroupId();
+    final RaftGroup group = RatisHelper.newRaftGroup(groupId, peers, 
priorityList);
     GroupManagementRequest request = GroupManagementRequest.newAdd(
         clientId, server.getId(), nextCallId(), group);
 
-    RaftClientReply reply;
-    LOG.debug("Received addGroup request for pipeline {}", pipelineID);
-
+    final RaftClientReply reply;
+    // groupManagement calls getStateMachine(groupId) before it returns.
+    addingGroups.put(groupId, type);
     try {
       reply = server.groupManagement(request);
     } catch (Exception e) {
       throw new IOException(e.getMessage(), e);
+    } finally {
+      addingGroups.remove(groupId);
     }
     processReply(reply);
-    LOG.info("Created group {}", pipelineID);
   }
 
-  public void removeGroup(RaftGroupId groupId) throws IOException {
+  private void removeGroup(RaftGroupId groupId) throws IOException {
     // if shouldDeleteRatisLogDirectory is set to false, the raft log
     // directory will be renamed and kept aside for debugging.
     // In case, its set to true, the raft log directory will be removed
@@ -827,6 +845,30 @@ public void removeGroup(RaftGroupId groupId) throws 
IOException {
     processReply(reply);
   }
 
+  public void removeGroup(RaftGroupId groupId, GrpcTlsConfig tlsConfig) throws 
IOException {
+    // For RATIS  , fan-out to removeGroup for the other datanodes (faster)
+    // For CHAINED, just remove it locally and don't fan-out
+    if (getReplicationType(groupId) == ReplicationType.RATIS) {
+      final Collection<RaftPeer> peers = getRaftPeers(groupId);
+      // For RATIS pipeline, send remove group to the other datanodes first
+      peers.stream()
+          .filter(peer -> !peer.getId().equals(getServer().getId()))
+          .forEach(peer -> {
+            try (RaftClient client = newRaftClient.apply(peer, tlsConfig)) {
+              client.getGroupManagementApi(peer.getId())
+                  .remove(groupId, shouldDeleteRatisLogDirectory, 
!shouldDeleteRatisLogDirectory);
+            } catch (GroupMismatchException ae) {
+              // ignore GroupMismatchException since the group can be closed 
by another datanode
+              LOG.debug("{} on peer {} already removed", groupId, peer);
+            } catch (IOException ioe) {
+              LOG.warn("Failed to remove group {} on peer {}", groupId, peer, 
ioe);
+            }
+          });
+    }
+    // Remove local group, might throw GroupMismatchException
+    removeGroup(groupId);
+  }
+
   void handleFollowerSlowness(RaftGroupId groupId, RoleInfoProto 
roleInfoProto, RaftPeer follower) {
     handlePipelineFailure(groupId, roleInfoProto, "slow follower " + 
follower.getId());
   }
@@ -893,6 +935,11 @@ public Collection<RaftPeer> getRaftPeers(RaftGroupId 
groupId) throws IOException
     return server.getDivision(groupId).getGroup().getPeers();
   }
 
+  /** @return the {@link ReplicationType} of the given group. */
+  public ReplicationType getReplicationType(RaftGroupId groupId) throws 
IOException {
+    return ((ContainerStateMachine) 
server.getDivision(groupId).getStateMachine()).getReplicationType();
+  }
+
   public void notifyGroupRemove(RaftGroupId gid) {
     // Remove Group ID entry from the active pipeline map
     activePipelines.remove(gid);
diff --git 
a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestClosePipelineCommandHandler.java
 
b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestClosePipelineCommandHandler.java
index 52a5ec965e2..a7bcaf0c371 100644
--- 
a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestClosePipelineCommandHandler.java
+++ 
b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestClosePipelineCommandHandler.java
@@ -21,10 +21,7 @@
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.mockito.Mockito.any;
-import static org.mockito.Mockito.anyBoolean;
 import static org.mockito.Mockito.doAnswer;
-import static org.mockito.Mockito.eq;
-import static org.mockito.Mockito.lenient;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
@@ -33,19 +30,16 @@
 import com.google.common.util.concurrent.MoreExecutors;
 import java.io.IOException;
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.List;
 import java.util.UUID;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
-import java.util.stream.Collectors;
 import org.apache.hadoop.hdds.conf.OzoneConfiguration;
 import org.apache.hadoop.hdds.protocol.DatanodeDetails;
 import org.apache.hadoop.hdds.protocol.MockDatanodeDetails;
 import 
org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.ClosePipelineCommandProto;
-import org.apache.hadoop.hdds.ratis.RatisHelper;
 import org.apache.hadoop.hdds.scm.pipeline.PipelineID;
 import org.apache.hadoop.ozone.container.common.ContainerTestUtils;
 import 
org.apache.hadoop.ozone.container.common.statemachine.SCMConnectionManager;
@@ -54,11 +48,7 @@
 import org.apache.hadoop.ozone.container.ozoneimpl.OzoneContainer;
 import org.apache.hadoop.ozone.protocol.commands.ClosePipelineCommand;
 import org.apache.hadoop.ozone.protocol.commands.SCMCommand;
-import org.apache.ratis.client.RaftClient;
-import org.apache.ratis.client.api.GroupManagementApi;
-import org.apache.ratis.protocol.RaftPeer;
-import org.apache.ratis.protocol.RaftPeerId;
-import org.apache.ratis.server.RaftServer;
+import org.apache.ratis.grpc.GrpcTlsConfig;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
@@ -69,8 +59,7 @@ public class TestClosePipelineCommandHandler {
 
   private OzoneContainer ozoneContainer;
   private SCMConnectionManager connectionManager;
-  private RaftClient raftClient;
-  private GroupManagementApi raftClientGroupManager;
+  private GrpcTlsConfig tlsConfig;
   private OzoneConfiguration conf;
 
   @BeforeEach
@@ -78,12 +67,11 @@ public void setup() throws Exception {
     conf = new OzoneConfiguration();
     ozoneContainer = mock(OzoneContainer.class);
     connectionManager = mock(SCMConnectionManager.class);
-    raftClient = mock(RaftClient.class);
-    raftClientGroupManager = mock(GroupManagementApi.class);
-    lenient().when(raftClient.getGroupManagementApi(
-        any(RaftPeerId.class))).thenReturn(raftClientGroupManager);
+    tlsConfig = mock(GrpcTlsConfig.class);
+    when(ozoneContainer.getTlsClientConfig()).thenReturn(tlsConfig);
   }
 
+  /** The peer group removal for RATIS and CHAINED is tested in 
TestXceiverServerRatisReplicationType. */
   @Test
   void testPipelineClose() throws IOException {
     final List<DatanodeDetails> datanodes = getDatanodes();
@@ -93,27 +81,16 @@ void testPipelineClose() throws IOException {
         new ClosePipelineCommand(pipelineID);
     StateContext stateContext = 
ContainerTestUtils.getMockContext(currentDatanode, conf);
 
-    final boolean shouldDeleteRatisLogDirectory = true;
     XceiverServerRatis writeChannel = mock(XceiverServerRatis.class);
     when(ozoneContainer.getWriteChannel()).thenReturn(writeChannel);
-    
when(writeChannel.getShouldDeleteRatisLogDirectory()).thenReturn(shouldDeleteRatisLogDirectory);
     when(writeChannel.isExist(pipelineID)).thenReturn(true);
-    Collection<RaftPeer> raftPeers = datanodes.stream()
-        .map(RatisHelper::toRaftPeer)
-        .collect(Collectors.toList());
-    when(writeChannel.getServer()).thenReturn(mock(RaftServer.class));
-    
when(writeChannel.getServer().getId()).thenReturn(RatisHelper.toRaftPeerId(currentDatanode));
-    
when(writeChannel.getRaftPeers(pipelineID.getGroupId())).thenReturn(raftPeers);
 
     final ClosePipelineCommandHandler commandHandler =
-        new ClosePipelineCommandHandler((leader, tls) -> raftClient, 
MoreExecutors.directExecutor());
+        new ClosePipelineCommandHandler(MoreExecutors.directExecutor());
     commandHandler.handle(command, ozoneContainer, stateContext, 
connectionManager);
 
     verify(writeChannel, times(1))
-        .removeGroup(pipelineID.getGroupId());
-
-    verify(raftClientGroupManager, times(2))
-        .remove(any(), eq(shouldDeleteRatisLogDirectory), 
eq(!shouldDeleteRatisLogDirectory));
+        .removeGroup(pipelineID.getGroupId(), tlsConfig);
   }
 
   @Test
@@ -131,14 +108,11 @@ void testCommandIdempotency() throws IOException {
     when(writeChannel.isExist(pipelineID)).thenReturn(false);
 
     final ClosePipelineCommandHandler commandHandler =
-        new ClosePipelineCommandHandler(conf, MoreExecutors.directExecutor());
+        new ClosePipelineCommandHandler(MoreExecutors.directExecutor());
     commandHandler.handle(command, ozoneContainer, stateContext, 
connectionManager);
 
     verify(writeChannel, times(0))
-        .removeGroup(pipelineID.getGroupId());
-
-    verify(raftClientGroupManager, times(0))
-        .remove(any(), anyBoolean(), anyBoolean());
+        .removeGroup(any(), any());
   }
 
   @Test
@@ -151,17 +125,9 @@ void testPendingPipelineClose() throws IOException, 
InterruptedException {
     final SCMCommand<ClosePipelineCommandProto> command2 = new 
ClosePipelineCommand(pipelineID);
     StateContext stateContext = 
ContainerTestUtils.getMockContext(currentDatanode, conf);
 
-    final boolean shouldDeleteRatisLogDirectory = true;
     XceiverServerRatis writeChannel = mock(XceiverServerRatis.class);
     when(ozoneContainer.getWriteChannel()).thenReturn(writeChannel);
-    
when(writeChannel.getShouldDeleteRatisLogDirectory()).thenReturn(shouldDeleteRatisLogDirectory);
     when(writeChannel.isExist(pipelineID)).thenReturn(true);
-    Collection<RaftPeer> raftPeers = datanodes.stream()
-        .map(RatisHelper::toRaftPeer)
-        .collect(Collectors.toList());
-    when(writeChannel.getServer()).thenReturn(mock(RaftServer.class));
-    
when(writeChannel.getServer().getId()).thenReturn(RatisHelper.toRaftPeerId(currentDatanode));
-    
when(writeChannel.getRaftPeers(pipelineID.getGroupId())).thenReturn(raftPeers);
 
     CountDownLatch firstCommandStarted = new CountDownLatch(1);
     CountDownLatch secondCommandSubmitted = new CountDownLatch(1);
@@ -170,12 +136,12 @@ void testPendingPipelineClose() throws IOException, 
InterruptedException {
       firstCommandStarted.countDown();
       secondCommandSubmitted.await();
       return null;
-    }).when(writeChannel).removeGroup(pipelineID.getGroupId());
+    }).when(writeChannel).removeGroup(pipelineID.getGroupId(), tlsConfig);
 
     ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
 
     final ClosePipelineCommandHandler commandHandler =
-        new ClosePipelineCommandHandler((leader, tls) -> raftClient, 
singleThreadExecutor);
+        new ClosePipelineCommandHandler(singleThreadExecutor);
     assertFalse(commandHandler.isPipelineCloseInProgress(pipelineUUID));
     commandHandler.handle(command1, ozoneContainer, stateContext, 
connectionManager);
     assertTrue(firstCommandStarted.await(5, TimeUnit.SECONDS));
diff --git 
a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestCreatePipelineCommandHandler.java
 
b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestCreatePipelineCommandHandler.java
index ae0147657f6..e95f45ca9ec 100644
--- 
a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestCreatePipelineCommandHandler.java
+++ 
b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/TestCreatePipelineCommandHandler.java
@@ -79,11 +79,21 @@ public void setup() throws Exception {
 
   @Test
   public void testPipelineCreation() throws IOException {
+    // the leader also adds the group to the other two datanodes
+    runPipelineCreation(HddsProtos.ReplicationType.RATIS, 2);
+  }
 
+  @Test
+  public void testChainedPipelineCreation() throws IOException {
+    // each datanode adds the group from its own command
+    runPipelineCreation(HddsProtos.ReplicationType.CHAINED, 0);
+  }
+
+  private void runPipelineCreation(HddsProtos.ReplicationType type, int 
numPeerAdds) throws IOException {
     final List<DatanodeDetails> datanodes = getDatanodes();
     final PipelineID pipelineID = PipelineID.randomId();
     final SCMCommand<CreatePipelineCommandProto> command =
-        new CreatePipelineCommand(pipelineID, HddsProtos.ReplicationType.RATIS,
+        new CreatePipelineCommand(pipelineID, type,
             HddsProtos.ReplicationFactor.THREE, datanodes, null);
     StateContext stateContext = 
ContainerTestUtils.getMockContext(datanodes.get(0), conf);
 
@@ -102,9 +112,9 @@ public void testPipelineCreation() throws IOException {
         new ArrayList<>(Collections.nCopies(datanodes.size(), 0));
 
     verify(writeChanel, times(1))
-        .addGroup(pipelineID, datanodes, priorityList);
+        .addGroup(pipelineID, type, datanodes, priorityList);
 
-    verify(raftClientGroupManager, times(2))
+    verify(raftClientGroupManager, times(numPeerAdds))
         .add(any(RaftGroup.class));
   }
 
@@ -129,7 +139,8 @@ public void testCommandIdempotency() throws IOException {
         connectionManager);
 
     verify(writeChanel, times(0))
-        .addGroup(pipelineID, datanodes, Collections.nCopies(datanodes.size(), 
0));
+        .addGroup(pipelineID, HddsProtos.ReplicationType.RATIS, datanodes,
+            Collections.nCopies(datanodes.size(), 0));
 
     verify(raftClientGroupManager, times(0))
         .add(any(RaftGroup.class));
diff --git 
a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/ContainerStateMachineTests.java
 
b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/ContainerStateMachineTests.java
index 82c158c8572..b230f2484db 100644
--- 
a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/ContainerStateMachineTests.java
+++ 
b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/ContainerStateMachineTests.java
@@ -52,6 +52,7 @@
 import java.util.stream.IntStream;
 import org.apache.hadoop.hdds.conf.OzoneConfiguration;
 import org.apache.hadoop.hdds.protocol.datanode.proto.ContainerProtos;
+import org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationType;
 import org.apache.hadoop.hdds.ratis.ContainerCommandRequestMessage;
 import 
org.apache.hadoop.hdds.scm.container.common.helpers.StorageContainerException;
 import org.apache.hadoop.ozone.container.common.interfaces.ContainerDispatcher;
@@ -119,8 +120,8 @@ public void setup() throws IOException {
     when(division.getInfo()).thenReturn(info);
     when(info.isLeader()).thenReturn(isLeader);
     when(ratisServer.getServerDivision(any())).thenReturn(division);
-    stateMachine = new ContainerStateMachine(null,
-        RaftGroupId.randomId(), dispatcher, controller, executor, ratisServer, 
conf, "containerOp");
+    stateMachine = new ContainerStateMachine(null, RaftGroupId.randomId(), 
ReplicationType.RATIS,
+        dispatcher, controller, executor, ratisServer, conf, "containerOp");
     try {
       stateMachine.initialize(raftServer, stateMachine.getGroupId(), null);
     } catch (Exception e) {
diff --git 
a/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/TestXceiverServerRatisReplicationType.java
 
b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/TestXceiverServerRatisReplicationType.java
new file mode 100644
index 00000000000..0bf6644ce21
--- /dev/null
+++ 
b/hadoop-hdds/container-service/src/test/java/org/apache/hadoop/ozone/container/common/transport/server/ratis/TestXceiverServerRatisReplicationType.java
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.hadoop.ozone.container.common.transport.server.ratis;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.hdds.protocol.DatanodeDetails;
+import org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationType;
+import org.apache.hadoop.hdds.scm.pipeline.MockPipeline;
+import org.apache.hadoop.hdds.scm.pipeline.PipelineID;
+import org.apache.hadoop.ozone.OzoneConfigKeys;
+import org.apache.hadoop.ozone.container.common.ContainerTestUtils;
+import org.apache.ratis.protocol.RaftGroupId;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.EnumSource;
+
+/**
+ * Test that {@link XceiverServerRatis#addGroup} passes the {@link 
ReplicationType} to {@link ContainerStateMachine},
+ * and that {@link XceiverServerRatis#removeGroup(RaftGroupId, 
org.apache.ratis.grpc.GrpcTlsConfig)}
+ * removes the group from the peers only for {@link ReplicationType#RATIS}.
+ */
+public class TestXceiverServerRatisReplicationType {
+  @TempDir
+  private File dir;
+  @TempDir
+  private File peerDir;
+  private DatanodeDetails dn;
+  private XceiverServerRatis server;
+  private XceiverServerRatis peerServer;
+
+  @BeforeEach
+  void setup() throws Exception {
+    dn = MockPipeline.createPipeline(1).getFirstNode();
+    server = newServer(dn, dir);
+  }
+
+  private static XceiverServerRatis newServer(DatanodeDetails datanode, File 
storageDir) throws Exception {
+    final OzoneConfiguration conf = new OzoneConfiguration();
+    conf.set(OzoneConfigKeys.HDDS_CONTAINER_RATIS_DATANODE_STORAGE_DIR, 
storageDir.getAbsolutePath());
+    conf.setBoolean(OzoneConfigKeys.HDDS_CONTAINER_RATIS_IPC_RANDOM_PORT, 
true);
+    final XceiverServerRatis s = 
ContainerTestUtils.newXceiverServerRatis(datanode, conf);
+    // start() updates the ports of the datanode to the actual ports
+    s.start();
+    return s;
+  }
+
+  @AfterEach
+  void teardown() {
+    if (server != null) {
+      server.stop();
+    }
+    if (peerServer != null) {
+      peerServer.stop();
+    }
+  }
+
+  @Test
+  void testRatis() throws Exception {
+    final PipelineID pipelineID = PipelineID.randomId();
+    server.addGroup(pipelineID, ReplicationType.RATIS, 
Collections.singletonList(dn), Collections.singletonList(0));
+    assertReplicationType(ReplicationType.RATIS, pipelineID);
+  }
+
+  @Test
+  void testChained() throws Exception {
+    final PipelineID pipelineID = PipelineID.randomId();
+    server.addGroup(pipelineID, ReplicationType.CHAINED, 
Collections.singletonList(dn), Collections.singletonList(0));
+    assertReplicationType(ReplicationType.CHAINED, pipelineID);
+  }
+
+  @ParameterizedTest
+  @EnumSource(value = ReplicationType.class, names = {"RATIS", "CHAINED"})
+  void testRemoveGroup(ReplicationType type) throws Exception {
+    final DatanodeDetails peerDn = 
MockPipeline.createPipeline(1).getFirstNode();
+    peerServer = newServer(peerDn, peerDir);
+
+    final PipelineID pipelineID = PipelineID.randomId();
+    final RaftGroupId groupId = pipelineID.getGroupId();
+    final List<DatanodeDetails> peers = Arrays.asList(dn, peerDn);
+    final List<Integer> priorities = Arrays.asList(0, 0);
+    server.addGroup(pipelineID, type, peers, priorities);
+    peerServer.addGroup(pipelineID, type, peers, priorities);
+    assertTrue(hasGroup(peerServer, groupId));
+
+    server.removeGroup(groupId, null);
+
+    assertFalse(hasGroup(server, groupId));
+    // For RATIS, the group is also removed from the peer; for CHAINED, only 
locally.
+    assertEquals(type == ReplicationType.CHAINED, hasGroup(peerServer, 
groupId));
+  }
+
+  private static boolean hasGroup(XceiverServerRatis s, RaftGroupId groupId) {
+    for (RaftGroupId id : s.getServer().getGroupIds()) {
+      if (id.equals(groupId)) {
+        return true;
+      }
+    }
+    return false;
+  }
+
+  private void assertReplicationType(ReplicationType expected, PipelineID 
pipelineID) throws Exception {
+    final RaftGroupId groupId = RaftGroupId.valueOf(pipelineID.getId());
+    final ContainerStateMachine stateMachine = 
assertInstanceOf(ContainerStateMachine.class,
+        server.getServerDivision(groupId).getStateMachine());
+    assertEquals(expected, stateMachine.getReplicationType());
+    assertEquals(expected, server.getReplicationType(pipelineID.getGroupId()));
+  }
+}
diff --git 
a/hadoop-ozone/integration-test-utils/src/main/java/org/apache/hadoop/ozone/container/OzoneTestHelper.java
 
b/hadoop-ozone/integration-test-utils/src/main/java/org/apache/hadoop/ozone/container/OzoneTestHelper.java
index 5b6213c690d..5a4fd7342f9 100644
--- 
a/hadoop-ozone/integration-test-utils/src/main/java/org/apache/hadoop/ozone/container/OzoneTestHelper.java
+++ 
b/hadoop-ozone/integration-test-utils/src/main/java/org/apache/hadoop/ozone/container/OzoneTestHelper.java
@@ -19,6 +19,7 @@
 
 import static java.util.stream.Collectors.toList;
 import static 
org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor.THREE;
+import static 
org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationType.RATIS;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.jupiter.api.Assertions.assertArrayEquals;
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -324,7 +325,7 @@ public static void createPipelineOnDatanode(Pipeline 
pipeline,
       assertInstanceOf(XceiverServerRatis.class, server);
       try {
         final List<DatanodeDetails> peers = 
Collections.unmodifiableList(pipeline.getNodes());
-        server.addGroup(pipeline.getId(), peers, 
Collections.nCopies(peers.size(), 0));
+        server.addGroup(pipeline.getId(), RATIS, peers, 
Collections.nCopies(peers.size(), 0));
       } catch (Exception e) {
         //ignore exception
       }


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

Reply via email to