Search in sources :

Example 1 with SchemaFetcher

use of com.alibaba.maxgraph.compiler.api.schema.SchemaFetcher in project GraphScope by alibaba.

the class Frontend method initAndStartGremlinServer.

@Override
protected void initAndStartGremlinServer() throws Exception {
    SchemaFetcher schemaFetcher;
    String vineyardSchemaPath = this.instanceConfig.getVineyardSchemaPath();
    logger.info("Read schema from vineyard schema file " + vineyardSchemaPath);
    schemaFetcher = new JsonFileSchemaFetcher(vineyardSchemaPath);
    this.remoteGraph = new RemoteGraph(this, schemaFetcher);
    this.remoteGraph.refresh();
    this.graph = new TinkerMaxGraph(instanceConfig, remoteGraph, new DefaultGraphDfs());
    // add gaia compiler
    AsyncRpcChannelFetcher gaiaRpcFetcher = new AddressChannelFetcher(new ExecutorAddressFetcher(this.clientManager));
    GraphStoreService gaiaStoreService = new VineyardGraphStore(schemaFetcher);
    AbstractBroadcastProcessor broadcastProcessor = new AsyncRpcBroadcastProcessor(gaiaRpcFetcher);
    gaiaGraphServer = new GaiaGraphServer(this.graph, instanceConfig, gaiaStoreService, broadcastProcessor, new VineyardConfig(instanceConfig));
    gaiaGraphServer.start(0, null, false);
    this.gremlinServerPort = gaiaGraphServer.getGremlinServerPort();
}
Also used : SchemaFetcher(com.alibaba.maxgraph.compiler.api.schema.SchemaFetcher) JsonFileSchemaFetcher(com.alibaba.maxgraph.compiler.schema.JsonFileSchemaFetcher) RemoteGraph(com.alibaba.maxgraph.frontendservice.RemoteGraph) AbstractBroadcastProcessor(com.alibaba.graphscope.gaia.broadcast.AbstractBroadcastProcessor) AsyncRpcChannelFetcher(com.alibaba.graphscope.gaia.broadcast.channel.AsyncRpcChannelFetcher) ExecutorAddressFetcher(com.alibaba.maxgraph.frontendservice.server.ExecutorAddressFetcher) DefaultGraphDfs(com.alibaba.maxgraph.compiler.dfs.DefaultGraphDfs) AsyncRpcBroadcastProcessor(com.alibaba.graphscope.gaia.broadcast.AsyncRpcBroadcastProcessor) JsonFileSchemaFetcher(com.alibaba.maxgraph.compiler.schema.JsonFileSchemaFetcher) TinkerMaxGraph(com.alibaba.maxgraph.structure.graph.TinkerMaxGraph) GraphStoreService(com.alibaba.graphscope.gaia.store.GraphStoreService)

Example 2 with SchemaFetcher

use of com.alibaba.maxgraph.compiler.api.schema.SchemaFetcher in project GraphScope by alibaba.

the class Frontend method initAndStartGremlinServer.

protected void initAndStartGremlinServer() throws Exception {
    SchemaFetcher schemaFetcher;
    String vineyardSchemaPath = this.instanceConfig.getVineyardSchemaPath();
    LOG.info("Read schema from vineyard schema file " + vineyardSchemaPath);
    schemaFetcher = new JsonFileSchemaFetcher(vineyardSchemaPath);
    this.remoteGraph = new RemoteGraph(this, schemaFetcher);
    this.remoteGraph.refresh();
    this.graph = new TinkerMaxGraph(instanceConfig, remoteGraph, new DefaultGraphDfs());
    this.graphGremlinServer = new MaxGraphServer(this.graph);
    int tmpGremlinServerPort = instanceConfig.getGremlinServerPort() > 0 ? instanceConfig.getGremlinServerPort() : 0;
    ProcessorLoader processorLoader;
    switch(instanceConfig.getGremlinServerMode()) {
        case TIMELY:
        case MIXED:
            {
                processorLoader = MixedProcessorLoader.newProcessorLoader(graph, this.instanceConfig, new ExecutorAddressFetcher(clientManager), schemaFetcher, new ZKStatementStore(instanceConfig), new MaxGraphRecordProcessorManager(this.graph, this), this.getFrontendQueryManager());
                break;
            }
        default:
            {
                processorLoader = GremlinProcessorLoader.newProcessorLoader();
                break;
            }
    }
    this.graphGremlinServer.start(tmpGremlinServerPort, processorLoader, instanceConfig.getInstanceAuthType() == 1);
    this.gremlinServerPort = tmpGremlinServerPort > 0 ? tmpGremlinServerPort : this.graphGremlinServer.getGremlinServerPort();
    LOG.info("gremlin server port:{}", this.gremlinServerPort);
}
Also used : ZKStatementStore(com.alibaba.maxgraph.frontendservice.query.ZKStatementStore) JsonFileSchemaFetcher(com.alibaba.maxgraph.compiler.schema.JsonFileSchemaFetcher) SchemaFetcher(com.alibaba.maxgraph.compiler.api.schema.SchemaFetcher) JsonFileSchemaFetcher(com.alibaba.maxgraph.compiler.schema.JsonFileSchemaFetcher) TinkerMaxGraph(com.alibaba.maxgraph.structure.graph.TinkerMaxGraph) MixedProcessorLoader(com.alibaba.maxgraph.server.processor.MixedProcessorLoader) GremlinProcessorLoader(com.alibaba.maxgraph.server.GremlinProcessorLoader) ProcessorLoader(com.alibaba.maxgraph.server.ProcessorLoader) MaxGraphRecordProcessorManager(com.alibaba.maxgraph.frontendservice.server.manager.MaxGraphRecordProcessorManager) ExecutorAddressFetcher(com.alibaba.maxgraph.frontendservice.server.ExecutorAddressFetcher) MaxGraphServer(com.alibaba.maxgraph.server.MaxGraphServer) Endpoint(com.alibaba.maxgraph.sdkcommon.client.Endpoint) DefaultGraphDfs(com.alibaba.maxgraph.compiler.dfs.DefaultGraphDfs)

Example 3 with SchemaFetcher

use of com.alibaba.maxgraph.compiler.api.schema.SchemaFetcher in project GraphScope by alibaba.

the class Frontend method initAndStartGremlinServer.

@Override
protected void initAndStartGremlinServer() throws Exception {
    SchemaFetcher schemaFetcher;
    String vineyardSchemaPath = this.instanceConfig.getVineyardSchemaPath();
    logger.info("Read schema from vineyard schema file " + vineyardSchemaPath);
    schemaFetcher = new JsonFileSchemaFetcher(vineyardSchemaPath);
    this.remoteGraph = new RemoteGraph(this, schemaFetcher);
    this.remoteGraph.refresh();
    this.graph = new TinkerMaxGraph(instanceConfig, remoteGraph, new DefaultGraphDfs());
    // add ir compiler
    Configs configs = getConfigs(this.instanceConfig);
    IrMetaFetcher irMetaFetcher = getStoreConfigs(this.instanceConfig);
    RpcAddressFetcher addressFetcher = new ExecutorAddressFetcher(this.clientManager);
    RpcChannelFetcher channelFetcher = new RpcAddressChannelFetcher(addressFetcher);
    this.gremlinServer = new IrGremlinServer(this.instanceConfig.getGremlinServerPort());
    this.gremlinServer.start(configs, irMetaFetcher, channelFetcher, new IrMetaQueryCallback(irMetaFetcher), TestGraphFactory.VINEYARD);
    this.gremlinServerPort = gremlinServer.getGremlinServerPort();
}
Also used : SchemaFetcher(com.alibaba.maxgraph.compiler.api.schema.SchemaFetcher) JsonFileSchemaFetcher(com.alibaba.maxgraph.compiler.schema.JsonFileSchemaFetcher) RemoteGraph(com.alibaba.maxgraph.frontendservice.RemoteGraph) ExecutorAddressFetcher(com.alibaba.maxgraph.frontendservice.server.ExecutorAddressFetcher) IrGremlinServer(com.alibaba.graphscope.gremlin.service.IrGremlinServer) DefaultGraphDfs(com.alibaba.maxgraph.compiler.dfs.DefaultGraphDfs) RpcChannelFetcher(com.alibaba.graphscope.common.client.RpcChannelFetcher) JsonFileSchemaFetcher(com.alibaba.maxgraph.compiler.schema.JsonFileSchemaFetcher) RpcAddressFetcher(com.alibaba.maxgraph.common.rpc.RpcAddressFetcher) TinkerMaxGraph(com.alibaba.maxgraph.structure.graph.TinkerMaxGraph) IrMetaFetcher(com.alibaba.graphscope.common.store.IrMetaFetcher) IrMetaQueryCallback(com.alibaba.graphscope.common.manager.IrMetaQueryCallback) Configs(com.alibaba.graphscope.common.config.Configs)

Example 4 with SchemaFetcher

use of com.alibaba.maxgraph.compiler.api.schema.SchemaFetcher 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

SchemaFetcher (com.alibaba.maxgraph.compiler.api.schema.SchemaFetcher)4 DefaultGraphDfs (com.alibaba.maxgraph.compiler.dfs.DefaultGraphDfs)3 JsonFileSchemaFetcher (com.alibaba.maxgraph.compiler.schema.JsonFileSchemaFetcher)3 ExecutorAddressFetcher (com.alibaba.maxgraph.frontendservice.server.ExecutorAddressFetcher)3 TinkerMaxGraph (com.alibaba.maxgraph.structure.graph.TinkerMaxGraph)3 RemoteGraph (com.alibaba.maxgraph.frontendservice.RemoteGraph)2 Endpoint (com.alibaba.maxgraph.sdkcommon.client.Endpoint)2 RpcChannelFetcher (com.alibaba.graphscope.common.client.RpcChannelFetcher)1 Configs (com.alibaba.graphscope.common.config.Configs)1 IrMetaQueryCallback (com.alibaba.graphscope.common.manager.IrMetaQueryCallback)1 IrMetaFetcher (com.alibaba.graphscope.common.store.IrMetaFetcher)1 AbstractBroadcastProcessor (com.alibaba.graphscope.gaia.broadcast.AbstractBroadcastProcessor)1 AsyncRpcBroadcastProcessor (com.alibaba.graphscope.gaia.broadcast.AsyncRpcBroadcastProcessor)1 AsyncRpcChannelFetcher (com.alibaba.graphscope.gaia.broadcast.channel.AsyncRpcChannelFetcher)1 GraphStoreService (com.alibaba.graphscope.gaia.store.GraphStoreService)1 IrGremlinServer (com.alibaba.graphscope.gremlin.service.IrGremlinServer)1 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