use of org.apache.dubbo.rpc.protocol.grpc.GrpcConstants.EXECUTOR 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);
}
Aggregations