use of org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.SCMListContainerResponseProto in project ozone by apache.
the class StorageContainerLocationProtocolServerSideTranslatorPB method listContainer.
public SCMListContainerResponseProto listContainer(SCMListContainerRequestProto request) throws IOException {
long startContainerID = 0;
int count = -1;
// Arguments check.
if (request.hasStartContainerID()) {
// End container name is given.
startContainerID = request.getStartContainerID();
}
count = request.getCount();
HddsProtos.LifeCycleState state = null;
HddsProtos.ReplicationFactor factor = null;
if (request.hasState()) {
state = request.getState();
}
if (request.hasFactor()) {
factor = request.getFactor();
}
List<ContainerInfo> containerList = impl.listContainer(startContainerID, count, state, factor);
SCMListContainerResponseProto.Builder builder = SCMListContainerResponseProto.newBuilder();
for (ContainerInfo container : containerList) {
builder.addContainers(container.getProtobuf());
}
return builder.build();
}
use of org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.SCMListContainerResponseProto 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