Search in sources :

Example 11 with Configs

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

the class RoleClientsTest method testRoleClients.

@Test
void testRoleClients() {
    Configs configs = Configs.newBuilder().put(CommonConfig.STORE_NODE_COUNT.getKey(), "1").put(CommonConfig.DISCOVERY_MODE.getKey(), "zookeeper").build();
    ChannelManager channelManager = new ChannelManager(configs, new MockFactory());
    RoleClients<MockRoleClient> clients = new RoleClients<>(channelManager, RoleType.STORE, MockRoleClient::new);
    channelManager.start();
    assertNotNull(clients.getClient(0));
    assertThrows(NodeConnectException.class, () -> clients.getClient(1));
    channelManager.stop();
}
Also used : RoleClients(com.alibaba.graphscope.groot.rpc.RoleClients) ChannelManager(com.alibaba.graphscope.groot.rpc.ChannelManager) Configs(com.alibaba.maxgraph.common.config.Configs) MockFactory(com.alibaba.maxgraph.tests.common.rpc.MockFactory) Test(org.junit.jupiter.api.Test)

Example 12 with Configs

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

the class LocalNodeProviderTest method testProvider.

@Test
void testProvider() {
    RoleType role = RoleType.STORE;
    int idx = 2;
    int port = 1111;
    Configs configs = Configs.newBuilder().put("role.name", role.getName()).put("node.idx", String.valueOf(idx)).put("discovery.mode", "zookeeper").build();
    LocalNodeProvider localNodeProvider = new LocalNodeProvider(configs);
    MaxGraphNode node = localNodeProvider.apply(port);
    Assertions.assertAll(() -> assertEquals(node.getRoleName(), role.getName()), () -> assertEquals(node.getIdx(), idx), () -> assertEquals(node.getPort(), port));
    assertThrows(MaxGraphException.class, () -> localNodeProvider.apply(port));
}
Also used : LocalNodeProvider(com.alibaba.graphscope.groot.discovery.LocalNodeProvider) MaxGraphNode(com.alibaba.graphscope.groot.discovery.MaxGraphNode) RoleType(com.alibaba.maxgraph.common.RoleType) Configs(com.alibaba.maxgraph.common.config.Configs) Test(org.junit.jupiter.api.Test)

Example 13 with Configs

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

the class ZkDiscoveryTest method testDiscovery.

@Test
void testDiscovery() throws Exception {
    try (TestingServer testingServer = new TestingServer(-1)) {
        int zkPort = testingServer.getPort();
        Configs zkConfigs = Configs.newBuilder().put(ZkConfig.ZK_CONNECT_STRING.getKey(), "localhost:" + zkPort).put(ZkConfig.ZK_BASE_PATH.getKey(), "test_discovery").build();
        CuratorFramework curator = CuratorUtils.makeCurator(zkConfigs);
        curator.start();
        RoleType role = RoleType.STORE;
        NodeDiscovery discovery1 = createNodeDiscovery(role, 0, 1111, zkConfigs, curator);
        NodeDiscovery discovery2 = createNodeDiscovery(role, 1, 2222, zkConfigs, curator);
        discovery1.start();
        CountDownLatch latch1 = new CountDownLatch(1);
        CountDownLatch latch2 = new CountDownLatch(1);
        NodeDiscovery.Listener mockListener = mock(NodeDiscovery.Listener.class);
        doAnswer(invocationOnMock -> {
            latch1.countDown();
            return null;
        }).when(mockListener).nodesJoin(RoleType.STORE, Collections.singletonMap(0, discovery1.getLocalNode()));
        doAnswer(invocationOnMock -> {
            latch2.countDown();
            return null;
        }).when(mockListener).nodesJoin(RoleType.STORE, Collections.singletonMap(1, discovery2.getLocalNode()));
        discovery1.addListener(mockListener);
        assertTrue(latch1.await(5L, TimeUnit.SECONDS));
        discovery2.start();
        assertTrue(latch2.await(5L, TimeUnit.SECONDS));
        verify(mockListener, times(2)).nodesJoin(any(), any());
        verify(mockListener, never()).nodesLeft(any(), any());
        discovery2.stop();
        verify(mockListener, timeout(5000L)).nodesLeft(RoleType.STORE, Collections.singletonMap(1, discovery2.getLocalNode()));
        discovery1.stop();
        curator.close();
    }
}
Also used : TestingServer(org.apache.curator.test.TestingServer) CuratorFramework(org.apache.curator.framework.CuratorFramework) NodeDiscovery(com.alibaba.graphscope.groot.discovery.NodeDiscovery) RoleType(com.alibaba.maxgraph.common.RoleType) Configs(com.alibaba.maxgraph.common.config.Configs) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.jupiter.api.Test)

Example 14 with Configs

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

the class ChannelManagerTest method testChannelManager.

@Test
void testChannelManager() {
    Configs configs = Configs.newBuilder().put(CommonConfig.STORE_NODE_COUNT.getKey(), "1").put(CommonConfig.DISCOVERY_MODE.getKey(), "zookeeper").build();
    ChannelManager channelManager = new ChannelManager(configs, new MockFactory());
    channelManager.registerRole(RoleType.STORE);
    channelManager.start();
    Assertions.assertNotNull(channelManager.getChannel(RoleType.STORE, 0));
    Assertions.assertThrows(NodeConnectException.class, () -> channelManager.getChannel(RoleType.STORE, 1));
    channelManager.stop();
}
Also used : ChannelManager(com.alibaba.graphscope.groot.rpc.ChannelManager) Configs(com.alibaba.maxgraph.common.config.Configs) Test(org.junit.jupiter.api.Test)

Example 15 with Configs

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

the class RpcServerTest method testRpcServer.

@Test
void testRpcServer() throws IOException {
    int port = 1111;
    Configs configs = Configs.newBuilder().put(CommonConfig.RPC_PORT.getKey(), String.valueOf(port)).put(CommonConfig.ROLE_NAME.getKey(), RoleType.STORE.getName()).put(CommonConfig.NODE_IDX.getKey(), "0").build();
    LocalNodeProvider localNodeProvider = new LocalNodeProvider(configs);
    RpcServer rpcServer = new RpcServer(configs, localNodeProvider);
    rpcServer.start();
    MaxGraphNode localNode = localNodeProvider.get();
    assertEquals(port, localNode.getPort());
    assertEquals(port, rpcServer.getPort());
    rpcServer.stop();
}
Also used : LocalNodeProvider(com.alibaba.graphscope.groot.discovery.LocalNodeProvider) MaxGraphNode(com.alibaba.graphscope.groot.discovery.MaxGraphNode) RpcServer(com.alibaba.graphscope.groot.rpc.RpcServer) Configs(com.alibaba.maxgraph.common.config.Configs) 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