Package io.netty.resolver.dns
Class DefaultAuthoritativeDnsServerCache
- java.lang.Object
-
- io.netty.resolver.dns.DefaultAuthoritativeDnsServerCache
-
- All Implemented Interfaces:
AuthoritativeDnsServerCache
public class DefaultAuthoritativeDnsServerCache extends java.lang.Object implements AuthoritativeDnsServerCache
Default implementation ofAuthoritativeDnsServerCache, backed by aConcurrentMap.
-
-
Constructor Summary
Constructors Constructor Description DefaultAuthoritativeDnsServerCache()Create a cache that respects the TTL returned by the DNS server.DefaultAuthoritativeDnsServerCache(int minTtl, int maxTtl, java.util.Comparator<java.net.InetSocketAddress> comparator)Create a cache.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcache(java.lang.String hostname, java.net.InetSocketAddress address, long originalTtl, EventLoop loop)Caches a nameserver that should be used to resolve the given hostname.voidclear()Clears all cached nameservers.booleanclear(java.lang.String hostname)Clears the cached nameservers for the specified hostname.DnsServerAddressStreamget(java.lang.String hostname)Returns the cached nameservers that should be used to resolve the given hostname.java.lang.StringtoString()
-
-
-
Constructor Detail
-
DefaultAuthoritativeDnsServerCache
public DefaultAuthoritativeDnsServerCache()
Create a cache that respects the TTL returned by the DNS server.
-
DefaultAuthoritativeDnsServerCache
public DefaultAuthoritativeDnsServerCache(int minTtl, int maxTtl, java.util.Comparator<java.net.InetSocketAddress> comparator)Create a cache.- Parameters:
minTtl- the minimum TTLmaxTtl- the maximum TTLcomparator- theComparatorto order theInetSocketAddressfor a hostname ornullif insertion order should be used.
-
-
Method Detail
-
get
public DnsServerAddressStream get(java.lang.String hostname)
Description copied from interface:AuthoritativeDnsServerCacheReturns the cached nameservers that should be used to resolve the given hostname. The returnedDnsServerAddressStreammay contain unresolvedInetSocketAddresses that will be resolved when needed while resolving other domain names.- Specified by:
getin interfaceAuthoritativeDnsServerCache- Parameters:
hostname- the hostname- Returns:
- the cached entries or an
nullif none.
-
cache
public void cache(java.lang.String hostname, java.net.InetSocketAddress address, long originalTtl, EventLoop loop)Description copied from interface:AuthoritativeDnsServerCacheCaches a nameserver that should be used to resolve the given hostname.- Specified by:
cachein interfaceAuthoritativeDnsServerCache- Parameters:
hostname- the hostnameaddress- the nameserver address (which may be unresolved).originalTtl- the TTL as returned by the DNS serverloop- theEventLoopused to register the TTL timeout
-
clear
public void clear()
Description copied from interface:AuthoritativeDnsServerCacheClears all cached nameservers.- Specified by:
clearin interfaceAuthoritativeDnsServerCache- See Also:
AuthoritativeDnsServerCache.clear(String)
-
clear
public boolean clear(java.lang.String hostname)
Description copied from interface:AuthoritativeDnsServerCacheClears the cached nameservers for the specified hostname.- Specified by:
clearin interfaceAuthoritativeDnsServerCache- Returns:
trueif and only if there was an entry for the specified host name in the cache and it has been removed by this method
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-