use of org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ContainerRequestProto in project ozone by apache.
the class StorageContainerLocationProtocolClientSideTranslatorPB method allocateContainer.
/**
* Asks SCM where a container should be allocated. SCM responds with the set
* of datanodes that should be used creating this container. Ozone/SCM only
* supports replication factor of either 1 or 3.
*
* @param type - Replication Type
* @param factor - Replication Count
* @param owner - Service owner of the container.
*/
@Override
public ContainerWithPipeline allocateContainer(HddsProtos.ReplicationType type, HddsProtos.ReplicationFactor factor, String owner) throws IOException {
ContainerRequestProto request = ContainerRequestProto.newBuilder().setTraceID(TracingUtil.exportCurrentSpan()).setReplicationFactor(factor).setReplicationType(type).setOwner(owner).build();
ContainerResponseProto response = submitRequest(Type.AllocateContainer, builder -> builder.setContainerRequest(request)).getContainerResponse();
// TODO should be migrated to use the top level status structure.
if (response.getErrorCode() != ContainerResponseProto.Error.success) {
throw new IOException(response.hasErrorMessage() ? response.getErrorMessage() : "Allocate container failed.");
}
return ContainerWithPipeline.fromProtobuf(response.getContainerWithPipeline());
}
Aggregations