Search in sources :

Example 1 with RoutingServerInfoResp

use of com.alibaba.maxgraph.proto.RoutingServerInfoResp in project GraphScope by alibaba.

the class FrontendQueryManager method getRoutingServerEndpointList.

private List<Endpoint> getRoutingServerEndpointList() throws Exception {
    List<Endpoint> endpointList = new ArrayList<>();
    ServerDataApiClient serverDataApiClient = clientManager.getServerDataApiClient();
    // rpc to coordinator to fetch latest routing server workerInfo and serverIdList
    RoutingServerInfoResp routingServerInfoResp = serverDataApiClient.getWorkerInfoAndRoutingServerList();
    // transform workerInfoList to serverId2Endpoint Map
    Map<Integer, Endpoint> serverId2Endpoint = new HashMap<>();
    routingServerInfoResp.getWorkerInfoProtos().getInfosList().forEach(workerInfoProto -> {
        int id = workerInfoProto.getId();
        if (!serverId2Endpoint.containsKey(id)) {
            serverId2Endpoint.put(id, Endpoint.fromProto(workerInfoProto.getAddress()));
        }
    });
    routingServerInfoResp.getServingServerIdList().forEach((serverId) -> {
        endpointList.add(serverId2Endpoint.get(serverId));
    });
    return endpointList;
}
Also used : Endpoint(com.alibaba.maxgraph.sdkcommon.client.Endpoint) ServerDataApiClient(com.alibaba.maxgraph.coordinator.client.ServerDataApiClient) RoutingServerInfoResp(com.alibaba.maxgraph.proto.RoutingServerInfoResp) Endpoint(com.alibaba.maxgraph.sdkcommon.client.Endpoint)

Aggregations

ServerDataApiClient (com.alibaba.maxgraph.coordinator.client.ServerDataApiClient)1 RoutingServerInfoResp (com.alibaba.maxgraph.proto.RoutingServerInfoResp)1 Endpoint (com.alibaba.maxgraph.sdkcommon.client.Endpoint)1