use of org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.SortDatanodesResponseProto in project ozone by apache.
the class ScmBlockLocationProtocolServerSideTranslatorPB method sortDatanodes.
public SortDatanodesResponseProto sortDatanodes(SortDatanodesRequestProto request, int clientVersion) throws ServiceException {
SortDatanodesResponseProto.Builder resp = SortDatanodesResponseProto.newBuilder();
try {
List<String> nodeList = request.getNodeNetworkNameList();
final List<DatanodeDetails> results = impl.sortDatanodes(nodeList, request.getClient());
if (results != null) {
for (DatanodeDetails dn : results) {
resp.addNode(dn.toProto(clientVersion));
}
}
return resp.build();
} catch (IOException ex) {
throw new ServiceException(ex);
}
}
use of org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.SortDatanodesResponseProto 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