use of com.alibaba.maxgraph.sdkcommon.client.Endpoint in project GraphScope by alibaba.
the class ServerDataApiServer method resendSimpleRequest.
void resendSimpleRequest(SimpleServerHBReq request) {
int nodeId = request.getNodeId();
long heartbeatTime = System.currentTimeMillis();
EndpointProto endpoint = request.getEndpoint();
NodeInfo nodeInfo = NodeInfo.newBuilder().setNodeId(NodeID.newBuilder().setRole(request.getRoleType()).setId(nodeId)).setHost(endpoint.getHost()).setPort(endpoint.getPort()).build();
masterService.updateNodeState(nodeInfo, heartbeatTime, null);
}
use of com.alibaba.maxgraph.sdkcommon.client.Endpoint in project GraphScope by alibaba.
the class WorkerManagerApiServerTest method testReadAndWriteRuntimeEnvs.
@Test
public void testReadAndWriteRuntimeEnvs() {
String logDir = "";
InstanceInfo instanceInfo = new InstanceInfo();
instanceInfo.setWorkerInfo(RoleType.EXECUTOR, 0, new Endpoint("127.0.0.1", 1, 2), logDir);
instanceInfo.setWorkerInfo(RoleType.EXECUTOR, 1, new Endpoint("127.0.0.1", 1, 2), logDir);
instanceInfo.setWorkerInfo(RoleType.EXECUTOR, 2, new Endpoint("127.0.0.1", 1, 2), logDir);
instanceInfo.setWorkerInfo(RoleType.EXECUTOR, 3, new Endpoint("127.0.0.1", 1, 2), logDir);
List<String> envs = instanceInfo.updateExecutorRuntimeEnv(0, "127.0.0.1", 3);
Assert.assertEquals(envs, Lists.newArrayList("127.0.0.1:3", "127.0.0.1:0", "127.0.0.1:0", "127.0.0.1:0"));
instanceInfo.updateExecutorRuntimeEnv(1, "127.0.0.1", 4);
instanceInfo.updateExecutorRuntimeEnv(2, "127.0.0.1", 5);
instanceInfo.updateExecutorRuntimeEnv(3, "127.0.0.1", 6);
List<String> envs2 = instanceInfo.updateExecutorRuntimeEnv(4, "127.0.0.1", 7);
Assert.assertEquals(envs2, Lists.newArrayList("127.0.0.1:3", "127.0.0.1:4", "127.0.0.1:5", "127.0.0.1:6", "127.0.0.1:7"));
List<String> envs3 = instanceInfo.getRuntimeEnv();
Assert.assertEquals(envs3, Lists.newArrayList("127.0.0.1:3", "127.0.0.1:4", "127.0.0.1:5", "127.0.0.1:6", "127.0.0.1:7"));
}
use of com.alibaba.maxgraph.sdkcommon.client.Endpoint 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;
}
use of com.alibaba.maxgraph.sdkcommon.client.Endpoint in project GraphScope by alibaba.
the class ServerDataManager method startUpdateThread.
private void startUpdateThread() {
frontEndUpdateSchedule = new ScheduledThreadPoolExecutor(1, CommonUtil.createFactoryWithDefaultExceptionHandler("FrontEndUpdate_THREAD", LOG));
frontEndUpdateSchedule.scheduleWithFixedDelay(() -> {
Map<Integer, Endpoint> endpointMap = Maps.newHashMap();
for (WorkerInfo info : instanceInfo.getWorkerInfo(RoleType.FRONTEND)) {
endpointMap.put(info.id, info.endpoint);
}
if (!endpointMap.equals(this.endpointMap)) {
this.endpointMap = endpointMap;
StringBuilder sb = new StringBuilder();
for (Endpoint endpoint : this.endpointMap.values()) {
sb.append(endpoint.getIp()).append(":").append(endpoint.getGremlinServerPort()).append(" ");
}
String text = StringUtils.removeEnd(sb.toString(), " ");
try {
namingProxy.persistFrontEndEndpoints(vpcEndpoint, text);
} catch (Exception e) {
LOG.error("persist frontend ips error", e);
LOG.error("front ips info: {}", text);
}
}
}, 1, instanceConfig.getFrontendAmHbIntervalSeconds(), TimeUnit.SECONDS);
}
use of com.alibaba.maxgraph.sdkcommon.client.Endpoint in project GraphScope by alibaba.
the class RpcConnector method hasCancelDataFlowByFrontCompleted.
public boolean hasCancelDataFlowByFrontCompleted(int frontId, List<Endpoint> serverList) throws Exception {
for (Endpoint entry : serverList) {
IpPort address = IpPort.fromCtrlAndAsyncEndpoint(entry);
ManagedChannel randomChannel = channels.get(address).get(RandomUtils.nextInt(0, channelCount)).getRight();
MaxGraphCtrlServiceBlockingStub stub = MaxGraphCtrlServiceGrpc.newBlockingStub(randomChannel);
ShowProcessListResponse resp = stub.showProcessList(ShowProcessListRequest.newBuilder().build());
// resp.getQueriesList());
for (RunningQuery runningQuery : resp.getQueriesList()) {
if (runningQuery.getFrontId() == frontId) {
return false;
}
}
}
return true;
}
Aggregations