public final class DnsNameResolverBuilder
extends java.lang.Object
DnsNameResolver
builder.构造器和说明 |
---|
DnsNameResolverBuilder()
Creates a new builder.
|
DnsNameResolverBuilder(EventLoop eventLoop)
Creates a new builder.
|
限定符和类型 | 方法和说明 |
---|---|
DnsNameResolverBuilder |
authoritativeDnsServerCache(AuthoritativeDnsServerCache authoritativeDnsServerCache)
Sets the cache for authoritative NS servers
|
DnsNameResolverBuilder |
authoritativeDnsServerCache(DnsCache authoritativeDnsServerCache)
|
DnsNameResolver |
build()
Returns a new
DnsNameResolver instance. |
protected ChannelFactory<? extends DatagramChannel> |
channelFactory() |
DnsNameResolverBuilder |
channelFactory(ChannelFactory<? extends DatagramChannel> channelFactory)
Sets the
ChannelFactory that will create a DatagramChannel . |
DnsNameResolverBuilder |
channelType(java.lang.Class<? extends DatagramChannel> channelType)
Sets the
ChannelFactory as a ReflectiveChannelFactory of this type. |
DnsNameResolverBuilder |
cnameCache(DnsCnameCache cnameCache)
Sets the cache for
CNAME mappings. |
DnsNameResolverBuilder |
completeOncePreferredResolved(boolean completeOncePreferredResolved)
If
true SimpleNameResolver.resolveAll(String) will notify the returned Future as
soon as all queries for the preferred address-type are complete. |
static ResolvedAddressTypes |
computeResolvedAddressTypes(InternetProtocolFamily... internetProtocolFamilies)
Compute a
ResolvedAddressTypes from some InternetProtocolFamily s. |
DnsNameResolverBuilder |
consolidateCacheSize(int maxNumConsolidation)
Set the maximum size of the cache that is used to consolidate lookups for different hostnames when in-flight.
|
DnsNameResolverBuilder |
copy()
Creates a copy of this
DnsNameResolverBuilder |
DnsNameResolverBuilder |
decodeIdn(boolean decodeIdn)
Set if domain / host names should be decoded to unicode when received.
|
DnsNameResolverBuilder |
dnsQueryLifecycleObserverFactory(DnsQueryLifecycleObserverFactory lifecycleObserverFactory)
Set the factory used to generate objects which can observe individual DNS queries.
|
DnsNameResolverBuilder |
eventLoop(EventLoop eventLoop)
Sets the
EventLoop which will perform the communication with the DNS servers. |
DnsNameResolverBuilder |
hostsFileEntriesResolver(HostsFileEntriesResolver hostsFileEntriesResolver) |
DnsNameResolverBuilder |
localAddress(java.net.SocketAddress localAddress)
Configure the address that will be used to bind too.
|
DnsNameResolverBuilder |
maxPayloadSize(int maxPayloadSize)
Sets the capacity of the datagram packet buffer (in bytes).
|
DnsNameResolverBuilder |
maxQueriesPerResolve(int maxQueriesPerResolve)
Sets the maximum allowed number of DNS queries to send when resolving a host name.
|
protected DnsServerAddressStreamProvider |
nameServerProvider() |
DnsNameResolverBuilder |
nameServerProvider(DnsServerAddressStreamProvider dnsServerAddressStreamProvider)
Set the
DnsServerAddressStreamProvider which is used to determine which DNS server is used to resolve
each hostname. |
DnsNameResolverBuilder |
ndots(int ndots)
Set the number of dots which must appear in a name before an initial absolute query is made.
|
DnsNameResolverBuilder |
negativeTtl(int negativeTtl)
Sets the TTL of the cache for the failed DNS queries (in seconds).
|
DnsNameResolverBuilder |
optResourceEnabled(boolean optResourceEnabled)
Enable the automatic inclusion of a optional records that tries to give the remote DNS server a hint about
how much data the resolver can read per response.
|
protected DnsServerAddressStream |
queryServerAddressStream() |
DnsNameResolverBuilder |
queryServerAddressStream(DnsServerAddressStream queryServerAddressStream)
Set the
DnsServerAddressStream which provides the server address for DNS queries. |
DnsNameResolverBuilder |
queryTimeoutMillis(long queryTimeoutMillis)
Sets the timeout of each DNS query performed by this resolver (in milliseconds).
|
DnsNameResolverBuilder |
recursionDesired(boolean recursionDesired)
Sets if this resolver has to send a DNS query with the RD (recursion desired) flag set.
|
DnsNameResolverBuilder |
resolveCache(DnsCache resolveCache)
Sets the cache for resolution results.
|
DnsNameResolverBuilder |
resolvedAddressTypes(ResolvedAddressTypes resolvedAddressTypes)
Sets the list of the protocol families of the address resolved.
|
DnsNameResolverBuilder |
searchDomains(java.lang.Iterable<java.lang.String> searchDomains)
Set the list of search domains of the resolver.
|
DnsNameResolverBuilder |
socketChannelFactory(ChannelFactory<? extends SocketChannel> channelFactory)
|
DnsNameResolverBuilder |
socketChannelFactory(ChannelFactory<? extends SocketChannel> channelFactory,
boolean retryOnTimeout)
|
DnsNameResolverBuilder |
socketChannelType(java.lang.Class<? extends SocketChannel> channelType)
|
DnsNameResolverBuilder |
socketChannelType(java.lang.Class<? extends SocketChannel> channelType,
boolean retryOnTimeout)
|
DnsNameResolverBuilder |
traceEnabled(boolean traceEnabled)
已过时。
Prefer to configure
a
LoggingDnsQueryLifeCycleObserverFactory instead. |
DnsNameResolverBuilder |
ttl(int minTtl,
int maxTtl)
Sets the minimum and maximum TTL of the cached DNS resource records (in seconds).
|
public DnsNameResolverBuilder eventLoop(EventLoop eventLoop)
EventLoop
which will perform the communication with the DNS servers.eventLoop
- the EventLoop
this
protected ChannelFactory<? extends DatagramChannel> channelFactory()
public DnsNameResolverBuilder channelFactory(ChannelFactory<? extends DatagramChannel> channelFactory)
ChannelFactory
that will create a DatagramChannel
.
If TCP fallback should be supported as well it is required
to call the or {@link #socketChannelType(Class)}
method.channelFactory
- the ChannelFactory
this
public DnsNameResolverBuilder channelType(java.lang.Class<? extends DatagramChannel> channelType)
ChannelFactory
as a ReflectiveChannelFactory
of this type.
Use as an alternative to channelFactory(ChannelFactory)
.
If TCP fallback should be supported as well it is required
to call the or {@link #socketChannelType(Class)}
method.channelType
- the typethis
public DnsNameResolverBuilder socketChannelFactory(ChannelFactory<? extends SocketChannel> channelFactory)
ChannelFactory
that will create a SocketChannel
for
TCP fallback if needed.
TCP fallback is not enabled by default and must be enabled by providing a non-null
ChannelFactory
for this method.channelFactory
- the ChannelFactory
or null
if TCP fallback should not be supported.
By default, TCP fallback is not enabled.this
public DnsNameResolverBuilder socketChannelType(java.lang.Class<? extends SocketChannel> channelType)
ChannelFactory
as a ReflectiveChannelFactory
of this type for
TCP fallback if needed.
Use as an alternative to socketChannelFactory(ChannelFactory)
.
TCP fallback is not enabled by default and must be enabled by providing a non-null
channelType
for this method.channelType
- the type or null
if TCP fallback
should not be supported. By default, TCP fallback is not enabled.this
public DnsNameResolverBuilder socketChannelFactory(ChannelFactory<? extends SocketChannel> channelFactory, boolean retryOnTimeout)
ChannelFactory
that will create a SocketChannel
for
TCP fallback if needed.
TCP fallback is not enabled by default and must be enabled by providing a non-null
ChannelFactory
for this method.channelFactory
- the ChannelFactory
or null
if TCP fallback should not be supported.
By default, TCP fallback is not enabled.retryOnTimeout
- if true
the DnsNameResolver
will also fallback to TCP if a timeout
was detected, if false
it will only try to use TCP if the response was marked
as truncated.this
public DnsNameResolverBuilder socketChannelType(java.lang.Class<? extends SocketChannel> channelType, boolean retryOnTimeout)
ChannelFactory
as a ReflectiveChannelFactory
of this type for
TCP fallback if needed.
Use as an alternative to socketChannelFactory(ChannelFactory)
.
TCP fallback is not enabled by default and must be enabled by providing a non-null
channelType
for this method.channelType
- the type or null
if TCP fallback
should not be supported. By default, TCP fallback is not enabled.retryOnTimeout
- if true
the DnsNameResolver
will also fallback to TCP if a timeout
was detected, if false
it will only try to use TCP if the response was marked
as truncated.this
public DnsNameResolverBuilder resolveCache(DnsCache resolveCache)
resolveCache
- the DNS resolution results cachethis
public DnsNameResolverBuilder cnameCache(DnsCnameCache cnameCache)
CNAME
mappings.cnameCache
- the cache used to cache CNAME
mappings for a domain.this
public DnsNameResolverBuilder dnsQueryLifecycleObserverFactory(DnsQueryLifecycleObserverFactory lifecycleObserverFactory)
lifecycleObserverFactory
- the factory used to generate objects which can observe individual DNS queries.this
@Deprecated public DnsNameResolverBuilder authoritativeDnsServerCache(DnsCache authoritativeDnsServerCache)
authoritativeDnsServerCache
- the authoritative NS servers cachethis
public DnsNameResolverBuilder authoritativeDnsServerCache(AuthoritativeDnsServerCache authoritativeDnsServerCache)
authoritativeDnsServerCache
- the authoritative NS servers cachethis
public DnsNameResolverBuilder localAddress(java.net.SocketAddress localAddress)
null
the default will be used.localAddress
- the bind addressthis
public DnsNameResolverBuilder ttl(int minTtl, int maxTtl)
0
and Integer.MAX_VALUE
, which practically tells this resolver to
respect the TTL from the DNS server.minTtl
- the minimum TTLmaxTtl
- the maximum TTLthis
public DnsNameResolverBuilder negativeTtl(int negativeTtl)
negativeTtl
- the TTL for failed cached queriesthis
public DnsNameResolverBuilder queryTimeoutMillis(long queryTimeoutMillis)
0
disables the timeout. If not set or a negative number is set, the default timeout is used.queryTimeoutMillis
- the query timeoutthis
public static ResolvedAddressTypes computeResolvedAddressTypes(InternetProtocolFamily... internetProtocolFamilies)
ResolvedAddressTypes
from some InternetProtocolFamily
s.
An empty input will return the default value, based on "java.net" System properties.
Valid inputs are (), (IPv4), (IPv6), (Ipv4, IPv6) and (IPv6, IPv4).internetProtocolFamilies
- a valid sequence of InternetProtocolFamily
sResolvedAddressTypes
public DnsNameResolverBuilder resolvedAddressTypes(ResolvedAddressTypes resolvedAddressTypes)
computeResolvedAddressTypes(InternetProtocolFamily...)
to get a ResolvedAddressTypes
out of some InternetProtocolFamily
s.resolvedAddressTypes
- the address typesthis
public DnsNameResolverBuilder completeOncePreferredResolved(boolean completeOncePreferredResolved)
true
SimpleNameResolver.resolveAll(String)
will notify the returned Future
as
soon as all queries for the preferred address-type are complete.completeOncePreferredResolved
- true
to enable, false
to disable.this
public DnsNameResolverBuilder recursionDesired(boolean recursionDesired)
recursionDesired
- true if recursion is desiredthis
public DnsNameResolverBuilder maxQueriesPerResolve(int maxQueriesPerResolve)
maxQueriesPerResolve
- the max number of queriesthis
@Deprecated public DnsNameResolverBuilder traceEnabled(boolean traceEnabled)
LoggingDnsQueryLifeCycleObserverFactory
instead.traceEnabled
- true if trace is enabledthis
public DnsNameResolverBuilder maxPayloadSize(int maxPayloadSize)
4096
bytes.maxPayloadSize
- the capacity of the datagram packet bufferthis
public DnsNameResolverBuilder optResourceEnabled(boolean optResourceEnabled)
optResourceEnabled
- if optional records inclusion is enabledthis
public DnsNameResolverBuilder hostsFileEntriesResolver(HostsFileEntriesResolver hostsFileEntriesResolver)
hostsFileEntriesResolver
- the HostsFileEntriesResolver
used to first check
if the hostname is locally aliased.this
protected DnsServerAddressStreamProvider nameServerProvider()
public DnsNameResolverBuilder nameServerProvider(DnsServerAddressStreamProvider dnsServerAddressStreamProvider)
DnsServerAddressStreamProvider
which is used to determine which DNS server is used to resolve
each hostname.this
.protected DnsServerAddressStream queryServerAddressStream()
public DnsNameResolverBuilder queryServerAddressStream(DnsServerAddressStream queryServerAddressStream)
DnsServerAddressStream
which provides the server address for DNS queries.this
.public DnsNameResolverBuilder searchDomains(java.lang.Iterable<java.lang.String> searchDomains)
searchDomains
- the search domainsthis
public DnsNameResolverBuilder ndots(int ndots)
1
.ndots
- the ndots valuethis
public DnsNameResolverBuilder decodeIdn(boolean decodeIdn)
decodeIdn
- if should get decodedthis
public DnsNameResolverBuilder consolidateCacheSize(int maxNumConsolidation)
maxNumConsolidation
- the maximum lookups to consolidate (different hostnames), or 0
if
no consolidation should be performed.this
public DnsNameResolver build()
DnsNameResolver
instance.DnsNameResolver
public DnsNameResolverBuilder copy()
DnsNameResolverBuilder