Search in sources :

Example 1 with InstanceStatus

use of com.alibaba.maxgraph.common.InstanceStatus 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)

Aggregations

InstanceStatus (com.alibaba.maxgraph.common.InstanceStatus)1 ServerAssignment (com.alibaba.maxgraph.common.ServerAssignment)1 WorkerInfo (com.alibaba.maxgraph.common.client.WorkerInfo)1 InstanceConfig (com.alibaba.maxgraph.common.cluster.InstanceConfig)1 GraphSchema (com.alibaba.maxgraph.compiler.api.schema.GraphSchema)1 SchemaFetcher (com.alibaba.maxgraph.compiler.api.schema.SchemaFetcher)1 IteratorList (com.alibaba.maxgraph.iterator.IteratorList)1 RoleType (com.alibaba.maxgraph.proto.RoleType)1 Endpoint (com.alibaba.maxgraph.sdkcommon.client.Endpoint)1 CompositeId (com.alibaba.maxgraph.sdkcommon.graph.CompositeId)1 ElementId (com.alibaba.maxgraph.sdkcommon.graph.ElementId)1 JSON (com.alibaba.maxgraph.sdkcommon.util.JSON)1 DefaultGraphPartitioner (com.alibaba.maxgraph.structure.DefaultGraphPartitioner)1 Edge (com.alibaba.maxgraph.structure.Edge)1 GraphPartitioner (com.alibaba.maxgraph.structure.GraphPartitioner)1 IdManager (com.alibaba.maxgraph.structure.IdManager)1 Vertex (com.alibaba.maxgraph.structure.Vertex)1 MaxGraph (com.alibaba.maxgraph.structure.graph.MaxGraph)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Lists (com.google.common.collect.Lists)1