HDDS-506. Fields in AllocateScmBlockResponseProto should be optional. Contributed by Arpit Agarwal.

This commit is contained in:
Xiaoyu Yao 2018-09-18 23:21:29 -07:00
parent fb85351dc6
commit e435e12f1f
3 changed files with 9 additions and 4 deletions

View File

@ -104,9 +104,9 @@ message AllocateScmBlockResponseProto {
unknownFailure = 4; unknownFailure = 4;
} }
required Error errorCode = 1; required Error errorCode = 1;
required BlockID blockID = 2; optional BlockID blockID = 2;
required hadoop.hdds.Pipeline pipeline = 3; optional hadoop.hdds.Pipeline pipeline = 3;
required bool createContainer = 4; optional bool createContainer = 4;
optional string errorMessage = 5; optional string errorMessage = 5;
} }

View File

@ -118,6 +118,7 @@ public enum ResultCodes {
SCM_NOT_INITIALIZED, SCM_NOT_INITIALIZED,
DUPLICATE_DATANODE, DUPLICATE_DATANODE,
NO_SUCH_DATANODE, NO_SUCH_DATANODE,
NO_REPLICA_FOUND NO_REPLICA_FOUND,
FAILED_TO_FIND_ACTIVE_PIPELINE
} }
} }

View File

@ -62,6 +62,7 @@
import static org.apache.hadoop.hdds.scm.exceptions.SCMException.ResultCodes import static org.apache.hadoop.hdds.scm.exceptions.SCMException.ResultCodes
.FAILED_TO_CHANGE_PIPELINE_STATE; .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 import static org.apache.hadoop.hdds.server
.ServerUtils.getOzoneMetaDirPath; .ServerUtils.getOzoneMetaDirPath;
import static org.apache.hadoop.ozone import static org.apache.hadoop.ozone
@ -285,6 +286,9 @@ public Pipeline getReplicationPipeline(ReplicationType replicationType,
// try to return a pipeline from already allocated pipelines // try to return a pipeline from already allocated pipelines
PipelineID pipelineId = PipelineID pipelineId =
manager.getPipeline(replicationFactor, replicationType); manager.getPipeline(replicationFactor, replicationType);
if (pipelineId == null) {
throw new SCMException(FAILED_TO_FIND_ACTIVE_PIPELINE);
}
pipeline = pipelineMap.get(pipelineId); pipeline = pipelineMap.get(pipelineId);
Preconditions.checkArgument(pipeline.getLifeCycleState() == Preconditions.checkArgument(pipeline.getLifeCycleState() ==
LifeCycleState.OPEN); LifeCycleState.OPEN);