Search in sources :

Example 1 with MAX_CONCURRENT_CALLS_PER_CONNECTION

use of org.apache.dubbo.rpc.protocol.grpc.GrpcConstants.MAX_CONCURRENT_CALLS_PER_CONNECTION in project dubbo by alibaba.

the class GrpcOptionsUtils method buildServerBuilder.

static ServerBuilder buildServerBuilder(URL url, NettyServerBuilder builder) {
    int maxInboundMessageSize = url.getParameter(MAX_INBOUND_MESSAGE_SIZE, 0);
    if (maxInboundMessageSize > 0) {
        builder.maxInboundMessageSize(maxInboundMessageSize);
    }
    int maxInboundMetadataSize = url.getParameter(MAX_INBOUND_METADATA_SIZE, 0);
    if (maxInboundMetadataSize > 0) {
        builder.maxInboundMetadataSize(maxInboundMetadataSize);
    }
    if (url.getParameter(SSL_ENABLED_KEY, false)) {
        builder.sslContext(buildServerSslContext(url));
    }
    int flowControlWindow = url.getParameter(MAX_INBOUND_MESSAGE_SIZE, 0);
    if (flowControlWindow > 0) {
        builder.flowControlWindow(flowControlWindow);
    }
    int maxCalls = url.getParameter(MAX_CONCURRENT_CALLS_PER_CONNECTION, url.getParameter(EXECUTES_KEY, 0));
    if (maxCalls > 0) {
        builder.maxConcurrentCallsPerConnection(maxCalls);
    }
    // server interceptors
    List<ServerInterceptor> serverInterceptors = ExtensionLoader.getExtensionLoader(ServerInterceptor.class).getActivateExtension(url, SERVER_INTERCEPTORS, PROVIDER_SIDE);
    for (ServerInterceptor serverInterceptor : serverInterceptors) {
        builder.intercept(serverInterceptor);
    }
    // server filters
    List<ServerTransportFilter> transportFilters = ExtensionLoader.getExtensionLoader(ServerTransportFilter.class).getActivateExtension(url, TRANSPORT_FILTERS, PROVIDER_SIDE);
    for (ServerTransportFilter transportFilter : transportFilters) {
        builder.addTransportFilter(transportFilter.grpcTransportFilter());
    }
    String thread = url.getParameter(EXECUTOR, url.getParameter(DISPATCHER_KEY));
    if ("direct".equals(thread)) {
        builder.directExecutor();
    } else {
        builder.executor(ExtensionLoader.getExtensionLoader(ThreadPool.class).getAdaptiveExtension().getExecutor(url));
    }
    // Give users the chance to customize ServerBuilder
    return getConfigurator().map(configurator -> configurator.configureServerBuilder(builder, url)).orElse(builder);
}
Also used : LoggerFactory(org.apache.dubbo.common.logger.LoggerFactory) CallOptions(io.grpc.CallOptions) ExtensionLoader(org.apache.dubbo.common.extension.ExtensionLoader) ServerInterceptor(org.apache.dubbo.rpc.protocol.grpc.interceptors.ServerInterceptor) ManagedChannel(io.grpc.ManagedChannel) SslConfig(org.apache.dubbo.config.SslConfig) NettyServerBuilder(io.grpc.netty.NettyServerBuilder) CLIENT_INTERCEPTORS(org.apache.dubbo.rpc.protocol.grpc.GrpcConstants.CLIENT_INTERCEPTORS) MAX_INBOUND_MESSAGE_SIZE(org.apache.dubbo.rpc.protocol.grpc.GrpcConstants.MAX_INBOUND_MESSAGE_SIZE) ConfigManager(org.apache.dubbo.config.context.ConfigManager) ArrayList(java.util.ArrayList) ClientAuth(io.netty.handler.ssl.ClientAuth) SERVER_INTERCEPTORS(org.apache.dubbo.rpc.protocol.grpc.GrpcConstants.SERVER_INTERCEPTORS) URL(org.apache.dubbo.common.URL) SSL_ENABLED_KEY(org.apache.dubbo.common.constants.CommonConstants.SSL_ENABLED_KEY) PROVIDER_SIDE(org.apache.dubbo.common.constants.CommonConstants.PROVIDER_SIDE) ServerBuilder(io.grpc.ServerBuilder) CONSUMER_SIDE(org.apache.dubbo.common.constants.CommonConstants.CONSUMER_SIDE) MAX_CONCURRENT_CALLS_PER_CONNECTION(org.apache.dubbo.rpc.protocol.grpc.GrpcConstants.MAX_CONCURRENT_CALLS_PER_CONNECTION) MAX_INBOUND_METADATA_SIZE(org.apache.dubbo.rpc.protocol.grpc.GrpcConstants.MAX_INBOUND_METADATA_SIZE) EXECUTOR(org.apache.dubbo.rpc.protocol.grpc.GrpcConstants.EXECUTOR) ApplicationModel(org.apache.dubbo.rpc.model.ApplicationModel) GrpcConfigurator(org.apache.dubbo.rpc.protocol.grpc.interceptors.GrpcConfigurator) SslContext(io.netty.handler.ssl.SslContext) Logger(org.apache.dubbo.common.logger.Logger) CollectionUtils(org.apache.dubbo.common.utils.CollectionUtils) ThreadPool(org.apache.dubbo.common.threadpool.ThreadPool) Set(java.util.Set) IOException(java.io.IOException) DISPATCHER_KEY(org.apache.dubbo.remoting.Constants.DISPATCHER_KEY) TRANSPORT_FILTERS(org.apache.dubbo.rpc.protocol.grpc.GrpcConstants.TRANSPORT_FILTERS) NettyChannelBuilder(io.grpc.netty.NettyChannelBuilder) SSLException(javax.net.ssl.SSLException) List(java.util.List) EXECUTES_KEY(org.apache.dubbo.rpc.Constants.EXECUTES_KEY) ServerTransportFilter(org.apache.dubbo.rpc.protocol.grpc.interceptors.ServerTransportFilter) SslContextBuilder(io.netty.handler.ssl.SslContextBuilder) Optional(java.util.Optional) ClientInterceptor(org.apache.dubbo.rpc.protocol.grpc.interceptors.ClientInterceptor) GrpcSslContexts(io.grpc.netty.GrpcSslContexts) InputStream(java.io.InputStream) ServerInterceptor(org.apache.dubbo.rpc.protocol.grpc.interceptors.ServerInterceptor) ThreadPool(org.apache.dubbo.common.threadpool.ThreadPool) ServerTransportFilter(org.apache.dubbo.rpc.protocol.grpc.interceptors.ServerTransportFilter)

Aggregations

CallOptions (io.grpc.CallOptions)1 ManagedChannel (io.grpc.ManagedChannel)1 ServerBuilder (io.grpc.ServerBuilder)1 GrpcSslContexts (io.grpc.netty.GrpcSslContexts)1 NettyChannelBuilder (io.grpc.netty.NettyChannelBuilder)1 NettyServerBuilder (io.grpc.netty.NettyServerBuilder)1 ClientAuth (io.netty.handler.ssl.ClientAuth)1 SslContext (io.netty.handler.ssl.SslContext)1 SslContextBuilder (io.netty.handler.ssl.SslContextBuilder)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Optional (java.util.Optional)1 Set (java.util.Set)1 SSLException (javax.net.ssl.SSLException)1 URL (org.apache.dubbo.common.URL)1 CONSUMER_SIDE (org.apache.dubbo.common.constants.CommonConstants.CONSUMER_SIDE)1 PROVIDER_SIDE (org.apache.dubbo.common.constants.CommonConstants.PROVIDER_SIDE)1 SSL_ENABLED_KEY (org.apache.dubbo.common.constants.CommonConstants.SSL_ENABLED_KEY)1