public class DnsNameResolver extends SimpleNameResolver<InetSocketAddress>
NameResolver
.Constructor and Description |
---|
DnsNameResolver(EventLoop eventLoop,
ChannelFactory<? extends DatagramChannel> channelFactory,
InetSocketAddress nameServerAddress)
Creates a new DNS-based name resolver that communicates with a single DNS server.
|
DnsNameResolver(EventLoop eventLoop,
ChannelFactory<? extends DatagramChannel> channelFactory,
InetSocketAddress localAddress,
InetSocketAddress nameServerAddress)
Creates a new DNS-based name resolver that communicates with a single DNS server.
|
DnsNameResolver(EventLoop eventLoop,
ChannelFactory<? extends DatagramChannel> channelFactory,
InetSocketAddress localAddress,
Iterable<InetSocketAddress> nameServerAddresses)
Creates a new DNS-based name resolver that communicates with the specified list of DNS servers.
|
DnsNameResolver(EventLoop eventLoop,
ChannelFactory<? extends DatagramChannel> channelFactory,
Iterable<InetSocketAddress> 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 nameServerAddress)
Creates a new DNS-based name resolver that communicates with a single DNS server.
|
DnsNameResolver(EventLoop eventLoop,
Class<? extends DatagramChannel> channelType,
InetSocketAddress localAddress,
InetSocketAddress nameServerAddress)
Creates a new DNS-based name resolver that communicates with a single DNS server.
|
DnsNameResolver(EventLoop eventLoop,
Class<? extends DatagramChannel> channelType,
InetSocketAddress localAddress,
Iterable<InetSocketAddress> nameServerAddresses)
Creates a new DNS-based name resolver that communicates with the specified list of DNS servers.
|
DnsNameResolver(EventLoop eventLoop,
Class<? extends DatagramChannel> channelType,
Iterable<InetSocketAddress> 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 DNS resource records cached by this resolver.
|
boolean |
clearCache(DnsQuestion question)
Clears the DNS resource record of the specified DNS question 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 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. |
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 |
maxTriesPerQuery()
Returns the maximum number of tries for each query.
|
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<DnsResponse> |
query(DnsQuestion question)
Sends a DNS query with the specified question.
|
Future<DnsResponse> |
query(DnsQuestion question,
Promise<DnsResponse> promise)
Sends a DNS query with the specified question.
|
Future<DnsResponse> |
query(Iterable<InetSocketAddress> nameServerAddresses,
DnsQuestion question)
Sends a DNS query with the specified question using the specified name server list.
|
Future<DnsResponse> |
query(Iterable<InetSocketAddress> nameServerAddresses,
DnsQuestion question,
Promise<DnsResponse> 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 |
setMaxTriesPerQuery(int maxTriesPerQuery)
Sets the maximum number of tries for each query.
|
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 |
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
public DnsNameResolver(EventLoop eventLoop, Class<? extends DatagramChannel> channelType, InetSocketAddress nameServerAddress)
eventLoop
- the EventLoop
which will perform the communication with the DNS serverschannelType
- the type of the DatagramChannel
to createnameServerAddress
- the address of the DNS serverpublic DnsNameResolver(EventLoop eventLoop, Class<? extends DatagramChannel> channelType, InetSocketAddress localAddress, InetSocketAddress nameServerAddress)
eventLoop
- the EventLoop
which will perform the communication with the DNS serverschannelType
- the type of the DatagramChannel
to createlocalAddress
- the local address of the DatagramChannel
nameServerAddress
- the address of the DNS serverpublic DnsNameResolver(EventLoop eventLoop, ChannelFactory<? extends DatagramChannel> channelFactory, InetSocketAddress nameServerAddress)
eventLoop
- the EventLoop
which will perform the communication with the DNS serverschannelFactory
- the ChannelFactory
that will create a DatagramChannel
nameServerAddress
- the address of the DNS serverpublic DnsNameResolver(EventLoop eventLoop, ChannelFactory<? extends DatagramChannel> channelFactory, InetSocketAddress localAddress, InetSocketAddress nameServerAddress)
eventLoop
- the EventLoop
which will perform the communication with the DNS serverschannelFactory
- the ChannelFactory
that will create a DatagramChannel
localAddress
- the local address of the DatagramChannel
nameServerAddress
- the address of the DNS serverpublic DnsNameResolver(EventLoop eventLoop, Class<? extends DatagramChannel> channelType, Iterable<InetSocketAddress> 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 Iterator
is
created from this Iterable
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, Iterable<InetSocketAddress> 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 DatagramChannel
nameServerAddresses
- the addresses of the DNS server. For each DNS query, a new Iterator
is
created from this Iterable
to determine which DNS server should be contacted
for the next retry in case of failure.public DnsNameResolver(EventLoop eventLoop, ChannelFactory<? extends DatagramChannel> channelFactory, Iterable<InetSocketAddress> nameServerAddresses)
eventLoop
- the EventLoop
which will perform the communication with the DNS serverschannelFactory
- the ChannelFactory
that will create a DatagramChannel
nameServerAddresses
- the addresses of the DNS server. For each DNS query, a new Iterator
is
created from this Iterable
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, Iterable<InetSocketAddress> nameServerAddresses)
eventLoop
- the EventLoop
which will perform the communication with the DNS serverschannelFactory
- the ChannelFactory
that will create a DatagramChannel
localAddress
- the local address of the DatagramChannel
nameServerAddresses
- the addresses of the DNS server. For each DNS query, a new Iterator
is
created from this Iterable
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)
this
negativeTtl()
public long queryTimeoutMillis()
setQueryTimeoutMillis(long)
public DnsNameResolver setQueryTimeoutMillis(long queryTimeoutMillis)
this
queryTimeoutMillis()
public int maxTriesPerQuery()
setMaxTriesPerQuery(int)
public DnsNameResolver setMaxTriesPerQuery(int maxTriesPerQuery)
this
maxTriesPerQuery()
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
.this
resolveAddressTypes()
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
.this
resolveAddressTypes()
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)
this
isRecursionDesired()
public int maxQueriesPerResolve()
8
.setMaxQueriesPerResolve(int)
public DnsNameResolver setMaxQueriesPerResolve(int maxQueriesPerResolve)
this
maxQueriesPerResolve()
public int maxPayloadSize()
4096
bytes.setMaxPayloadSize(int)
public DnsNameResolver setMaxPayloadSize(int maxPayloadSize)
4096
bytes.this
maxPayloadSize()
public DnsNameResolver clearCache()
this
clearCache(DnsQuestion)
public boolean clearCache(DnsQuestion question)
public void close()
close
in interface NameResolver<InetSocketAddress>
close
in interface Closeable
close
in interface AutoCloseable
close
in class SimpleNameResolver<InetSocketAddress>
protected EventLoop executor()
SimpleNameResolver
EventExecutor
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)
SimpleNameResolver
SimpleNameResolver.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
SimpleNameResolver
SimpleNameResolver.resolve(SocketAddress)
and SimpleNameResolver.resolve(String, int)
to perform the actual name
resolution.doResolve
in class SimpleNameResolver<InetSocketAddress>
Exception
public Future<DnsResponse> query(DnsQuestion question)
public Future<DnsResponse> query(DnsQuestion question, Promise<DnsResponse> promise)
public Future<DnsResponse> query(Iterable<InetSocketAddress> nameServerAddresses, DnsQuestion question)
public Future<DnsResponse> query(Iterable<InetSocketAddress> nameServerAddresses, DnsQuestion question, Promise<DnsResponse> promise)
Copyright © 2008–2015 The Netty Project. All rights reserved.