Top Description Inners Fields Constructors Methods
io.netty5.resolver.dns

public Class DefaultDnsCache

extends Object
implements DnsCache
Class Inheritance
All Implemented Interfaces
io.netty5.resolver.dns.DnsCache
Imports
io.netty5.channel.EventLoop, io.netty5.handler.codec.dns.DnsRecord, io.netty5.util.internal.StringUtil, java.net.InetAddress, java.util.Collections, .List, java.util.concurrent.ConcurrentMap

Default implementation of DnsCache, backed by a ConcurrentMap. If any additional DnsRecord is used, no caching takes place.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final int
private final int
private final int
private final Cache<DefaultDnsCache.DefaultDnsCacheEntry>

Constructor Summary

AccessConstructor and Description
public
DefaultDnsCache()

Create a cache that respects the TTL returned by the DNS server and doesn't cache negative responses.

public
DefaultDnsCache(int
the minimum TTL
minTtl
,
int
the maximum TTL
maxTtl
,
int
the TTL for failed queries
negativeTtl
)

Create a cache.

Method Summary

Modifier and TypeMethod and Description
private static String
appendDot(String hostname)

public DnsCacheEntry
cache(String
the hostname
hostname
,
DnsRecord[]
the additional records
additionals
,
InetAddress
the resolved address
address
,
long
the TTL as returned by the DNS server
originalTtl
,
EventLoop
the EventLoop used to register the TTL timeout
loop
)

Implements io.netty5.resolver.dns.DnsCache.cache.

Create a new DnsCacheEntry and cache a resolved address for a given hostname.
public DnsCacheEntry
cache(String
the hostname
hostname
,
DnsRecord[]
the additional records
additionals
,
Throwable
the resolution failure
cause
,
EventLoop
the EventLoop used to register the TTL timeout
loop
)

Implements io.netty5.resolver.dns.DnsCache.cache.

Cache the resolution failure for a given hostname.
public void
clear()

Implements io.netty5.resolver.dns.DnsCache.clear.

Clears all the resolved addresses cached by this resolver.
public boolean
clear(String hostname)

Implements io.netty5.resolver.dns.DnsCache.clear.

Clears the resolved addresses of the specified host name from the cache of this resolver.
private static boolean
emptyAdditionals(DnsRecord[] additionals)

public List<? extends DnsCacheEntry>
get(String
the hostname
hostname
,
DnsRecord[]
the additional records
additionals
)

Implements io.netty5.resolver.dns.DnsCache.get.

Return the cached entries for the given hostname.
public int
maxTtl()

Returns the maximum TTL of the cached DNS resource records (in seconds).

public int
minTtl()

Returns the minimum TTL of the cached DNS resource records (in seconds).

public int
negativeTtl()

Returns the TTL of the cache for the failed DNS queries (in seconds).

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

maxTtlback to summary
private final int maxTtl
minTtlback to summary
private final int minTtl
negativeTtlback to summary
private final int negativeTtl
resolveCacheback to summary
private final Cache<DefaultDnsCache.DefaultDnsCacheEntry> resolveCache

Constructor Detail

DefaultDnsCacheback to summary
public DefaultDnsCache()

Create a cache that respects the TTL returned by the DNS server and doesn't cache negative responses.

DefaultDnsCacheback to summary
public DefaultDnsCache(int minTtl, int maxTtl, int negativeTtl)

Create a cache.

Parameters
minTtl:int

the minimum TTL

maxTtl:int

the maximum TTL

negativeTtl:int

the TTL for failed queries

Method Detail

appendDotback to summary
private static String appendDot(String hostname)
cacheback to summary
public DnsCacheEntry cache(String hostname, DnsRecord[] additionals, InetAddress address, long originalTtl, EventLoop loop)

Implements io.netty5.resolver.dns.DnsCache.cache.

Doc from io.netty5.resolver.dns.DnsCache.cache.

Create a new DnsCacheEntry and cache a resolved address for a given hostname.

Parameters
hostname:String

the hostname

additionals:DnsRecord[]

the additional records

address:InetAddress

the resolved address

originalTtl:long

the TTL as returned by the DNS server

loop:EventLoop

the EventLoop used to register the TTL timeout

Returns:DnsCacheEntry

The DnsCacheEntry corresponding to this cache entry.

Annotations
@Override
cacheback to summary
public DnsCacheEntry cache(String hostname, DnsRecord[] additionals, Throwable cause, EventLoop loop)

Implements io.netty5.resolver.dns.DnsCache.cache.

Doc from io.netty5.resolver.dns.DnsCache.cache.

Cache the resolution failure for a given hostname. Be aware this won't be called with timeout / cancel / transport exceptions.

Parameters
hostname:String

the hostname

additionals:DnsRecord[]

the additional records

cause:Throwable

the resolution failure

loop:EventLoop

the EventLoop used to register the TTL timeout

Returns:DnsCacheEntry

The DnsCacheEntry corresponding to this cache entry, or null if this cache doesn't support caching failed responses.

Annotations
@Override
clearback to summary
public void clear()

Implements io.netty5.resolver.dns.DnsCache.clear.

Doc from io.netty5.resolver.dns.DnsCache.clear.

Clears all the resolved addresses cached by this resolver.

Annotations
@Override
clearback to summary
public boolean clear(String hostname)

Implements io.netty5.resolver.dns.DnsCache.clear.

Doc from io.netty5.resolver.dns.DnsCache.clear.

Clears the resolved addresses of the specified host name from the cache of this resolver.

Returns:boolean

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

Annotations
@Override
emptyAdditionalsback to summary
private static boolean emptyAdditionals(DnsRecord[] additionals)
getback to summary
public List<? extends DnsCacheEntry> get(String hostname, DnsRecord[] additionals)

Implements io.netty5.resolver.dns.DnsCache.get.

Doc from io.netty5.resolver.dns.DnsCache.get.

Return the cached entries for the given hostname.

Parameters
hostname:String

the hostname

additionals:DnsRecord[]

the additional records

Returns:List<? extends DnsCacheEntry>

the cached entries

Annotations
@Override
maxTtlback to summary
public int maxTtl()

Returns the maximum TTL of the cached DNS resource records (in seconds).

See Also
minTtl()
minTtlback to summary
public int minTtl()

Returns the minimum TTL of the cached DNS resource records (in seconds).

See Also
maxTtl()
negativeTtlback to summary
public int negativeTtl()

Returns the TTL of the cache for the failed DNS queries (in seconds). The default value is 0, which disables the cache for negative results.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
io.netty5.resolver.dns back to summary

private final Class DefaultDnsCache.DefaultDnsCacheEntry

extends Object
implements DnsCacheEntry
Class Inheritance
All Implemented Interfaces
io.netty5.resolver.dns.DnsCacheEntry

Field Summary

Modifier and TypeField and Description
private final InetAddress
private final Throwable
private final String

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv

Method Summary

Modifier and TypeMethod and Description
public InetAddress
address()

Implements io.netty5.resolver.dns.DnsCacheEntry.address.

Get the resolved address.
public Throwable
cause()

Implements io.netty5.resolver.dns.DnsCacheEntry.cause.

If the DNS query failed this will provide the rational.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

addressback to summary
private final InetAddress address
causeback to summary
private final Throwable cause
hostnameback to summary
private final String hostname

Constructor Detail

DefaultDnsCacheEntryback to summary
pack-priv DefaultDnsCacheEntry(String hostname, InetAddress address)
DefaultDnsCacheEntryback to summary
pack-priv DefaultDnsCacheEntry(String hostname, Throwable cause)

Method Detail

addressback to summary
public InetAddress address()

Implements io.netty5.resolver.dns.DnsCacheEntry.address.

Doc from io.netty5.resolver.dns.DnsCacheEntry.address.

Get the resolved address.

This may be null if the resolution failed, and in that case cause() will describe the failure.

Returns:InetAddress

the resolved address.

Annotations
@Override
causeback to summary
public Throwable cause()

Implements io.netty5.resolver.dns.DnsCacheEntry.cause.

Doc from io.netty5.resolver.dns.DnsCacheEntry.cause.

If the DNS query failed this will provide the rational.

Returns:Throwable

the rational for why the DNS query failed, or null if the query hasn't failed.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override