Search in sources :

Example 1 with AuthorizationServerInterceptor

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

Aggregations

LocalNodeProvider (com.alibaba.graphscope.groot.discovery.LocalNodeProvider)1 AuthorizationServerInterceptor (com.alibaba.graphscope.groot.rpc.AuthorizationServerInterceptor)1 RpcServer (com.alibaba.graphscope.groot.rpc.RpcServer)1 NettyServerBuilder (io.grpc.netty.NettyServerBuilder)1