Package com.linecorp.armeria.client
Class DnsResolverGroupBuilder
java.lang.Object
com.linecorp.armeria.client.DnsResolverGroupBuilder
Builds an
AddressResolverGroup
which builds AddressResolver
s that update DNS caches
automatically. Standard DnsNameResolver
will only expire a cache entry after TTL,
meaning DNS queries after TTL will always take time to resolve. A refreshing AddressResolver
on the other hand updates the DNS cache automatically when TTL elapses,
meaning DNS queries after TTL will retrieve a refreshed result right away. If refreshing fails,
the AddressResolver
will retry with refreshBackoff(Backoff)
.
The refreshing AddressResolver
will only start auto refresh for a given hostname
on the second access before TTL to avoid auto-refreshing for queries that only happen once
(e.g., requests during server startup).
-
Method Summary
Modifier and TypeMethodDescriptionSets the Caffeine specification string of the cache that stores the domain names and their resolved addresses.decodeIdn(boolean decodeIdn)
Sets if the domain and host names should be decoded to unicode when received.Disables the defaultDnsQueryLifecycleObserverFactory
that collects DNS query metrics throughMeterRegistry
.dnsQueryLifecycleObserverFactory(DnsQueryLifecycleObserverFactory dnsQueryLifecycleObserverFactory)
SetsDnsQueryLifecycleObserverFactory
that is used to generate objects which can observe individual DNS queries.dnsServerAddressStreamProvider(DnsServerAddressStreamProvider dnsServerAddressStreamProvider)
SetsDnsServerAddressStreamProvider
which is used to determine which DNS server is used to resolve each hostname.hostsFileEntriesResolver(HostsFileEntriesResolver hostsFileEntriesResolver)
SetsHostsFileEntriesResolver
which is used to first check if the hostname is locally aliased.maxPayloadSize(int maxPayloadSize)
Sets the capacity of the datagram packet buffer in bytes.maxQueriesPerResolve(int maxQueriesPerResolve)
Returns the maximum allowed number of DNS queries to send when resolving a host name.ndots(int ndots)
Sets the number of dots which must appear in a name before an initial absolute query is made.negativeTtl(int negativeTtl)
Sets the TTL of the cache for the failed DNS queries in seconds.optResourceEnabled(boolean optResourceEnabled)
Enables the automatic inclusion of a optional records that tries to give the remote DNS server a hint about how much data the resolver can read per response.queryTimeout(Duration queryTimeout)
Sets the timeout of the DNS query performed by this resolver.queryTimeoutMillis(long queryTimeoutMillis)
Sets the timeout of the DNS query performed by this resolver in milliseconds.recursionDesired(boolean recursionDesired)
Sets if this resolver has to send a DNS query with the RD (recursion desired) flag set.refreshBackoff(Backoff refreshBackoff)
SetsBackoff
which is used when theDnsNameResolver
fails to update the cache.resolvedAddressTypes(ResolvedAddressTypes resolvedAddressTypes)
SetsResolvedAddressTypes
which is the list of the protocol families of the address resolved.searchDomains(Iterable<String> searchDomains)
Sets the list of search domains of the resolver.searchDomains(String... searchDomains)
Sets the search domains of the resolver.traceEnabled(boolean traceEnabled)
Sets if this resolver should generate detailed trace information in exception messages so that it is easier to understand the cause of resolution failure.ttl(int minTtl, int maxTtl)
Sets the minimum and maximum TTL of the cached DNS resource records in seconds.
-
Method Details
-
refreshBackoff
SetsBackoff
which is used when theDnsNameResolver
fails to update the cache. -
ttl
Sets the minimum and maximum TTL of the cached DNS resource records in seconds. If the TTL of the DNS resource record returned by the DNS server is less than the minimum TTL or greater than the maximum TTL, this resolver will ignore the TTL from the DNS server and use the minimum TTL or the maximum TTL instead respectively. The default value is1
andInteger.MAX_VALUE
, which practically tells this resolver to respect the TTL from the DNS server. -
negativeTtl
Sets the TTL of the cache for the failed DNS queries in seconds. The default value is0
which means that theAddressResolver
does not cache when DNS queries are failed. -
traceEnabled
Sets if this resolver should generate detailed trace information in exception messages so that it is easier to understand the cause of resolution failure. This flag is enabled by default. -
queryTimeout
Sets the timeout of the DNS query performed by this resolver.0
disables the timeout. -
queryTimeoutMillis
Sets the timeout of the DNS query performed by this resolver in milliseconds.0
disables the timeout. -
resolvedAddressTypes
SetsResolvedAddressTypes
which is the list of the protocol families of the address resolved. -
recursionDesired
Sets if this resolver has to send a DNS query with the RD (recursion desired) flag set. -
maxQueriesPerResolve
Returns the maximum allowed number of DNS queries to send when resolving a host name. -
maxPayloadSize
Sets the capacity of the datagram packet buffer in bytes. -
optResourceEnabled
Enables the automatic inclusion of a optional records that tries to give the remote DNS server a hint about how much data the resolver can read per response. Some DNSServer may not support this and so fail to answer queries. -
hostsFileEntriesResolver
public DnsResolverGroupBuilder hostsFileEntriesResolver(HostsFileEntriesResolver hostsFileEntriesResolver)SetsHostsFileEntriesResolver
which is used to first check if the hostname is locally aliased. -
dnsServerAddressStreamProvider
public DnsResolverGroupBuilder dnsServerAddressStreamProvider(DnsServerAddressStreamProvider dnsServerAddressStreamProvider)SetsDnsServerAddressStreamProvider
which is used to determine which DNS server is used to resolve each hostname. -
dnsQueryLifecycleObserverFactory
public DnsResolverGroupBuilder dnsQueryLifecycleObserverFactory(DnsQueryLifecycleObserverFactory dnsQueryLifecycleObserverFactory)SetsDnsQueryLifecycleObserverFactory
that is used to generate objects which can observe individual DNS queries. -
disableDnsQueryMetrics
Disables the defaultDnsQueryLifecycleObserverFactory
that collects DNS query metrics throughMeterRegistry
. -
searchDomains
Sets the list of search domains of the resolver. -
searchDomains
Sets the search domains of the resolver. -
ndots
Sets the number of dots which must appear in a name before an initial absolute query is made.- See Also:
DnsNameResolverBuilder.ndots(int)
-
decodeIdn
Sets if the domain and host names should be decoded to unicode when received. See rfc3492. This flag is enabled by default. -
cacheSpec
Sets the Caffeine specification string of the cache that stores the domain names and their resolved addresses. If not set,Flags.dnsCacheSpec()
is used by default.
-