From 738fab3bff04ab0128146b401b4978d3d60ec97f Mon Sep 17 00:00:00 2001 From: supratimdeka <46919641+supratimdeka@users.noreply.github.com> Date: Fri, 12 Jul 2019 10:31:48 +0530 Subject: [PATCH] HDDS-1754. getContainerWithPipeline fails with PipelineNotFoundException. Contributed by Supratim Deka (#1081) --- .../apache/hadoop/hdds/scm/container/ContainerInfo.java | 8 ++++++++ .../hadoop/hdds/scm/server/SCMClientProtocolServer.java | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerInfo.java b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerInfo.java index 7b5c467e67..0ecfdacb03 100644 --- a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerInfo.java +++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/scm/container/ContainerInfo.java @@ -467,4 +467,12 @@ public boolean isOpen() { return state == HddsProtos.LifeCycleState.OPEN || state == HddsProtos.LifeCycleState.CLOSING; } + + /** + * Check if a container is in Open state, but Close has not been initiated. + * @return true if Open, false otherwise. + */ + public boolean isOpenNotClosing() { + return state == HddsProtos.LifeCycleState.OPEN; + } } diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java index 6a875e6564..769f3efe33 100644 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java +++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java @@ -238,7 +238,7 @@ public ContainerWithPipeline getContainerWithPipeline(long containerID) getContainer(id); final Pipeline pipeline; - if (container.isOpen()) { + if (container.isOpenNotClosing()) { // Ratis pipeline pipeline = scm.getPipelineManager() .getPipeline(container.getPipelineID());