瀏覽代碼

HDDS-551. Fix the close container status check in CloseContainerCommandHandler. Contributed by Shashikant Banerjee.

Hanisha Koneru 6 年之前
父節點
當前提交
2a5d4315bf

+ 11 - 0
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/statemachine/commandhandler/CloseContainerCommandHandler.java

@@ -74,6 +74,17 @@ public class CloseContainerCommandHandler implements CommandHandler {
           CloseContainerCommandProto
               .parseFrom(command.getProtoBufMessage());
       containerID = closeContainerProto.getContainerID();
+      if (container.getContainerSet().getContainer(containerID)
+          .getContainerData().isClosed()) {
+        LOG.debug("Container {} is already closed", containerID);
+        // It might happen that the where the first attempt of closing the
+        // container failed with NOT_LEADER_EXCEPTION. In such cases, SCM will
+        // retry to check the container got really closed via Ratis.
+        // In such cases of the retry attempt, if the container is already
+        // closed via Ratis, we should just return.
+        cmdExecuted = true;
+        return;
+      }
       HddsProtos.PipelineID pipelineID = closeContainerProto.getPipelineID();
       HddsProtos.ReplicationType replicationType =
           closeContainerProto.getReplicationType();

+ 0 - 9
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/ozoneimpl/OzoneContainer.java

@@ -188,15 +188,6 @@ public class OzoneContainer {
       ContainerProtos.ContainerCommandRequestProto request,
       ReplicationType replicationType,
       PipelineID pipelineID) throws IOException {
-    if (containerSet.getContainer(request.getContainerID())
-        .getContainerData().isClosed()) {
-      LOG.debug("Container {} is already closed", request.getContainerID());
-      // It might happen that the where the first attempt of closing the
-      // container failed with NOT_LEADER_EXCEPTION. In such cases, SCM will
-      // retry to check the container got really closed via Ratis.
-      // In such cases of the retry attempt, if the container is already closed
-      // via Ratis, we should just return.
-    }
     LOG.info("submitting {} request over {} server for container {}",
         request.getCmdType(), replicationType, request.getContainerID());
     Preconditions.checkState(servers.containsKey(replicationType));