Search in sources :

Example 11 with Endpoint

use of com.alibaba.maxgraph.sdkcommon.client.Endpoint in project GraphScope by alibaba.

the class Frontend method startRpcService.

protected void startRpcService() throws Exception {
    String hostName = InetAddress.getLocalHost().getHostAddress();
    int threadCount = this.instanceConfig.getFrontendGrpcThreadCount();
    LOG.info("rpc server thread count: " + threadCount);
    NettyServerBuilder serverBuilder = NettyServerBuilder.forAddress(new InetSocketAddress(hostName, 0)).executor(CommonUtil.getGrpcExecutor(threadCount)).maxInboundMessageSize(Constants.MAXGRAPH_RPC_MAX_MESSAGE_SIZE);
    Server rpcServer = serverBuilder.build().start();
    this.endpoint = new Endpoint(hostName, rpcServer.getPort(), gremlinServerPort);
    LOG.info("frontend host: {}, port: {}, gremlin server port:{}", endpoint.getIp(), endpoint.getPort(), gremlinServerPort);
}
Also used : NettyServerBuilder(io.grpc.netty.NettyServerBuilder) Server(io.grpc.Server) MaxGraphServer(com.alibaba.maxgraph.server.MaxGraphServer) Endpoint(com.alibaba.maxgraph.sdkcommon.client.Endpoint) InetSocketAddress(java.net.InetSocketAddress) Endpoint(com.alibaba.maxgraph.sdkcommon.client.Endpoint)

Example 12 with Endpoint

use of com.alibaba.maxgraph.sdkcommon.client.Endpoint in project GraphScope by alibaba.

the class RemoteGraph method refresh.

@Override
public void refresh() throws Exception {
    InstanceStatus serverStatuses = clientManager.getServerDataApiClient().getServerStatuses();
    List<RemoteProxy> proxys = new ArrayList<>(serverStatuses.server2WorkerInfo.size());
    Set<WorkerInfo> workerInfoSet = new TreeSet<>(serverStatuses.getWorkInfo(RoleType.EXECUTOR));
    for (WorkerInfo v : workerInfoSet) {
        if (serverStatuses.assignments.containsKey(v.id)) {
            ServerAssignment serverAssignment = serverStatuses.readServerAssignment(v.id);
            serverAssignment.getPartitions().forEach(p -> partitionDistri.put(p, v.id));
            proxys.add(new RemoteProxy(v.endpoint.getIp(), v.endpoint.getPort(), 120L, schemaFetcher, this));
        }
    }
    List<Endpoint> endpointList = workerInfoSet.stream().map(workerInfo -> workerInfo.endpoint).collect(toList());
    LOG.info("proxys: {}", JSON.toJson(endpointList));
    List<RemoteProxy> prevProxyList = this.proxys;
    this.proxys = proxys;
    try {
        for (RemoteProxy remoteProxy : prevProxyList) {
            remoteProxy.close();
        }
    } finally {
        LOG.info("Close all previous remote proxy");
    }
    // TODO : dynamic configuration of different Graph Partitioner;
    this.partitioner = new DefaultGraphPartitioner(schemaFetcher.getPartitionNum());
}
Also used : GraphSchema(com.alibaba.maxgraph.compiler.api.schema.GraphSchema) java.util(java.util) ElementId(com.alibaba.maxgraph.sdkcommon.graph.ElementId) CompositeId(com.alibaba.maxgraph.sdkcommon.graph.CompositeId) LoggerFactory(org.slf4j.LoggerFactory) DefaultGraphPartitioner(com.alibaba.maxgraph.structure.DefaultGraphPartitioner) GraphPartitioner(com.alibaba.maxgraph.structure.GraphPartitioner) Edge(com.alibaba.maxgraph.structure.Edge) ServerAssignment(com.alibaba.maxgraph.common.ServerAssignment) Vertex(com.alibaba.maxgraph.structure.Vertex) Lists(com.google.common.collect.Lists) Pair(org.apache.commons.lang3.tuple.Pair) IteratorList(com.alibaba.maxgraph.iterator.IteratorList) WorkerInfo(com.alibaba.maxgraph.common.client.WorkerInfo) IteratorUtils(org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils) JSON(com.alibaba.maxgraph.sdkcommon.util.JSON) Triple(org.apache.commons.lang3.tuple.Triple) IdManager(com.alibaba.maxgraph.structure.IdManager) Logger(org.slf4j.Logger) SchemaFetcher(com.alibaba.maxgraph.compiler.api.schema.SchemaFetcher) InstanceStatus(com.alibaba.maxgraph.common.InstanceStatus) InstanceConfig(com.alibaba.maxgraph.common.cluster.InstanceConfig) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) RoleType(com.alibaba.maxgraph.proto.RoleType) MaxGraph(com.alibaba.maxgraph.structure.graph.MaxGraph) Maps(com.google.common.collect.Maps) Sets(com.google.common.collect.Sets) Direction(org.apache.tinkerpop.gremlin.structure.Direction) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Endpoint(com.alibaba.maxgraph.sdkcommon.client.Endpoint) Endpoint(com.alibaba.maxgraph.sdkcommon.client.Endpoint) InstanceStatus(com.alibaba.maxgraph.common.InstanceStatus) WorkerInfo(com.alibaba.maxgraph.common.client.WorkerInfo) DefaultGraphPartitioner(com.alibaba.maxgraph.structure.DefaultGraphPartitioner) ServerAssignment(com.alibaba.maxgraph.common.ServerAssignment)

Example 13 with Endpoint

use of com.alibaba.maxgraph.sdkcommon.client.Endpoint in project GraphScope by alibaba.

the class ServerDataApiClient method doRefresh.

@Override
protected void doRefresh() throws Exception {
    closeChannel();
    Endpoint endpoint = namingProxy.getCoordinatorEndpoint();
    if (endpoint == null) {
        throw new RuntimeException("graphName: " + graphName + " with zk:" + this.zkUtils.getZkUrl() + " has no " + "valid endpoint");
    }
    channel.set(RpcUtils.createChannel(endpoint.getIp(), endpoint.getPort()));
    serverStub.set(ServerDataApiGrpc.newBlockingStub(channel.get()));
    LOG.info("graph: {}, init server data api client, endpoint: {}", graphName, endpoint);
}
Also used : StatusRuntimeException(io.grpc.StatusRuntimeException) Endpoint(com.alibaba.maxgraph.sdkcommon.client.Endpoint)

Example 14 with Endpoint

use of com.alibaba.maxgraph.sdkcommon.client.Endpoint in project GraphScope by alibaba.

the class InstanceInfo method updateExecutorRuntimeEnv.

public List<String> updateExecutorRuntimeEnv(int serverId, String ip, int port) {
    // TODO : Avoid to use a mutex write lock to guard a concurrent hash map ???.
    try (LockWrapper ignore = lock.openWriteLock()) {
        if (server2WorkerInfo.containsKey(serverId)) {
            server2WorkerInfo.get(serverId).endpoint.setRuntimePort(port);
            server2WorkerInfo.get(serverId).endpoint.updateIp(ip);
        } else {
            Endpoint endpoint = new Endpoint(ip, -1);
            endpoint.setRuntimePort(port);
            server2WorkerInfo.put(serverId, new WorkerInfo(serverId, endpoint, RoleType.EXECUTOR, WorkerStatus.RUNNING, StringUtils.EMPTY, System.currentTimeMillis()));
        }
    }
    return getRuntimeEnv();
}
Also used : Endpoint(com.alibaba.maxgraph.sdkcommon.client.Endpoint) WorkerInfo(com.alibaba.maxgraph.common.client.WorkerInfo) LockWrapper(com.alibaba.maxgraph.common.lock.LockWrapper)

Example 15 with Endpoint

use of com.alibaba.maxgraph.sdkcommon.client.Endpoint in project GraphScope by alibaba.

the class ServerDataApiServer method resendRequest.

void resendRequest(ServerHBReq request) throws Exception {
    StoreStatus status = request.getStatus();
    if (status == StoreStatus.INITIALING) {
        LOG.debug("ignore initialing node");
        return;
    }
    long heartbeatTime = System.currentTimeMillis();
    int serverID = request.getId();
    int nodeId = serverID - 1;
    EndpointProto endpoint = request.getEndpoint();
    NodeInfo nodeInfo = NodeInfo.newBuilder().setNodeId(NodeID.newBuilder().setRole(RoleType.STORE_NODE).setId(nodeId)).setHost(endpoint.getHost()).setPort(endpoint.getPort()).build();
    NodeStateProto.Builder nodeStateBuilder = NodeStateProto.newBuilder();
    for (Integer partition : serverDataManager.partitionManager.getServerAssignment(serverID).getPartitions()) {
        nodeStateBuilder.putNodeStateMap(partition, StateList.newBuilder().addStates(ShardState.ONLINING_VALUE).build());
    }
    NodeStateProto nodeState = nodeStateBuilder.build();
    masterService.updateNodeState(nodeInfo, heartbeatTime, nodeState);
}
Also used : Endpoint(com.alibaba.maxgraph.sdkcommon.client.Endpoint)

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