use of com.alibaba.maxgraph.coordinator.client.ServerDataApiClient 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;
}
Aggregations