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 of AuthoritativeDnsServerCache, backed by a ConcurrentMap.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final java.util.Comparator<java.net.InetSocketAddress>
     
    private final int
     
    private final int
     
    private final Cache<java.net.InetSocketAddress>
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    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

    Modifier and Type
    Method
    Description
    void
    cache(java.lang.String hostname, java.net.InetSocketAddress address, long originalTtl, EventLoop loop)
    Caches a nameserver that should be used to resolve the given hostname.
    void
    Clears all cached nameservers.
    boolean
    clear(java.lang.String hostname)
    Clears the cached nameservers for the specified hostname.
    get(java.lang.String hostname)
    Returns the cached nameservers that should be used to resolve the given hostname.
    (package private) int
     
    (package private) int
     
    java.lang.String
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • minTtl

      private final int minTtl
    • maxTtl

      private final int maxTtl
    • comparator

      private final java.util.Comparator<java.net.InetSocketAddress> comparator
    • resolveCache

      private final Cache<java.net.InetSocketAddress> 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, java.util.Comparator<java.net.InetSocketAddress> comparator)
      Create a cache.
      Parameters:
      minTtl - the minimum TTL
      maxTtl - the maximum TTL
      comparator - the Comparator to order the InetSocketAddress for a hostname or null if insertion order should be used.
  • Method Details

    • get

      public DnsServerAddressStream get(java.lang.String hostname)
      Description copied from interface: AuthoritativeDnsServerCache
      Returns the cached nameservers that should be used to resolve the given hostname. The returned DnsServerAddressStream may contain unresolved InetSocketAddresses that will be resolved when needed while resolving other domain names.
      Specified by:
      get in interface AuthoritativeDnsServerCache
      Parameters:
      hostname - the hostname
      Returns:
      the cached entries or an null if none.
    • cache

      public void cache(java.lang.String hostname, java.net.InetSocketAddress address, long originalTtl, EventLoop loop)
      Description copied from interface: AuthoritativeDnsServerCache
      Caches a nameserver that should be used to resolve the given hostname.
      Specified by:
      cache in interface AuthoritativeDnsServerCache
      Parameters:
      hostname - the hostname
      address - the nameserver address (which may be unresolved).
      originalTtl - the TTL as returned by the DNS server
      loop - the EventLoop used to register the TTL timeout
    • clear

      public void clear()
      Description copied from interface: AuthoritativeDnsServerCache
      Clears all cached nameservers.
      Specified by:
      clear in interface AuthoritativeDnsServerCache
      See Also:
    • clear

      public boolean clear(java.lang.String hostname)
      Description copied from interface: AuthoritativeDnsServerCache
      Clears the cached nameservers for the specified hostname.
      Specified by:
      clear in interface AuthoritativeDnsServerCache
      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

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • minTtl

      int minTtl()
    • maxTtl

      int maxTtl()