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;
}
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;
}

View File

@ -118,6 +118,7 @@ public class SCMException extends IOException {
SCM_NOT_INITIALIZED,
DUPLICATE_DATANODE,
NO_SUCH_DATANODE,
NO_REPLICA_FOUND
NO_REPLICA_FOUND,
FAILED_TO_FIND_ACTIVE_PIPELINE
}
}

View File

@ -62,6 +62,7 @@ import java.util.concurrent.TimeUnit;
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 class PipelineSelector {
// 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);