Search in sources :

Example 1 with RpcServer

use of com.alibaba.graphscope.groot.rpc.RpcServer 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 RpcServer

use of com.alibaba.graphscope.groot.rpc.RpcServer 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

LocalNodeProvider (com.alibaba.graphscope.groot.discovery.LocalNodeProvider)2 RpcServer (com.alibaba.graphscope.groot.rpc.RpcServer)2 MaxGraphNode (com.alibaba.graphscope.groot.discovery.MaxGraphNode)1 AuthorizationServerInterceptor (com.alibaba.graphscope.groot.rpc.AuthorizationServerInterceptor)1 Configs (com.alibaba.maxgraph.common.config.Configs)1 NettyServerBuilder (io.grpc.netty.NettyServerBuilder)1 Test (org.junit.jupiter.api.Test)1