Search in sources :

Example 1 with LocalNodeProvider

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

the class Frontend method buildServiceServer.

private RpcServer buildServiceServer(Configs configs, BindableService... services) {
    int port = FrontendConfig.FRONTEND_SERVICE_PORT.get(configs);
    int threadCount = FrontendConfig.FRONTEND_SERVICE_THREAD_COUNT.get(configs);
    int maxBytes = CommonConfig.RPC_MAX_BYTES_MB.get(configs) * 1024 * 1024;
    NettyServerBuilder builder = NettyServerBuilder.forPort(port);
    builder.executor(RpcUtils.createGrpcExecutor(threadCount)).maxInboundMessageSize(maxBytes);
    String username = FrontendConfig.AUTH_USERNAME.get(configs);
    String password = FrontendConfig.AUTH_PASSWORD.get(configs);
    if (!username.isEmpty()) {
        AuthorizationServerInterceptor interceptor = new AuthorizationServerInterceptor(Collections.singletonMap(username, password));
        builder.intercept(interceptor);
    }
    LocalNodeProvider lnp = new LocalNodeProvider(RoleType.FRONTEND_SERVICE, configs);
    return new RpcServer(builder, lnp, services);
}
Also used : LocalNodeProvider(com.alibaba.graphscope.groot.discovery.LocalNodeProvider) NettyServerBuilder(io.grpc.netty.NettyServerBuilder) RpcServer(com.alibaba.graphscope.groot.rpc.RpcServer) AuthorizationServerInterceptor(com.alibaba.graphscope.groot.rpc.AuthorizationServerInterceptor)

Example 2 with LocalNodeProvider

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

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

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

the class ExecutorDiscoveryManagerTest method testExecutorServerStart.

@Test
void testExecutorServerStart() 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_discovery").build();
        CuratorFramework curator = CuratorUtils.makeCurator(configs);
        curator.start();
        LocalNodeProvider engineServerProvider = new LocalNodeProvider(RoleType.EXECUTOR_ENGINE, configs);
        NodeDiscovery engineServerDiscovery = new ZkDiscovery(configs, engineServerProvider, curator);
        LocalNodeProvider storeQueryProvider = new LocalNodeProvider(RoleType.EXECUTOR_GRAPH, configs);
        NodeDiscovery storeQueryDiscovery = new ZkDiscovery(configs, storeQueryProvider, curator);
        LocalNodeProvider queryExecuteProvider = new LocalNodeProvider(RoleType.EXECUTOR_QUERY, configs);
        NodeDiscovery queryExecuteDiscovery = new ZkDiscovery(configs, queryExecuteProvider, curator);
        LocalNodeProvider queryManageProvider = new LocalNodeProvider(RoleType.EXECUTOR_MANAGE, configs);
        NodeDiscovery queryManageDiscovery = new ZkDiscovery(configs, queryManageProvider, curator);
        ExecutorDiscoveryManager executorDiscoveryManager = new ExecutorDiscoveryManager(engineServerProvider, engineServerDiscovery, storeQueryProvider, storeQueryDiscovery, queryExecuteProvider, queryExecuteDiscovery, queryManageProvider, queryManageDiscovery);
        executorDiscoveryManager.getEngineServerProvider().apply(123);
        executorDiscoveryManager.getEngineServerDiscovery().start();
        executorDiscoveryManager.getQueryExecuteProvider().apply(1234);
        executorDiscoveryManager.getQueryExecuteDiscovery().start();
    }
}
Also used : TestingServer(org.apache.curator.test.TestingServer) LocalNodeProvider(com.alibaba.graphscope.groot.discovery.LocalNodeProvider) CuratorFramework(org.apache.curator.framework.CuratorFramework) NodeDiscovery(com.alibaba.graphscope.groot.discovery.NodeDiscovery) ExecutorDiscoveryManager(com.alibaba.maxgraph.servers.maxgraph.ExecutorDiscoveryManager) Configs(com.alibaba.maxgraph.common.config.Configs) ZkDiscovery(com.alibaba.graphscope.groot.discovery.ZkDiscovery) Test(org.junit.jupiter.api.Test)

Example 5 with LocalNodeProvider

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

the class ZkDiscoveryTest method createNodeDiscovery.

private NodeDiscovery createNodeDiscovery(RoleType role, int idx, int port, Configs zkConfigs, CuratorFramework curator) {
    Configs nodeConfigs = Configs.newBuilder().put(CommonConfig.ROLE_NAME.getKey(), role.getName()).put(CommonConfig.NODE_IDX.getKey(), String.valueOf(idx)).build();
    LocalNodeProvider localNodeProvider = new LocalNodeProvider(nodeConfigs);
    localNodeProvider.apply(port);
    return new ZkDiscovery(zkConfigs, localNodeProvider, curator);
}
Also used : LocalNodeProvider(com.alibaba.graphscope.groot.discovery.LocalNodeProvider) Configs(com.alibaba.maxgraph.common.config.Configs) ZkDiscovery(com.alibaba.graphscope.groot.discovery.ZkDiscovery)

Aggregations

LocalNodeProvider (com.alibaba.graphscope.groot.discovery.LocalNodeProvider)5 Configs (com.alibaba.maxgraph.common.config.Configs)4 Test (org.junit.jupiter.api.Test)3 MaxGraphNode (com.alibaba.graphscope.groot.discovery.MaxGraphNode)2 ZkDiscovery (com.alibaba.graphscope.groot.discovery.ZkDiscovery)2 RpcServer (com.alibaba.graphscope.groot.rpc.RpcServer)2 NodeDiscovery (com.alibaba.graphscope.groot.discovery.NodeDiscovery)1 AuthorizationServerInterceptor (com.alibaba.graphscope.groot.rpc.AuthorizationServerInterceptor)1 RoleType (com.alibaba.maxgraph.common.RoleType)1 ExecutorDiscoveryManager (com.alibaba.maxgraph.servers.maxgraph.ExecutorDiscoveryManager)1 NettyServerBuilder (io.grpc.netty.NettyServerBuilder)1 CuratorFramework (org.apache.curator.framework.CuratorFramework)1 TestingServer (org.apache.curator.test.TestingServer)1