Class CaffeineDnsCache
- java.lang.Object
- 
- org.opennms.netmgt.dnsresolver.netty.CaffeineDnsCache
 
- 
- All Implemented Interfaces:
- io.netty.resolver.dns.DnsCache,- ExtendedDnsCache
 
 public class CaffeineDnsCache extends Object implements ExtendedDnsCache DNS cache implementation largely copied from Netty's https://github.com/netty/netty/blob/netty-4.1.38.Final/resolver-dns/src/main/java/io/netty/resolver/dns/DefaultDnsCache.java but adapted slightly to work with ourCaffeineCache.
- 
- 
Field SummaryFields Modifier and Type Field Description protected static intDEFAULT_MAX_SIZEprotected static intDEFAULT_NEGATIVE_TTL_SECSprotected static intMAX_SUPPORTED_TTL_SECS
 - 
Constructor SummaryConstructors Constructor Description CaffeineDnsCache()Create a cache that respects the TTL returned by the DNS server and doesn't cache negative responses.CaffeineDnsCache(int minTtl, int maxTtl, int negativeTtl, long maxSize)Create a cache.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description ExtendedDnsCacheEntrycache(String hostname, io.netty.handler.codec.dns.DnsPtrRecord ptrRecord, io.netty.channel.EventLoop loop)Positive caching for reverse lookups.io.netty.resolver.dns.DnsCacheEntrycache(String hostname, io.netty.handler.codec.dns.DnsRecord[] additionals, Throwable cause, io.netty.channel.EventLoop loop)Negative caching for failures (or empty reverse lookups).io.netty.resolver.dns.DnsCacheEntrycache(String hostname, io.netty.handler.codec.dns.DnsRecord[] additionals, InetAddress address, long originalTtl, io.netty.channel.EventLoop loop)Positive caching for normal lookups.voidclear()booleanclear(String hostname)List<? extends io.netty.resolver.dns.DnsCacheEntry>get(String hostname, io.netty.handler.codec.dns.DnsRecord[] additionals)longgetSize()longmaxSize()Returns the maximum number of elements allows in the cache.intmaxTtl()Returns the maximum TTL of the cached DNS resource records (in seconds).intminTtl()Returns the minimum TTL of the cached DNS resource records (in seconds).intnegativeTtl()Returns the TTL of the cache for the failed DNS queries (in seconds).voidregisterMetrics(com.codahale.metrics.MetricRegistry metrics)StringtoString()voidunregisterMetrics(com.codahale.metrics.MetricRegistry metrics)
 
- 
- 
- 
Field Detail- 
MAX_SUPPORTED_TTL_SECSprotected static final int MAX_SUPPORTED_TTL_SECS 
 - 
DEFAULT_NEGATIVE_TTL_SECSprotected static final int DEFAULT_NEGATIVE_TTL_SECS 
 - 
DEFAULT_MAX_SIZEprotected static final int DEFAULT_MAX_SIZE - See Also:
- Constant Field Values
 
 
- 
 - 
Constructor Detail- 
CaffeineDnsCachepublic CaffeineDnsCache() Create a cache that respects the TTL returned by the DNS server and doesn't cache negative responses.
 - 
CaffeineDnsCachepublic CaffeineDnsCache(int minTtl, int maxTtl, int negativeTtl, long maxSize)Create a cache.- Parameters:
- minTtl- the minimum TTL
- maxTtl- the maximum TTL
- negativeTtl- the TTL for failed queries
 
 
- 
 - 
Method Detail- 
minTtlpublic int minTtl() Returns the minimum TTL of the cached DNS resource records (in seconds).- See Also:
- maxTtl()
 
 - 
maxTtlpublic int maxTtl() Returns the maximum TTL of the cached DNS resource records (in seconds).- See Also:
- minTtl()
 
 - 
negativeTtlpublic int negativeTtl() Returns the TTL of the cache for the failed DNS queries (in seconds). The default value is0, which disables the cache for negative results.
 - 
maxSizepublic long maxSize() Returns the maximum number of elements allows in the cache.
 - 
clearpublic void clear() - Specified by:
- clearin interface- io.netty.resolver.dns.DnsCache
 
 - 
clearpublic boolean clear(String hostname) - Specified by:
- clearin interface- io.netty.resolver.dns.DnsCache
 
 - 
getpublic List<? extends io.netty.resolver.dns.DnsCacheEntry> get(String hostname, io.netty.handler.codec.dns.DnsRecord[] additionals) - Specified by:
- getin interface- io.netty.resolver.dns.DnsCache
 
 - 
cachepublic io.netty.resolver.dns.DnsCacheEntry cache(String hostname, io.netty.handler.codec.dns.DnsRecord[] additionals, InetAddress address, long originalTtl, io.netty.channel.EventLoop loop) Positive caching for normal lookups.- Specified by:
- cachein interface- io.netty.resolver.dns.DnsCache
 
 - 
cachepublic ExtendedDnsCacheEntry cache(String hostname, io.netty.handler.codec.dns.DnsPtrRecord ptrRecord, io.netty.channel.EventLoop loop) Positive caching for reverse lookups.- Specified by:
- cachein interface- ExtendedDnsCache
 
 - 
cachepublic io.netty.resolver.dns.DnsCacheEntry cache(String hostname, io.netty.handler.codec.dns.DnsRecord[] additionals, Throwable cause, io.netty.channel.EventLoop loop) Negative caching for failures (or empty reverse lookups).- Specified by:
- cachein interface- io.netty.resolver.dns.DnsCache
 
 - 
getSizepublic long getSize() 
 - 
registerMetricspublic void registerMetrics(com.codahale.metrics.MetricRegistry metrics) 
 - 
unregisterMetricspublic void unregisterMetrics(com.codahale.metrics.MetricRegistry metrics) 
 
- 
 
-