use of org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.SortDatanodesRequestProto in project ozone by apache.
the class ScmBlockLocationProtocolClientSideTranslatorPB method sortDatanodes.
/**
* Sort the datanodes based on distance from client.
* @return List<DatanodeDetails></>
* @throws IOException
*/
@Override
public List<DatanodeDetails> sortDatanodes(List<String> nodes, String clientMachine) throws IOException {
SortDatanodesRequestProto request = SortDatanodesRequestProto.newBuilder().addAllNodeNetworkName(nodes).setClient(clientMachine).build();
SCMBlockLocationRequest wrapper = createSCMBlockRequest(Type.SortDatanodes).setSortDatanodesRequest(request).build();
final SCMBlockLocationResponse wrappedResponse = handleError(submitRequest(wrapper));
SortDatanodesResponseProto resp = wrappedResponse.getSortDatanodesResponse();
List<DatanodeDetails> results = new ArrayList<>(resp.getNodeCount());
results.addAll(resp.getNodeList().stream().map(node -> DatanodeDetails.getFromProtoBuf(node)).collect(Collectors.toList()));
return results;
}
Aggregations