Search in sources :

Example 1 with Configs

use of com.alibaba.maxgraph.common.config.Configs in project GraphScope by alibaba.

the class MaxNode method main.

public static void main(String[] args) throws Exception {
    String configFile = System.getProperty("config.file");
    Configs conf = new Configs(configFile);
    MaxNode maxNode = new MaxNode(conf);
    NodeLauncher nodeLauncher = new NodeLauncher(maxNode);
    nodeLauncher.start();
}
Also used : Configs(com.alibaba.maxgraph.common.config.Configs)

Example 2 with Configs

use of com.alibaba.maxgraph.common.config.Configs in project GraphScope by alibaba.

the class ExecutorService method start.

public void start() {
    logger.info("Start to launch executor service");
    int nodeCount = CommonConfig.STORE_NODE_COUNT.get(this.configs);
    int workerPerProcess = ExecutorConfig.EXECUTOR_WORKER_PER_PROCESS.get(this.configs);
    Configs executorConfig = Configs.newBuilder().put("node.idx", String.valueOf(CommonConfig.NODE_IDX.get(configs))).put("graph.name", CommonConfig.GRAPH_NAME.get(configs)).put("partition.count", String.valueOf(CommonConfig.PARTITION_COUNT.get(configs))).put("graph.port", String.valueOf(StoreConfig.EXECUTOR_GRAPH_PORT.get(configs))).put("query.port", String.valueOf(StoreConfig.EXECUTOR_QUERY_PORT.get(configs))).put("engine.port", String.valueOf(StoreConfig.EXECUTOR_ENGINE_PORT.get(configs))).put("worker.per.process", String.valueOf(workerPerProcess)).put("worker.num", String.valueOf(nodeCount)).build();
    byte[] configBytes = executorConfig.toProto().toByteArray();
    logger.info("Start to open executor server");
    Pointer pointer = ExecutorLibrary.INSTANCE.openExecutorServer(configBytes, configBytes.length);
    // Add graph store with partition id to executor
    Map<Integer, GraphPartition> idToPartition = this.storeService.getIdToPartition();
    logger.info("Get partition count " + idToPartition.size() + " for current store node");
    for (Map.Entry<Integer, GraphPartition> partition : idToPartition.entrySet()) {
        int partitionId = partition.getKey();
        GraphPartition graphStore = partition.getValue();
        if (graphStore instanceof JnaGraphStore) {
            JnaGraphStore jnaGraphStore = (JnaGraphStore) graphStore;
            ExecutorLibrary.INSTANCE.addGraphPartition(pointer, partitionId, jnaGraphStore.getPointer());
            logger.info("Add partition " + partitionId);
        }
    }
    // Assign partition id to each worker id
    for (int i = 0; i < nodeCount; i++) {
        List<Integer> partitionIdList = metaService.getPartitionsByStoreId(i);
        logger.info("Get partition id list " + partitionIdList + " for store index " + i);
        partitionIdList.sort(Integer::compareTo);
        for (int k = 0; k < partitionIdList.size(); k++) {
            int partitionId = partitionIdList.get(k);
            int innnerIndex = k % workerPerProcess;
            int workerId = (i * workerPerProcess) + innnerIndex;
            logger.info("Add partition->worker mapping " + partitionId + "->" + workerId);
            ExecutorLibrary.INSTANCE.addPartitionWorkerMapping(pointer, partitionId, workerId);
        }
    }
    this.executorManager.initialExecutor(pointer, nodeCount);
    this.executorManager.startEngineServer();
    this.executorManager.startRpcServer();
    this.executorManager.getDiscoveryManager().getEngineServerDiscovery().addListener(new EngineServerListener(this.executorManager));
    while (!this.executorManager.checkEngineServersConnect()) {
        try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        logger.info("Wait all the engine server to build connection with each other");
    }
    logger.info("All engine server build connection with each success");
}
Also used : GraphPartition(com.alibaba.graphscope.groot.store.GraphPartition) Pointer(com.sun.jna.Pointer) JnaGraphStore(com.alibaba.graphscope.groot.store.jna.JnaGraphStore) Configs(com.alibaba.maxgraph.common.config.Configs) Map(java.util.Map)

Example 3 with Configs

use of com.alibaba.maxgraph.common.config.Configs in project GraphScope by alibaba.

the class Ingestor method main.

public static void main(String[] args) throws IOException {
    String configFile = System.getProperty("config.file");
    Configs conf = new Configs(configFile);
    Ingestor ingestor = new Ingestor(conf);
    NodeLauncher nodeLauncher = new NodeLauncher(ingestor);
    nodeLauncher.start();
}
Also used : Configs(com.alibaba.maxgraph.common.config.Configs)

Example 4 with Configs

use of com.alibaba.maxgraph.common.config.Configs in project GraphScope by alibaba.

the class MaxGraph method main.

public static void main(String[] args) throws IOException {
    String configFile = System.getProperty("config.file");
    Configs conf = new Configs(configFile);
    NodeBase node;
    if (args.length == 0) {
        logger.warn("No role type, use MaxNode");
        try {
            node = new MaxNode(conf);
        } catch (Exception e) {
            throw new MaxGraphException(e);
        }
    } else {
        String roleName = args[0];
        if (roleName.equalsIgnoreCase("store-gaia") || roleName.equalsIgnoreCase("frontend-gaia")) {
            conf = Configs.newBuilder(conf).put(CommonConfig.ENGINE_TYPE.getKey(), "gaia").build();
        }
        RoleType roleType = RoleType.fromName(roleName);
        switch(roleType) {
            case FRONTEND:
                node = new Frontend(conf);
                break;
            case INGESTOR:
                node = new Ingestor(conf);
                break;
            case STORE:
                node = new Store(conf);
                break;
            case COORDINATOR:
                node = new Coordinator(conf);
                break;
            default:
                throw new IllegalArgumentException("invalid roleType [" + roleType + "]");
        }
    }
    new NodeLauncher(node).start();
    logger.info("node started. [" + node.getName() + "]");
}
Also used : RoleType(com.alibaba.maxgraph.common.RoleType) MaxGraphException(com.alibaba.maxgraph.compiler.api.exception.MaxGraphException) MaxGraphException(com.alibaba.maxgraph.compiler.api.exception.MaxGraphException) IOException(java.io.IOException) Configs(com.alibaba.maxgraph.common.config.Configs)

Example 5 with Configs

use of com.alibaba.maxgraph.common.config.Configs in project GraphScope by alibaba.

the class ZkMetaStoreTest method testMetaStore.

@Test
void testMetaStore() throws Exception {
    try (TestingServer testingServer = new TestingServer(-1)) {
        int zkPort = testingServer.getPort();
        Configs configs = Configs.newBuilder().put(ZkConfig.ZK_CONNECT_STRING.getKey(), "localhost:" + zkPort).put(ZkConfig.ZK_BASE_PATH.getKey(), "test_meta_store").build();
        CuratorFramework curator = CuratorUtils.makeCurator(configs);
        curator.start();
        MetaStore metaStore = new ZkMetaStore(configs, curator);
        String path = "test_path";
        String data = "test_data";
        assertFalse(metaStore.exists(path));
        metaStore.write(path, data.getBytes());
        assertTrue(metaStore.exists(path));
        assertEquals(new String(metaStore.read(path)), data);
        metaStore.delete(path);
        assertFalse(metaStore.exists(path));
        curator.close();
    }
}
Also used : TestingServer(org.apache.curator.test.TestingServer) ZkMetaStore(com.alibaba.graphscope.groot.coordinator.ZkMetaStore) MetaStore(com.alibaba.graphscope.groot.meta.MetaStore) CuratorFramework(org.apache.curator.framework.CuratorFramework) Configs(com.alibaba.maxgraph.common.config.Configs) ZkMetaStore(com.alibaba.graphscope.groot.coordinator.ZkMetaStore) Test(org.junit.jupiter.api.Test)

Aggregations

Configs (com.alibaba.maxgraph.common.config.Configs)33 Test (org.junit.jupiter.api.Test)22 MetaService (com.alibaba.graphscope.groot.meta.MetaService)7 LogService (com.alibaba.graphscope.groot.wal.LogService)7 MetricsCollector (com.alibaba.graphscope.groot.metrics.MetricsCollector)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 LocalNodeProvider (com.alibaba.graphscope.groot.discovery.LocalNodeProvider)4 StoreDataBatch (com.alibaba.graphscope.groot.operation.StoreDataBatch)4 MetaStore (com.alibaba.graphscope.groot.meta.MetaStore)3 OperationBatch (com.alibaba.graphscope.groot.operation.OperationBatch)3 GraphPartition (com.alibaba.graphscope.groot.store.GraphPartition)3 StoreService (com.alibaba.graphscope.groot.store.StoreService)3 KafkaLogService (com.alibaba.graphscope.groot.wal.kafka.KafkaLogService)3 RoleType (com.alibaba.maxgraph.common.RoleType)3 CuratorFramework (org.apache.curator.framework.CuratorFramework)3 TestingServer (org.apache.curator.test.TestingServer)3 IngestorWriteSnapshotIdNotifier (com.alibaba.graphscope.groot.coordinator.IngestorWriteSnapshotIdNotifier)2 SnapshotManager (com.alibaba.graphscope.groot.coordinator.SnapshotManager)2 MaxGraphNode (com.alibaba.graphscope.groot.discovery.MaxGraphNode)2 NodeDiscovery (com.alibaba.graphscope.groot.discovery.NodeDiscovery)2