use of org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ScmContainerLocationResponse in project ozone by apache.
the class StorageContainerLocationProtocolClientSideTranslatorPB method submitRequest.
/**
* Helper method to wrap the request and send the message.
*/
private ScmContainerLocationResponse submitRequest(StorageContainerLocationProtocolProtos.Type type, Consumer<Builder> builderConsumer) throws IOException {
final ScmContainerLocationResponse response;
try {
Builder builder = ScmContainerLocationRequest.newBuilder().setCmdType(type).setVersion(CURRENT_VERSION).setTraceID(TracingUtil.exportCurrentSpan());
builderConsumer.accept(builder);
ScmContainerLocationRequest wrapper = builder.build();
response = submitRpcRequest(wrapper);
} catch (ServiceException ex) {
throw ProtobufHelper.getRemoteException(ex);
}
return response;
}
use of org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ScmContainerLocationResponse in project ozone by apache.
the class StorageContainerLocationProtocolClientSideTranslatorPB method getExistContainerWithPipelinesInBatch.
/**
* {@inheritDoc}
*/
@Override
public List<ContainerWithPipeline> getExistContainerWithPipelinesInBatch(List<Long> containerIDs) {
for (Long containerID : containerIDs) {
Preconditions.checkState(containerID >= 0, "Container ID cannot be negative");
}
GetExistContainerWithPipelinesInBatchRequestProto request = GetExistContainerWithPipelinesInBatchRequestProto.newBuilder().setTraceID(TracingUtil.exportCurrentSpan()).addAllContainerIDs(containerIDs).build();
ScmContainerLocationResponse response = null;
List<ContainerWithPipeline> cps = new ArrayList<>();
try {
response = submitRequest(Type.GetExistContainerWithPipelinesInBatch, (builder) -> builder.setGetExistContainerWithPipelinesInBatchRequest(request));
} catch (IOException ex) {
return cps;
}
List<HddsProtos.ContainerWithPipeline> protoCps = response.getGetExistContainerWithPipelinesInBatchResponse().getContainerWithPipelinesList();
for (HddsProtos.ContainerWithPipeline cp : protoCps) {
try {
cps.add(ContainerWithPipeline.fromProtobuf(cp));
} catch (IOException uex) {
// "fromProtobuf" may throw an exception
// do nothing , just go ahead
}
}
return cps;
}
use of org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ScmContainerLocationResponse in project ozone by apache.
the class StorageContainerLocationProtocolClientSideTranslatorPB method getContainerWithPipelineBatch.
/**
* {@inheritDoc}
*/
@Override
public List<ContainerWithPipeline> getContainerWithPipelineBatch(List<Long> containerIDs) throws IOException {
for (Long containerID : containerIDs) {
Preconditions.checkState(containerID >= 0, "Container ID cannot be negative");
}
GetContainerWithPipelineBatchRequestProto request = GetContainerWithPipelineBatchRequestProto.newBuilder().setTraceID(TracingUtil.exportCurrentSpan()).addAllContainerIDs(containerIDs).build();
ScmContainerLocationResponse response = submitRequest(Type.GetContainerWithPipelineBatch, (builder) -> builder.setGetContainerWithPipelineBatchRequest(request));
List<HddsProtos.ContainerWithPipeline> protoCps = response.getGetContainerWithPipelineBatchResponse().getContainerWithPipelinesList();
List<ContainerWithPipeline> cps = new ArrayList<>();
for (HddsProtos.ContainerWithPipeline cp : protoCps) {
cps.add(ContainerWithPipeline.fromProtobuf(cp));
}
return cps;
}
use of org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ScmContainerLocationResponse in project ozone by apache.
the class StorageContainerLocationProtocolClientSideTranslatorPB method getContainer.
@Override
public ContainerInfo getContainer(long containerID) throws IOException {
Preconditions.checkState(containerID >= 0, "Container ID cannot be negative");
GetContainerRequestProto request = GetContainerRequestProto.newBuilder().setContainerID(containerID).setTraceID(TracingUtil.exportCurrentSpan()).build();
ScmContainerLocationResponse response = submitRequest(Type.GetContainer, (builder) -> builder.setGetContainerRequest(request));
return ContainerInfo.fromProtobuf(response.getGetContainerResponse().getContainerInfo());
}
use of org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ScmContainerLocationResponse in project ozone by apache.
the class StorageContainerLocationProtocolClientSideTranslatorPB method getContainerReplicas.
/**
* {@inheritDoc}
*/
@Override
public List<HddsProtos.SCMContainerReplicaProto> getContainerReplicas(long containerID) throws IOException {
Preconditions.checkState(containerID >= 0, "Container ID cannot be negative");
GetContainerReplicasRequestProto request = GetContainerReplicasRequestProto.newBuilder().setTraceID(TracingUtil.exportCurrentSpan()).setContainerID(containerID).build();
ScmContainerLocationResponse response = submitRequest(Type.GetContainerReplicas, (builder) -> builder.setGetContainerReplicasRequest(request));
return response.getGetContainerReplicasResponse().getContainerReplicaList();
}
Aggregations