Package com.linecorp.armeria.client
Class AbstractDnsResolverBuilder
java.lang.Object
com.linecorp.armeria.client.AbstractDnsResolverBuilder
- Direct Known Subclasses:
DnsAddressEndpointGroupBuilder,DnsResolverGroupBuilder,DnsServiceEndpointGroupBuilder,DnsTextEndpointGroupBuilder
A skeletal builder implementation for DNS resolvers.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final Consumer<DnsNameResolverBuilder>buildConfigurator(EventLoopGroup eventLoopGroup) Builds a configurator that configures aDnsNameResolverBuilderwith the properties set.protected final StringReturns the Caffeine specification string.Sets 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.Deprecated.dnsQueryLifecycleObserverFactory(DnsQueryLifecycleObserverFactory observerFactory) Sets theDnsQueryLifecycleObserverFactorythat is used to generate objects which can observe individual DNS queries.dnsServerAddressStreamProvider(DnsServerAddressStreamProvider dnsServerAddressStreamProvider) Deprecated.enableDnsQueryMetrics(boolean enable) Enables the defaultDnsQueryLifecycleObserverFactorythat collects DNS query metrics throughMeterRegistry.protected final HostsFileEntriesResolverReturns theHostsFileEntriesResolver.hostsFileEntriesResolver(HostsFileEntriesResolver hostsFileEntriesResolver) Sets theHostsFileEntriesResolverwhich 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) Sets the base value of maximum allowed number of DNS queries to send when resolving a host name.protected final intmaxTtl()Returns the maximum TTL of the cached DNS resource records in seconds.protected final DnsCacheprotected final @Nullable MeterRegistryReturnsMeterRegistrythat collects the DNS query metrics.meterRegistry(MeterRegistry meterRegistry) SetsMeterRegistryto collect the DNS query metrics.protected final intminTtl()Returns the minimum TTL of the cached DNS resource records in seconds.protected final intndots()Returns the number of dots which must appear in a name before an initial absolute query is made.ndots(int ndots) Sets the number of dots which must appear in a name before an initial absolute query is made.protected final intReturns the negative TTL of the failed DNS queries in seconds.negativeTtl(int negativeTtl) Sets the TTL of the cache for the failed DNS queries in seconds.optResourceEnabled(boolean optResourceEnabled) Enables the automatic inclusion of an 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.queryTimeoutForEachAttempt(Duration queryTimeoutForEachAttempt) Sets the timeout of each DNS query performed by this endpoint group.protected final longReturns the timeout of the DNS query performed by this resolver in milliseconds.queryTimeoutMillis(long queryTimeoutMillis) Sets the timeout of the DNS query performed by this resolver in milliseconds.queryTimeoutMillisForEachAttempt(long queryTimeoutMillisForEachAttempt) Sets the timeout of each DNS query performed by this endpoint group in milliseconds.recursionDesired(boolean recursionDesired) Sets if this resolver has to send a DNS query with the RD (recursion desired) flag set.Returns the search domains of the resolver.searchDomains(Iterable<String> searchDomains) Sets the list of search domains of the resolver.searchDomains(String... searchDomains) Sets the search domains of the resolver.serverAddresses(Iterable<InetSocketAddress> serverAddresses) Sets the DNS server addresses to send queries to.serverAddresses(InetSocketAddress... serverAddresses) Sets the DNS server addresses to send queries to.protected final DnsServerAddressStreamProviderReturns theDnsServerAddressStreamProvider.serverAddressStreamProvider(DnsServerAddressStreamProvider serverAddressStreamProvider) Sets theDnsServerAddressStreamProviderwhich is used to determine which DNS server is used to resolve each hostname.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.
-
Constructor Details
-
AbstractDnsResolverBuilder
protected AbstractDnsResolverBuilder()Creates a new instance.
-
-
Method Details
-
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.0disables the timeout. If unspecified, 5000 ms will be used. -
queryTimeoutMillis
protected final long queryTimeoutMillis()Returns the timeout of the DNS query performed by this resolver in milliseconds. -
queryTimeoutMillis
Sets the timeout of the DNS query performed by this resolver in milliseconds.0disables the timeout. If unspecified, 5000 ms will be used. -
queryTimeoutForEachAttempt
Sets the timeout of each DNS query performed by this endpoint group. This option is useful if you want to set a timeout for each search domain resolution. If unspecified, the value ofqueryTimeout(Duration)is used. -
queryTimeoutMillisForEachAttempt
public AbstractDnsResolverBuilder queryTimeoutMillisForEachAttempt(long queryTimeoutMillisForEachAttempt) Sets the timeout of each DNS query performed by this endpoint group in milliseconds. This option is useful if you want to set a timeout for each search domain resolution. If unspecified, the value ofqueryTimeoutMillis(long)is used. -
recursionDesired
Sets if this resolver has to send a DNS query with the RD (recursion desired) flag set. This flag is enabled by default. -
maxQueriesPerResolve
Sets the base value of maximum allowed number of DNS queries to send when resolving a host name. The actual maximum allowed number of queries will be multiplied by theDnsServerAddressStream.size(). For example, ifmaxQueriesPerResolveis 5 andDnsServerAddressStream.size()is 2, DNS queries can be executed up to 10 times. TheDnsServerAddressStreamis provided byDnsServerAddressStreamProvider. -
serverAddresses
Sets the DNS server addresses to send queries to. Operating system default is used by default. -
serverAddresses
Sets the DNS server addresses to send queries to. Operating system default is used by default. -
serverAddressStreamProvider
Returns theDnsServerAddressStreamProvider. -
serverAddressStreamProvider
public AbstractDnsResolverBuilder serverAddressStreamProvider(DnsServerAddressStreamProvider serverAddressStreamProvider) Sets theDnsServerAddressStreamProviderwhich is used to determine which DNS server is used to resolve each hostname. -
dnsServerAddressStreamProvider
@Deprecated public AbstractDnsResolverBuilder dnsServerAddressStreamProvider(DnsServerAddressStreamProvider dnsServerAddressStreamProvider) Deprecated.Sets theDnsServerAddressStreamProviderwhich is used to determine which DNS server is used to resolve each hostname. -
maxPayloadSize
Sets the capacity of the datagram packet buffer in bytes. -
optResourceEnabled
Enables the automatic inclusion of an optional records that tries to give the remote DNS server a hint about how much data the resolver can read per response. Some DNS Server may not support this and so fail to answer queries. -
hostsFileEntriesResolver
Returns theHostsFileEntriesResolver. -
hostsFileEntriesResolver
public AbstractDnsResolverBuilder hostsFileEntriesResolver(HostsFileEntriesResolver hostsFileEntriesResolver) Sets theHostsFileEntriesResolverwhich is used to first check if the hostname is locally aliased. -
dnsQueryLifecycleObserverFactory
public AbstractDnsResolverBuilder dnsQueryLifecycleObserverFactory(DnsQueryLifecycleObserverFactory observerFactory) Sets theDnsQueryLifecycleObserverFactorythat is used to generate objects which can observe individual DNS queries. -
disableDnsQueryMetrics
Deprecated.UseenableDnsQueryMetrics(boolean)instead.Disables the defaultDnsQueryLifecycleObserverFactorythat collects DNS query metrics throughMeterRegistry. -
enableDnsQueryMetrics
Enables the defaultDnsQueryLifecycleObserverFactorythat collects DNS query metrics throughMeterRegistry. This option is enabled by default. -
searchDomains
Returns the search domains of the resolver. -
searchDomains
Sets the search domains of the resolver. -
searchDomains
Sets the list of search domains of the resolver. -
ndots
protected final int ndots()Returns the number of dots which must appear in a name before an initial absolute query is made. -
ndots
Sets the number of dots which must appear in a name before an initial absolute query is made. -
decodeIdn
Sets if the domain and host names should be decoded to unicode when received. See rfc3492. This flag is enabled by default. -
meterRegistry
ReturnsMeterRegistrythat collects the DNS query metrics. -
meterRegistry
SetsMeterRegistryto collect the DNS query metrics. -
cacheSpec
Returns the Caffeine specification string. -
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.Note that
cacheSpec(String)anddnsCache(DnsCache)are mutually exclusive. -
minTtl
protected final int minTtl()Returns the minimum TTL of the cached DNS resource records in seconds. -
maxTtl
protected final int maxTtl()Returns the maximum TTL of the cached DNS resource records in seconds. -
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 is1andInteger.MAX_VALUE, which practically tells this resolver to respect the TTL from the DNS server.Note that
ttl(int, int)anddnsCache(DnsCache)are mutually exclusive. -
negativeTtl
protected final int negativeTtl()Returns the negative TTL of the failed DNS queries in seconds. -
negativeTtl
Sets the TTL of the cache for the failed DNS queries in seconds. The default value is0which means that the DNS resolver does not cache when DNS queries are failed.Note that
negativeTtl(int)anddnsCache(DnsCache)are mutually exclusive. -
dnsCache
Sets theDnsCachethat caches the resolvedDnsRecords and the cause of a failure if negative cache is activated. This option is useful if you want to share aDnsCachewith multiple DNS resolvers. If unspecified, the defaultDnsCacheis used.Note that if
cacheSpec(String),ttl(int, int), ornegativeTtl(int)is set, the DNS resolver will create its ownDnsCacheusing the properties. Therefore,cacheSpec(String),ttl(int, int), andnegativeTtl(int)are mutually exclusive withdnsCache(DnsCache). -
maybeCreateDnsCache
Returns a newly-createdDnsCacheifcacheSpec(String),ttl(int, int)ornegativeTtl(int)is set. Returns theDnsCachespecified bydnsCache(DnsCache)if it is set. Otherwise, returns the defaultDnsCache. -
buildConfigurator
@UnstableApi protected final Consumer<DnsNameResolverBuilder> buildConfigurator(EventLoopGroup eventLoopGroup) Builds a configurator that configures aDnsNameResolverBuilderwith the properties set.
-
enableDnsQueryMetrics(boolean)instead.