@UnstableApi public class RoundRobinDnsAddressResolverGroup extends DnsAddressResolverGroup
AddressResolverGroup
的DnsNameResolver
s,如果名称服务器提供多个目标地址,则支持随机选择目标地址。
这非常适合在使用连接池的应用程序中使用,因为连接到单个解析的地址效率不高。
Constructor and Description |
---|
RoundRobinDnsAddressResolverGroup(ChannelFactory<? extends DatagramChannel> channelFactory, DnsServerAddressStreamProvider nameServerProvider) |
RoundRobinDnsAddressResolverGroup(java.lang.Class<? extends DatagramChannel> channelType, DnsServerAddressStreamProvider nameServerProvider) |
Modifier and Type | Method and Description |
---|---|
protected AddressResolver<java.net.InetSocketAddress> |
newAddressResolver(EventLoop eventLoop, NameResolver<java.net.InetAddress> resolver)
我们需要重写此方法,而不是
DnsAddressResolverGroup.newNameResolver(EventLoop, ChannelFactory, DnsServerAddressStreamProvider) ,因为我们需要消除可能缓存
NameResolver.resolve(java.lang.String) 通过
InflightNameResolver 中创建
DnsAddressResolverGroup.newResolver(EventLoop, ChannelFactory, DnsServerAddressStreamProvider) 。
|
newNameResolver, newResolver, newResolver
close, getResolver
public RoundRobinDnsAddressResolverGroup(java.lang.Class<? extends DatagramChannel> channelType, DnsServerAddressStreamProvider nameServerProvider)
public RoundRobinDnsAddressResolverGroup(ChannelFactory<? extends DatagramChannel> channelFactory, DnsServerAddressStreamProvider nameServerProvider)
protected final AddressResolver<java.net.InetSocketAddress> newAddressResolver(EventLoop eventLoop, NameResolver<java.net.InetAddress> resolver) throws java.lang.Exception
DnsAddressResolverGroup.newNameResolver(EventLoop, ChannelFactory, DnsServerAddressStreamProvider)
,因为我们需要消除可能缓存
NameResolver.resolve(java.lang.String)
通过
InflightNameResolver
中创建
DnsAddressResolverGroup.newResolver(EventLoop, ChannelFactory, DnsServerAddressStreamProvider)
。
newAddressResolver
在课堂
DnsAddressResolverGroup
java.lang.Exception
Copyright © 2008–2018 The Netty Project. All rights reserved.