Search in sources :

Example 16 with Endpoint

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);
}
Also used : Endpoint(com.alibaba.maxgraph.sdkcommon.client.Endpoint)

Example 17 with Endpoint

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"));
}
Also used : Endpoint(com.alibaba.maxgraph.sdkcommon.client.Endpoint) InstanceInfo(com.alibaba.maxgraph.coordinator.manager.InstanceInfo) Test(org.junit.Test)

Example 18 with Endpoint

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;
}
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)

Example 19 with Endpoint

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);
}
Also used : Endpoint(com.alibaba.maxgraph.sdkcommon.client.Endpoint) ScheduledThreadPoolExecutor(java.util.concurrent.ScheduledThreadPoolExecutor) WorkerInfo(com.alibaba.maxgraph.common.client.WorkerInfo)

Example 20 with Endpoint

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;
}
Also used : Endpoint(com.alibaba.maxgraph.sdkcommon.client.Endpoint) MaxGraphCtrlServiceBlockingStub(com.alibaba.maxgraph.rpc.MaxGraphCtrlServiceGrpc.MaxGraphCtrlServiceBlockingStub) ManagedChannel(io.grpc.ManagedChannel)

Aggregations

Endpoint (com.alibaba.maxgraph.sdkcommon.client.Endpoint)21 WorkerInfo (com.alibaba.maxgraph.common.client.WorkerInfo)3 MaxGraphCtrlServiceBlockingStub (com.alibaba.maxgraph.rpc.MaxGraphCtrlServiceGrpc.MaxGraphCtrlServiceBlockingStub)3 ManagedChannel (io.grpc.ManagedChannel)3 InstanceInfo (com.alibaba.maxgraph.coordinator.manager.InstanceInfo)2 ArrayList (java.util.ArrayList)2 QueryFlowOuterClass (com.alibaba.maxgraph.QueryFlowOuterClass)1 InstanceStatus (com.alibaba.maxgraph.common.InstanceStatus)1 ServerAssignment (com.alibaba.maxgraph.common.ServerAssignment)1 InstanceConfig (com.alibaba.maxgraph.common.cluster.InstanceConfig)1 LockWrapper (com.alibaba.maxgraph.common.lock.LockWrapper)1 RpcAddress (com.alibaba.maxgraph.common.rpc.RpcAddress)1 GraphSchema (com.alibaba.maxgraph.compiler.api.schema.GraphSchema)1 SchemaFetcher (com.alibaba.maxgraph.compiler.api.schema.SchemaFetcher)1 ServerDataApiClient (com.alibaba.maxgraph.coordinator.client.ServerDataApiClient)1 IteratorList (com.alibaba.maxgraph.iterator.IteratorList)1 RoleType (com.alibaba.maxgraph.proto.RoleType)1 RoutingServerInfoResp (com.alibaba.maxgraph.proto.RoutingServerInfoResp)1 RuntimeEnvList (com.alibaba.maxgraph.proto.RuntimeEnvList)1 PropertyValueResult (com.alibaba.maxgraph.result.PropertyValueResult)1