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);
}
Aggregations