Search in sources :

Example 1 with MaxGraphNode

use of com.alibaba.graphscope.groot.discovery.MaxGraphNode in project GraphScope by alibaba.

the class RpcServer method start.

public void start() throws IOException {
    server.start();
    MaxGraphNode localNode = this.localNodeProvider.apply(server.getPort());
    logger.info("RpcServer started, node [" + localNode + "]");
}
Also used : MaxGraphNode(com.alibaba.graphscope.groot.discovery.MaxGraphNode)

Example 2 with MaxGraphNode

use of com.alibaba.graphscope.groot.discovery.MaxGraphNode in project GraphScope by alibaba.

the class SnapshotNotifierTest method testSnapshotNotifier.

@Test
void testSnapshotNotifier() {
    NodeDiscovery discovery = mock(NodeDiscovery.class);
    SnapshotManager snapshotManager = mock(SnapshotManager.class);
    RoleClients<FrontendSnapshotClient> roleClients = mock(RoleClients.class);
    SnapshotNotifier snapshotNotifier = new SnapshotNotifier(discovery, snapshotManager, null, roleClients);
    snapshotNotifier.start();
    MaxGraphNode localNode = MaxGraphNode.createLocalNode(Configs.newBuilder().put(CommonConfig.ROLE_NAME.getKey(), RoleType.COORDINATOR.getName()).build(), 1111);
    snapshotNotifier.nodesJoin(RoleType.FRONTEND, Collections.singletonMap(1, localNode));
    ArgumentCaptor<NotifyFrontendListener> captor = ArgumentCaptor.forClass(NotifyFrontendListener.class);
    verify(snapshotManager).addListener(captor.capture());
    NotifyFrontendListener listener = captor.getValue();
    snapshotNotifier.nodesLeft(RoleType.FRONTEND, Collections.singletonMap(1, localNode));
    verify(snapshotManager).removeListener(listener);
}
Also used : SnapshotNotifier(com.alibaba.graphscope.groot.coordinator.SnapshotNotifier) MaxGraphNode(com.alibaba.graphscope.groot.discovery.MaxGraphNode) NotifyFrontendListener(com.alibaba.graphscope.groot.coordinator.NotifyFrontendListener) NodeDiscovery(com.alibaba.graphscope.groot.discovery.NodeDiscovery) FrontendSnapshotClient(com.alibaba.graphscope.groot.coordinator.FrontendSnapshotClient) SnapshotManager(com.alibaba.graphscope.groot.coordinator.SnapshotManager) Test(org.junit.jupiter.api.Test)

Example 3 with MaxGraphNode

use of com.alibaba.graphscope.groot.discovery.MaxGraphNode 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 4 with MaxGraphNode

use of com.alibaba.graphscope.groot.discovery.MaxGraphNode 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)

Example 5 with MaxGraphNode

use of com.alibaba.graphscope.groot.discovery.MaxGraphNode in project GraphScope by alibaba.

the class NodeNameResolver method nodesLeft.

@Override
public void nodesLeft(RoleType role, Map<Integer, MaxGraphNode> nodes) {
    if (role == this.roleType) {
        MaxGraphNode lostNode = nodes.get(this.idx);
        if (lostNode != null) {
            logger.info("connection lost. node [" + lostNode + "]");
            this.listener.onResult(ResolutionResult.newBuilder().build());
        }
    }
}
Also used : MaxGraphNode(com.alibaba.graphscope.groot.discovery.MaxGraphNode)

Aggregations

MaxGraphNode (com.alibaba.graphscope.groot.discovery.MaxGraphNode)6 Test (org.junit.jupiter.api.Test)3 LocalNodeProvider (com.alibaba.graphscope.groot.discovery.LocalNodeProvider)2 Configs (com.alibaba.maxgraph.common.config.Configs)2 FrontendSnapshotClient (com.alibaba.graphscope.groot.coordinator.FrontendSnapshotClient)1 NotifyFrontendListener (com.alibaba.graphscope.groot.coordinator.NotifyFrontendListener)1 SnapshotManager (com.alibaba.graphscope.groot.coordinator.SnapshotManager)1 SnapshotNotifier (com.alibaba.graphscope.groot.coordinator.SnapshotNotifier)1 NodeDiscovery (com.alibaba.graphscope.groot.discovery.NodeDiscovery)1 RpcServer (com.alibaba.graphscope.groot.rpc.RpcServer)1 RoleType (com.alibaba.maxgraph.common.RoleType)1 EquivalentAddressGroup (io.grpc.EquivalentAddressGroup)1 InetSocketAddress (java.net.InetSocketAddress)1