use of org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.PipelineRequestProto in project ozone by apache.
the class StorageContainerLocationProtocolClientSideTranslatorPB method createReplicationPipeline.
/**
* Creates a replication pipeline of a specified type.
*
* @param replicationType - replication type
* @param factor - factor 1 or 3
* @param nodePool - optional machine list to build a pipeline.
*/
@Override
public Pipeline createReplicationPipeline(HddsProtos.ReplicationType replicationType, HddsProtos.ReplicationFactor factor, HddsProtos.NodePool nodePool) throws IOException {
PipelineRequestProto request = PipelineRequestProto.newBuilder().setTraceID(TracingUtil.exportCurrentSpan()).setNodePool(nodePool).setReplicationFactor(factor).setReplicationType(replicationType).build();
PipelineResponseProto response = submitRequest(Type.AllocatePipeline, builder -> builder.setPipelineRequest(request)).getPipelineResponse();
if (response.getErrorCode() == PipelineResponseProto.Error.success) {
Preconditions.checkState(response.hasPipeline(), "With success, " + "must come a pipeline");
return Pipeline.getFromProtobuf(response.getPipeline());
} else {
String errorMessage = String.format("create replication pipeline " + "failed. code : %s Message: %s", response.getErrorCode(), response.hasErrorMessage() ? response.getErrorMessage() : "");
throw new IOException(errorMessage);
}
}
Aggregations