Package io.netty.resolver.dns
Class DefaultAuthoritativeDnsServerCache
java.lang.Object
io.netty.resolver.dns.DefaultAuthoritativeDnsServerCache
- All Implemented Interfaces:
AuthoritativeDnsServerCache
public class DefaultAuthoritativeDnsServerCache
extends Object
implements AuthoritativeDnsServerCache
Default implementation of
AuthoritativeDnsServerCache
, backed by a ConcurrentMap
.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Comparator
<InetSocketAddress> private final int
private final int
private final Cache
<InetSocketAddress> -
Constructor Summary
ConstructorsConstructorDescriptionCreate a cache that respects the TTL returned by the DNS server.DefaultAuthoritativeDnsServerCache
(int minTtl, int maxTtl, Comparator<InetSocketAddress> comparator) Create a cache. -
Method Summary
Modifier and TypeMethodDescriptionvoid
cache
(String hostname, InetSocketAddress address, long originalTtl, EventLoop loop) Caches a nameserver that should be used to resolve the given hostname.void
clear()
Clears all cached nameservers.boolean
Clears the cached nameservers for the specified hostname.Returns the cached nameservers that should be used to resolve the given hostname.(package private) int
maxTtl()
(package private) int
minTtl()
toString()
-
Field Details
-
minTtl
private final int minTtl -
maxTtl
private final int maxTtl -
comparator
-
resolveCache
-
-
Constructor Details
-
DefaultAuthoritativeDnsServerCache
public DefaultAuthoritativeDnsServerCache()Create a cache that respects the TTL returned by the DNS server. -
DefaultAuthoritativeDnsServerCache
public DefaultAuthoritativeDnsServerCache(int minTtl, int maxTtl, Comparator<InetSocketAddress> comparator) Create a cache.- Parameters:
minTtl
- the minimum TTLmaxTtl
- the maximum TTLcomparator
- theComparator
to order theInetSocketAddress
for a hostname ornull
if insertion order should be used.
-
-
Method Details
-
get
Description copied from interface:AuthoritativeDnsServerCache
Returns the cached nameservers that should be used to resolve the given hostname. The returnedDnsServerAddressStream
may contain unresolvedInetSocketAddress
es that will be resolved when needed while resolving other domain names.- Specified by:
get
in interfaceAuthoritativeDnsServerCache
- Parameters:
hostname
- the hostname- Returns:
- the cached entries or an
null
if none.
-
cache
Description copied from interface:AuthoritativeDnsServerCache
Caches a nameserver that should be used to resolve the given hostname.- Specified by:
cache
in interfaceAuthoritativeDnsServerCache
- Parameters:
hostname
- the hostnameaddress
- the nameserver address (which may be unresolved).originalTtl
- the TTL as returned by the DNS serverloop
- theEventLoop
used to register the TTL timeout
-
clear
public void clear()Description copied from interface:AuthoritativeDnsServerCache
Clears all cached nameservers.- Specified by:
clear
in interfaceAuthoritativeDnsServerCache
- See Also:
-
clear
Description copied from interface:AuthoritativeDnsServerCache
Clears the cached nameservers for the specified hostname.- Specified by:
clear
in interfaceAuthoritativeDnsServerCache
- Returns:
true
if and only if there was an entry for the specified host name in the cache and it has been removed by this method
-
toString
-
minTtl
int minTtl() -
maxTtl
int maxTtl()
-