Search in sources :

Example 1 with SortDatanodesRequestProto

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;
}
Also used : SCMBlockLocationRequest(org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.SCMBlockLocationRequest) SortDatanodesRequestProto(org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.SortDatanodesRequestProto) DatanodeDetails(org.apache.hadoop.hdds.protocol.DatanodeDetails) SCMBlockLocationResponse(org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.SCMBlockLocationResponse) ArrayList(java.util.ArrayList) SortDatanodesResponseProto(org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.SortDatanodesResponseProto)

Aggregations

ArrayList (java.util.ArrayList)1 DatanodeDetails (org.apache.hadoop.hdds.protocol.DatanodeDetails)1 SCMBlockLocationRequest (org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.SCMBlockLocationRequest)1 SCMBlockLocationResponse (org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.SCMBlockLocationResponse)1 SortDatanodesRequestProto (org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.SortDatanodesRequestProto)1 SortDatanodesResponseProto (org.apache.hadoop.hdds.protocol.proto.ScmBlockLocationProtocolProtos.SortDatanodesResponseProto)1