From 5d924bfb451bccdad0c1dc9a22c6dde49d65a47d Mon Sep 17 00:00:00 2001 From: grayson <916028390@qq.com> Date: Thu, 14 Nov 2024 05:07:01 +0800 Subject: [PATCH] Enabling DNS retryOnTimeout with TCP in DnsNameResolver (#23590) --- .../java/org/apache/pulsar/client/impl/ConnectionPool.java | 4 +++- .../java/org/apache/pulsar/proxy/server/ProxyService.java | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConnectionPool.java b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConnectionPool.java index 9be734bee6173..1eb603e28f571 100644 --- a/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConnectionPool.java +++ b/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConnectionPool.java @@ -188,7 +188,9 @@ public ConnectionPool(InstrumentProvider instrumentProvider, private static AddressResolver createAddressResolver(ClientConfigurationData conf, EventLoopGroup eventLoopGroup) { DnsNameResolverBuilder dnsNameResolverBuilder = new DnsNameResolverBuilder() - .traceEnabled(true).channelType(EventLoopUtil.getDatagramChannelClass(eventLoopGroup)); + .traceEnabled(true) + .channelType(EventLoopUtil.getDatagramChannelClass(eventLoopGroup)) + .socketChannelType(EventLoopUtil.getClientSocketChannelClass(eventLoopGroup), true); if (conf.getDnsLookupBindAddress() != null) { InetSocketAddress addr = new InetSocketAddress(conf.getDnsLookupBindAddress(), conf.getDnsLookupBindPort()); diff --git a/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyService.java b/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyService.java index 4ee15fd7124a6..11afb68398e19 100644 --- a/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyService.java +++ b/pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyService.java @@ -179,7 +179,8 @@ public ProxyService(ProxyConfiguration proxyConfig, this.authenticationService = authenticationService; DnsNameResolverBuilder dnsNameResolverBuilder = new DnsNameResolverBuilder() - .channelType(EventLoopUtil.getDatagramChannelClass(workerGroup)); + .channelType(EventLoopUtil.getDatagramChannelClass(workerGroup)) + .socketChannelType(EventLoopUtil.getClientSocketChannelClass(workerGroup), true); DnsResolverUtil.applyJdkDnsCacheSettings(dnsNameResolverBuilder); dnsAddressResolverGroup = new DnsAddressResolverGroup(dnsNameResolverBuilder);