use of org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.SCMListContainerRequestProto in project ozone by apache.
the class StorageContainerLocationProtocolClientSideTranslatorPB method listContainer.
@Override
public List<ContainerInfo> listContainer(long startContainerID, int count, HddsProtos.LifeCycleState state, HddsProtos.ReplicationFactor factor) throws IOException {
Preconditions.checkState(startContainerID >= 0, "Container ID cannot be negative.");
Preconditions.checkState(count > 0, "Container count must be greater than 0.");
SCMListContainerRequestProto.Builder builder = SCMListContainerRequestProto.newBuilder();
builder.setStartContainerID(startContainerID);
builder.setCount(count);
builder.setTraceID(TracingUtil.exportCurrentSpan());
if (state != null) {
builder.setState(state);
}
if (factor != null) {
builder.setFactor(factor);
}
SCMListContainerRequestProto request = builder.build();
SCMListContainerResponseProto response = submitRequest(Type.ListContainer, builder1 -> builder1.setScmListContainerRequest(request)).getScmListContainerResponse();
List<ContainerInfo> containerList = new ArrayList<>();
for (HddsProtos.ContainerInfoProto containerInfoProto : response.getContainersList()) {
containerList.add(ContainerInfo.fromProtobuf(containerInfoProto));
}
return containerList;
}
Aggregations