diff --git a/hadoop-hdds/common/src/main/proto/ScmBlockLocationProtocol.proto b/hadoop-hdds/common/src/main/proto/ScmBlockLocationProtocol.proto index 53f408ae88..9b4e0acaba 100644 --- a/hadoop-hdds/common/src/main/proto/ScmBlockLocationProtocol.proto +++ b/hadoop-hdds/common/src/main/proto/ScmBlockLocationProtocol.proto @@ -104,9 +104,9 @@ message AllocateScmBlockResponseProto { unknownFailure = 4; } required Error errorCode = 1; - required BlockID blockID = 2; - required hadoop.hdds.Pipeline pipeline = 3; - required bool createContainer = 4; + optional BlockID blockID = 2; + optional hadoop.hdds.Pipeline pipeline = 3; + optional bool createContainer = 4; optional string errorMessage = 5; } diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/exceptions/SCMException.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/exceptions/SCMException.java index 87a29e3a5d..dae0b06505 100644 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/exceptions/SCMException.java +++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/exceptions/SCMException.java @@ -118,6 +118,7 @@ public enum ResultCodes { SCM_NOT_INITIALIZED, DUPLICATE_DATANODE, NO_SUCH_DATANODE, - NO_REPLICA_FOUND + NO_REPLICA_FOUND, + FAILED_TO_FIND_ACTIVE_PIPELINE } } diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipelines/PipelineSelector.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipelines/PipelineSelector.java index c9f51f7a42..82946bdd7d 100644 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipelines/PipelineSelector.java +++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipelines/PipelineSelector.java @@ -62,6 +62,7 @@ import static org.apache.hadoop.hdds.scm.exceptions.SCMException.ResultCodes .FAILED_TO_CHANGE_PIPELINE_STATE; +import static org.apache.hadoop.hdds.scm.exceptions.SCMException.ResultCodes.FAILED_TO_FIND_ACTIVE_PIPELINE; import static org.apache.hadoop.hdds.server .ServerUtils.getOzoneMetaDirPath; import static org.apache.hadoop.ozone @@ -285,6 +286,9 @@ public Pipeline getReplicationPipeline(ReplicationType replicationType, // try to return a pipeline from already allocated pipelines PipelineID pipelineId = manager.getPipeline(replicationFactor, replicationType); + if (pipelineId == null) { + throw new SCMException(FAILED_TO_FIND_ACTIVE_PIPELINE); + } pipeline = pipelineMap.get(pipelineId); Preconditions.checkArgument(pipeline.getLifeCycleState() == LifeCycleState.OPEN);