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

This commit is contained in:
Hanisha Koneru 2018-09-27 16:03:49 -07:00
parent 90e2e493b3
commit 2a5d4315bf
2 changed files with 11 additions and 9 deletions

View File

@ -74,6 +74,17 @@ public void handle(SCMCommand command, OzoneContainer container,
CloseContainerCommandProto CloseContainerCommandProto
.parseFrom(command.getProtoBufMessage()); .parseFrom(command.getProtoBufMessage());
containerID = closeContainerProto.getContainerID(); 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.PipelineID pipelineID = closeContainerProto.getPipelineID();
HddsProtos.ReplicationType replicationType = HddsProtos.ReplicationType replicationType =
closeContainerProto.getReplicationType(); closeContainerProto.getReplicationType();

View File

@ -188,15 +188,6 @@ public void submitContainerRequest(
ContainerProtos.ContainerCommandRequestProto request, ContainerProtos.ContainerCommandRequestProto request,
ReplicationType replicationType, ReplicationType replicationType,
PipelineID pipelineID) throws IOException { 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 {}", LOG.info("submitting {} request over {} server for container {}",
request.getCmdType(), replicationType, request.getContainerID()); request.getCmdType(), replicationType, request.getContainerID());
Preconditions.checkState(servers.containsKey(replicationType)); Preconditions.checkState(servers.containsKey(replicationType));