use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.netty.NettyChannelBuilder in project pinpoint by naver.
the class DefaultChannelFactory method build.
@Override
public ManagedChannel build(String channelName, String host, int port) {
final NettyChannelBuilder channelBuilder = NettyChannelBuilder.forAddress(host, port);
channelBuilder.usePlaintext();
logger.info("ChannelType:{}", channelType.getSimpleName());
channelBuilder.channelType(channelType);
channelBuilder.eventLoopGroup(eventLoopGroup);
setupInternal(channelBuilder);
channelBuilder.defaultLoadBalancingPolicy(GrpcUtil.DEFAULT_LB_POLICY);
addHeader(channelBuilder);
addClientInterceptor(channelBuilder);
channelBuilder.executor(executorService);
if (nameResolverProvider != null) {
logger.info("Set nameResolverProvider {}. channelName={}, host={}, port={}", this.nameResolverProvider, channelName, host, port);
setNameResolverFactory(channelBuilder, this.nameResolverProvider);
}
setupClientOption(channelBuilder);
if (sslClientConfig.isEnable()) {
SslContext sslContext = null;
try {
sslContext = SslContextFactory.create(sslClientConfig);
} catch (SSLException e) {
throw new SecurityException(e);
}
channelBuilder.sslContext(sslContext);
channelBuilder.negotiationType(NegotiationType.TLS);
}
channelBuilder.maxTraceEvents(clientOption.getMaxTraceEvent());
final ManagedChannel channel = channelBuilder.build();
return channel;
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.netty.NettyChannelBuilder in project alluxio by Alluxio.
the class GrpcConnectionPool method createManagedChannel.
/**
* Creates a {@link ManagedChannel} by given pool key.
*/
private ManagedChannel createManagedChannel(GrpcChannelKey channelKey, AlluxioConfiguration conf) {
// Create netty channel builder with the address from channel key.
NettyChannelBuilder channelBuilder;
SocketAddress address = channelKey.getServerAddress().getSocketAddress();
if (address instanceof InetSocketAddress) {
InetSocketAddress inetServerAddress = (InetSocketAddress) address;
// This constructor delays DNS lookup to detect changes
channelBuilder = NettyChannelBuilder.forAddress(inetServerAddress.getHostName(), inetServerAddress.getPort());
} else {
channelBuilder = NettyChannelBuilder.forAddress(address);
}
// Apply default channel options for the multiplex group.
channelBuilder = applyGroupDefaults(channelKey, channelBuilder, conf);
// Build netty managed channel.
return channelBuilder.build();
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.netty.NettyChannelBuilder in project grpc-java by grpc.
the class Http2NettyTest method createChannelBuilder.
@Override
protected NettyChannelBuilder createChannelBuilder() {
try {
ChannelCredentials channelCreds = TlsChannelCredentials.newBuilder().keyManager(TestUtils.loadCert("client.pem"), TestUtils.loadCert("client.key")).trustManager(TestUtils.loadCert("ca.pem")).build();
NettyChannelBuilder builder = NettyChannelBuilder.forAddress("localhost", ((InetSocketAddress) getListenAddress()).getPort(), channelCreds).overrideAuthority(TestUtils.TEST_SERVER_HOST).flowControlWindow(AbstractInteropTest.TEST_FLOW_CONTROL_WINDOW).maxInboundMessageSize(AbstractInteropTest.MAX_MESSAGE_SIZE);
// Disable the default census stats interceptor, use testing interceptor instead.
InternalNettyChannelBuilder.setStatsEnabled(builder, false);
return builder.intercept(createCensusStatsClientInterceptor());
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.netty.NettyChannelBuilder in project grpc-java by grpc.
the class AutoWindowSizingOnTest method createChannelBuilder.
@Override
protected NettyChannelBuilder createChannelBuilder() {
NettyChannelBuilder builder = NettyChannelBuilder.forAddress(getListenAddress()).negotiationType(NegotiationType.PLAINTEXT).maxInboundMessageSize(AbstractInteropTest.MAX_MESSAGE_SIZE).initialFlowControlWindow(NettyChannelBuilder.DEFAULT_FLOW_CONTROL_WINDOW);
// Disable the default census stats interceptor, use testing interceptor instead.
InternalNettyChannelBuilder.setStatsEnabled(builder, false);
return builder.intercept(createCensusStatsClientInterceptor());
}
use of org.apache.beam.vendor.grpc.v1p43p2.io.grpc.netty.NettyChannelBuilder in project dubbo by alibaba.
the class GrpcOptionsUtils method buildManagedChannel.
static ManagedChannel buildManagedChannel(URL url) {
NettyChannelBuilder builder = NettyChannelBuilder.forAddress(url.getHost(), url.getPort());
if (url.getParameter(SSL_ENABLED_KEY, false)) {
builder.sslContext(buildClientSslContext(url));
} else {
builder.usePlaintext();
}
builder.disableRetry();
// builder.directExecutor();
// client interceptors
List<io.grpc.ClientInterceptor> interceptors = new ArrayList<>(ExtensionLoader.getExtensionLoader(ClientInterceptor.class).getActivateExtension(url, CLIENT_INTERCEPTORS, CONSUMER_SIDE));
builder.intercept(interceptors);
return getConfigurator().map(configurator -> configurator.configureChannelBuilder(builder, url)).orElse(builder).build();
}
Aggregations