public class DnsNameResolver extends SimpleNameResolver<InetSocketAddress>
NameResolver.| Constructor and Description |
|---|
DnsNameResolver(EventLoop eventLoop,
ChannelFactory<? extends DatagramChannel> channelFactory,
DnsServerAddresses nameServerAddresses)
Creates a new DNS-based name resolver that communicates with the specified list of DNS servers.
|
DnsNameResolver(EventLoop eventLoop,
ChannelFactory<? extends DatagramChannel> channelFactory,
InetSocketAddress localAddress,
DnsServerAddresses nameServerAddresses)
Creates a new DNS-based name resolver that communicates with the specified list of DNS servers.
|
DnsNameResolver(EventLoop eventLoop,
Class<? extends DatagramChannel> channelType,
DnsServerAddresses nameServerAddresses)
Creates a new DNS-based name resolver that communicates with the specified list of DNS servers.
|
DnsNameResolver(EventLoop eventLoop,
Class<? extends DatagramChannel> channelType,
InetSocketAddress localAddress,
DnsServerAddresses nameServerAddresses)
Creates a new DNS-based name resolver that communicates with the specified list of DNS servers.
|
| Modifier and Type | Method and Description |
|---|---|
DnsNameResolver |
clearCache()
Clears all the resolved addresses cached by this resolver.
|
boolean |
clearCache(String hostname)
Clears the resolved addresses of the specified host name from the cache of this resolver.
|
void |
close()
Closes the internal datagram channel used for sending and receiving DNS messages, and clears all DNS resource
records from the cache.
|
protected boolean |
doIsResolved(InetSocketAddress address)
Invoked by
SimpleNameResolver.isResolved(SocketAddress) to check if the specified address has been resolved
already. |
protected void |
doResolve(InetSocketAddress unresolvedAddress,
Promise<InetSocketAddress> promise)
Invoked by
SimpleNameResolver.resolve(SocketAddress) and SimpleNameResolver.resolve(String, int) to perform the actual name
resolution. |
protected void |
doResolveAll(InetSocketAddress unresolvedAddress,
Promise<List<InetSocketAddress>> promise)
Invoked by
SimpleNameResolver.resolveAll(SocketAddress) and SimpleNameResolver.resolveAll(String, int) to perform the actual name
resolution. |
protected EventLoop |
executor()
Returns the
EventExecutor which is used to notify the listeners of the Future returned
by SimpleNameResolver.resolve(SocketAddress). |
boolean |
isRecursionDesired()
Returns
true if and only if this resolver sends a DNS query with the RD (recursion desired) flag set. |
boolean |
isTraceEnabled()
Returns if this resolver should generate the detailed trace information in an exception message so that
it is easier to understand the cause of resolution failure.
|
int |
maxPayloadSize()
Returns the capacity of the datagram packet buffer (in bytes).
|
int |
maxQueriesPerResolve()
Returns the maximum allowed number of DNS queries to send when resolving a host name.
|
int |
maxTtl()
Returns the maximum TTL of the cached DNS resource records (in seconds).
|
int |
minTtl()
Returns the minimum TTL of the cached DNS resource records (in seconds).
|
int |
negativeTtl()
Returns the TTL of the cache for the failed DNS queries (in seconds).
|
Future<AddressedEnvelope<DnsResponse,InetSocketAddress>> |
query(DnsQuestion question)
Sends a DNS query with the specified question.
|
Future<AddressedEnvelope<DnsResponse,InetSocketAddress>> |
query(DnsQuestion question,
Promise<AddressedEnvelope<? extends DnsResponse,InetSocketAddress>> promise)
Sends a DNS query with the specified question.
|
Future<AddressedEnvelope<DnsResponse,InetSocketAddress>> |
query(InetSocketAddress nameServerAddr,
DnsQuestion question)
Sends a DNS query with the specified question using the specified name server list.
|
Future<AddressedEnvelope<DnsResponse,InetSocketAddress>> |
query(InetSocketAddress nameServerAddr,
DnsQuestion question,
Promise<AddressedEnvelope<? extends DnsResponse,InetSocketAddress>> promise)
Sends a DNS query with the specified question using the specified name server list.
|
long |
queryTimeoutMillis()
Returns the timeout of each DNS query performed by this resolver (in milliseconds).
|
List<InternetProtocolFamily> |
resolveAddressTypes()
Returns the list of the protocol families of the address resolved by
SimpleNameResolver.resolve(SocketAddress)
in the order of preference. |
DnsNameResolver |
setMaxPayloadSize(int maxPayloadSize)
Sets the capacity of the datagram packet buffer (in bytes).
|
DnsNameResolver |
setMaxQueriesPerResolve(int maxQueriesPerResolve)
Sets the maximum allowed number of DNS queries to send when resolving a host name.
|
DnsNameResolver |
setNegativeTtl(int negativeTtl)
Sets the TTL of the cache for the failed DNS queries (in seconds).
|
DnsNameResolver |
setQueryTimeoutMillis(long queryTimeoutMillis)
Sets the timeout of each DNS query performed by this resolver (in milliseconds).
|
DnsNameResolver |
setRecursionDesired(boolean recursionDesired)
Sets if this resolver has to send a DNS query with the RD (recursion desired) flag set.
|
DnsNameResolver |
setResolveAddressTypes(InternetProtocolFamily... resolveAddressTypes)
Sets the list of the protocol families of the address resolved by
SimpleNameResolver.resolve(SocketAddress). |
DnsNameResolver |
setResolveAddressTypes(Iterable<InternetProtocolFamily> resolveAddressTypes)
Sets the list of the protocol families of the address resolved by
SimpleNameResolver.resolve(SocketAddress). |
DnsNameResolver |
setTraceEnabled(boolean traceEnabled)
Sets if this resolver should generate the detailed trace information in an exception message so that
it is easier to understand the cause of resolution failure.
|
DnsNameResolver |
setTtl(int minTtl,
int maxTtl)
Sets the minimum and maximum TTL of the cached DNS resource records (in seconds).
|
isResolved, isSupported, resolve, resolve, resolve, resolve, resolveAll, resolveAll, resolveAll, resolveAllpublic DnsNameResolver(EventLoop eventLoop, Class<? extends DatagramChannel> channelType, DnsServerAddresses nameServerAddresses)
eventLoop - the EventLoop which will perform the communication with the DNS serverschannelType - the type of the DatagramChannel to createnameServerAddresses - the addresses of the DNS server. For each DNS query, a new stream is created from
this to determine which DNS server should be contacted for the next retry in case
of failure.public DnsNameResolver(EventLoop eventLoop, Class<? extends DatagramChannel> channelType, InetSocketAddress localAddress, DnsServerAddresses nameServerAddresses)
eventLoop - the EventLoop which will perform the communication with the DNS serverschannelType - the type of the DatagramChannel to createlocalAddress - the local address of the DatagramChannelnameServerAddresses - the addresses of the DNS server. For each DNS query, a new stream is created from
this to determine which DNS server should be contacted for the next retry in case
of failure.public DnsNameResolver(EventLoop eventLoop, ChannelFactory<? extends DatagramChannel> channelFactory, DnsServerAddresses nameServerAddresses)
eventLoop - the EventLoop which will perform the communication with the DNS serverschannelFactory - the ChannelFactory that will create a DatagramChannelnameServerAddresses - the addresses of the DNS server. For each DNS query, a new stream is created from
this to determine which DNS server should be contacted for the next retry in case
of failure.public DnsNameResolver(EventLoop eventLoop, ChannelFactory<? extends DatagramChannel> channelFactory, InetSocketAddress localAddress, DnsServerAddresses nameServerAddresses)
eventLoop - the EventLoop which will perform the communication with the DNS serverschannelFactory - the ChannelFactory that will create a DatagramChannellocalAddress - the local address of the DatagramChannelnameServerAddresses - the addresses of the DNS server. For each DNS query, a new stream is created from
this to determine which DNS server should be contacted for the next retry in case
of failure.public int minTtl()
maxTtl(),
setTtl(int, int)public int maxTtl()
minTtl(),
setTtl(int, int)public DnsNameResolver setTtl(int minTtl, int maxTtl)
0 and Integer.MAX_VALUE, which practically tells this resolver to respect
the TTL from the DNS server.public int negativeTtl()
0, which
disables the cache for negative results.setNegativeTtl(int)public DnsNameResolver setNegativeTtl(int negativeTtl)
thisnegativeTtl()public long queryTimeoutMillis()
setQueryTimeoutMillis(long)public DnsNameResolver setQueryTimeoutMillis(long queryTimeoutMillis)
thisqueryTimeoutMillis()public List<InternetProtocolFamily> resolveAddressTypes()
SimpleNameResolver.resolve(SocketAddress)
in the order of preference.
The default value depends on the value of the system property "java.net.preferIPv6Addresses".public DnsNameResolver setResolveAddressTypes(InternetProtocolFamily... resolveAddressTypes)
SimpleNameResolver.resolve(SocketAddress).
Usually, both InternetProtocolFamily.IPv4 and InternetProtocolFamily.IPv6 are specified in the
order of preference. To enforce the resolve to retrieve the address of a specific protocol family, specify
only a single InternetProtocolFamily.thisresolveAddressTypes()public DnsNameResolver setResolveAddressTypes(Iterable<InternetProtocolFamily> resolveAddressTypes)
SimpleNameResolver.resolve(SocketAddress).
Usually, both InternetProtocolFamily.IPv4 and InternetProtocolFamily.IPv6 are specified in the
order of preference. To enforce the resolve to retrieve the address of a specific protocol family, specify
only a single InternetProtocolFamily.thisresolveAddressTypes()public boolean isRecursionDesired()
true if and only if this resolver sends a DNS query with the RD (recursion desired) flag set.
The default value is true.setRecursionDesired(boolean)public DnsNameResolver setRecursionDesired(boolean recursionDesired)
thisisRecursionDesired()public int maxQueriesPerResolve()
8.setMaxQueriesPerResolve(int)public DnsNameResolver setMaxQueriesPerResolve(int maxQueriesPerResolve)
thismaxQueriesPerResolve()public boolean isTraceEnabled()
true.public DnsNameResolver setTraceEnabled(boolean traceEnabled)
public int maxPayloadSize()
4096 bytes.setMaxPayloadSize(int)public DnsNameResolver setMaxPayloadSize(int maxPayloadSize)
4096 bytes.thismaxPayloadSize()public DnsNameResolver clearCache()
thisclearCache(String)public boolean clearCache(String hostname)
true if and only if there was an entry for the specified host name in the cache and
it has been removed by this methodpublic void close()
close in interface NameResolver<InetSocketAddress>close in interface Closeableclose in interface AutoCloseableclose in class SimpleNameResolver<InetSocketAddress>protected EventLoop executor()
SimpleNameResolverEventExecutor which is used to notify the listeners of the Future returned
by SimpleNameResolver.resolve(SocketAddress).executor in class SimpleNameResolver<InetSocketAddress>protected boolean doIsResolved(InetSocketAddress address)
SimpleNameResolverSimpleNameResolver.isResolved(SocketAddress) to check if the specified address has been resolved
already.doIsResolved in class SimpleNameResolver<InetSocketAddress>protected void doResolve(InetSocketAddress unresolvedAddress, Promise<InetSocketAddress> promise) throws Exception
SimpleNameResolverSimpleNameResolver.resolve(SocketAddress) and SimpleNameResolver.resolve(String, int) to perform the actual name
resolution.doResolve in class SimpleNameResolver<InetSocketAddress>Exceptionprotected void doResolveAll(InetSocketAddress unresolvedAddress, Promise<List<InetSocketAddress>> promise) throws Exception
SimpleNameResolverSimpleNameResolver.resolveAll(SocketAddress) and SimpleNameResolver.resolveAll(String, int) to perform the actual name
resolution.doResolveAll in class SimpleNameResolver<InetSocketAddress>Exceptionpublic Future<AddressedEnvelope<DnsResponse,InetSocketAddress>> query(DnsQuestion question)
public Future<AddressedEnvelope<DnsResponse,InetSocketAddress>> query(DnsQuestion question, Promise<AddressedEnvelope<? extends DnsResponse,InetSocketAddress>> promise)
public Future<AddressedEnvelope<DnsResponse,InetSocketAddress>> query(InetSocketAddress nameServerAddr, DnsQuestion question)
public Future<AddressedEnvelope<DnsResponse,InetSocketAddress>> query(InetSocketAddress nameServerAddr, DnsQuestion question, Promise<AddressedEnvelope<? extends DnsResponse,InetSocketAddress>> promise)
Copyright © 2008–2015 The Netty Project. All rights reserved.