Class AbstractDnsResolverBuilder

java.lang.Object
com.linecorp.armeria.client.AbstractDnsResolverBuilder
Direct Known Subclasses:
DnsAddressEndpointGroupBuilder, DnsResolverGroupBuilder, DnsServiceEndpointGroupBuilder, DnsTextEndpointGroupBuilder

@UnstableApi public abstract class AbstractDnsResolverBuilder extends Object
A skeletal builder implementation for DNS resolvers.
  • Constructor Details

    • AbstractDnsResolverBuilder

      protected AbstractDnsResolverBuilder()
      Creates a new instance.
  • Method Details

    • traceEnabled

      @Deprecated public AbstractDnsResolverBuilder traceEnabled(boolean traceEnabled)
      Deprecated.
      Use dnsQueryLifecycleObserverFactory(DnsQueryLifecycleObserverFactory) with LoggingDnsQueryLifeCycleObserverFactory.
      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

      public AbstractDnsResolverBuilder queryTimeout(Duration queryTimeout)
      Sets the timeout of the DNS query performed by this resolver. 0 disables 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

      public AbstractDnsResolverBuilder queryTimeoutMillis(long queryTimeoutMillis)
      Sets the timeout of the DNS query performed by this resolver in milliseconds. 0 disables the timeout. If unspecified, 5000 ms will be used.
    • queryTimeoutForEachAttempt

      public AbstractDnsResolverBuilder queryTimeoutForEachAttempt(Duration 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 of queryTimeout(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 of queryTimeoutMillis(long) is used.
    • recursionDesired

      public AbstractDnsResolverBuilder recursionDesired(boolean 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

      public AbstractDnsResolverBuilder maxQueriesPerResolve(int 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 the DnsServerAddressStream.size(). For example, if maxQueriesPerResolve is 5 and DnsServerAddressStream.size() is 2, DNS queries can be executed up to 10 times. The DnsServerAddressStream is provided by DnsServerAddressStreamProvider.
      See Also:
    • serverAddresses

      public AbstractDnsResolverBuilder serverAddresses(InetSocketAddress... serverAddresses)
      Sets the DNS server addresses to send queries to. Operating system default is used by default.
    • serverAddresses

      public AbstractDnsResolverBuilder serverAddresses(Iterable<InetSocketAddress> serverAddresses)
      Sets the DNS server addresses to send queries to. Operating system default is used by default.
    • serverAddressStreamProvider

      protected final io.netty.resolver.dns.DnsServerAddressStreamProvider serverAddressStreamProvider()
      Returns the DnsServerAddressStreamProvider.
    • serverAddressStreamProvider

      public AbstractDnsResolverBuilder serverAddressStreamProvider(io.netty.resolver.dns.DnsServerAddressStreamProvider serverAddressStreamProvider)
      Sets the DnsServerAddressStreamProvider which is used to determine which DNS server is used to resolve each hostname.
    • dnsServerAddressStreamProvider

      @Deprecated public AbstractDnsResolverBuilder dnsServerAddressStreamProvider(io.netty.resolver.dns.DnsServerAddressStreamProvider dnsServerAddressStreamProvider)
      Sets the DnsServerAddressStreamProvider which is used to determine which DNS server is used to resolve each hostname.
    • maxPayloadSize

      public AbstractDnsResolverBuilder maxPayloadSize(int maxPayloadSize)
      Sets the capacity of the datagram packet buffer in bytes.
    • optResourceEnabled

      public AbstractDnsResolverBuilder 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. Some DNS Server may not support this and so fail to answer queries.
    • hostsFileEntriesResolver

      protected final io.netty.resolver.HostsFileEntriesResolver hostsFileEntriesResolver()
      Returns the HostsFileEntriesResolver.
    • hostsFileEntriesResolver

      public AbstractDnsResolverBuilder hostsFileEntriesResolver(io.netty.resolver.HostsFileEntriesResolver hostsFileEntriesResolver)
      Sets the HostsFileEntriesResolver which is used to first check if the hostname is locally aliased.
    • dnsQueryLifecycleObserverFactory

      public AbstractDnsResolverBuilder dnsQueryLifecycleObserverFactory(io.netty.resolver.dns.DnsQueryLifecycleObserverFactory observerFactory)
      Sets the DnsQueryLifecycleObserverFactory that is used to generate objects which can observe individual DNS queries.
    • disableDnsQueryMetrics

      @Deprecated public AbstractDnsResolverBuilder disableDnsQueryMetrics()
      Deprecated.
      Disables the default DnsQueryLifecycleObserverFactory that collects DNS query metrics through MeterRegistry.
    • enableDnsQueryMetrics

      public AbstractDnsResolverBuilder enableDnsQueryMetrics(boolean enable)
      Enables the default DnsQueryLifecycleObserverFactory that collects DNS query metrics through MeterRegistry. This option is enabled by default.
    • searchDomains

      protected final List<String> searchDomains()
      Returns the search domains of the resolver.
    • searchDomains

      public AbstractDnsResolverBuilder searchDomains(String... searchDomains)
      Sets the search domains of the resolver.
    • searchDomains

      public AbstractDnsResolverBuilder searchDomains(Iterable<String> 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

      public AbstractDnsResolverBuilder ndots(int ndots)
      Sets the number of dots which must appear in a name before an initial absolute query is made.
    • decodeIdn

      public AbstractDnsResolverBuilder decodeIdn(boolean decodeIdn)
      Sets if the domain and host names should be decoded to unicode when received. See rfc3492. This flag is enabled by default.
    • meterRegistry

      @Nullable protected final @Nullable io.micrometer.core.instrument.MeterRegistry meterRegistry()
      Returns MeterRegistry that collects the DNS query metrics.
    • meterRegistry

      public AbstractDnsResolverBuilder meterRegistry(io.micrometer.core.instrument.MeterRegistry meterRegistry)
      Sets MeterRegistry to collect the DNS query metrics.
    • cacheSpec

      protected final String cacheSpec()
      Returns the Caffeine specification string.
    • cacheSpec

      public AbstractDnsResolverBuilder cacheSpec(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) and dnsCache(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

      public AbstractDnsResolverBuilder ttl(int minTtl, int maxTtl)
      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 is 1 and Integer.MAX_VALUE, which practically tells this resolver to respect the TTL from the DNS server.

      Note that ttl(int, int) and dnsCache(DnsCache) are mutually exclusive.

    • negativeTtl

      protected final int negativeTtl()
      Returns the negative TTL of the failed DNS queries in seconds.
    • negativeTtl

      public AbstractDnsResolverBuilder negativeTtl(int negativeTtl)
      Sets the TTL of the cache for the failed DNS queries in seconds. The default value is 0 which means that the DNS resolver does not cache when DNS queries are failed.

      Note that negativeTtl(int) and dnsCache(DnsCache) are mutually exclusive.

    • dnsCache

      @UnstableApi public AbstractDnsResolverBuilder dnsCache(DnsCache dnsCache)
      Sets the DnsCache that caches the resolved DnsRecords and the cause of a failure if negative cache is activated. This option is useful if you want to share a DnsCache with multiple DNS resolvers. If unspecified, the default DnsCache is used.

      Note that if cacheSpec(String), ttl(int, int), or negativeTtl(int) is set, the DNS resolver will create its own DnsCache using the properties. Therefore, cacheSpec(String), ttl(int, int), and negativeTtl(int) are mutually exclusive with dnsCache(DnsCache).

    • maybeCreateDnsCache

      @UnstableApi protected final DnsCache maybeCreateDnsCache()
      Returns a newly-created DnsCache if cacheSpec(String), ttl(int, int) or negativeTtl(int) is set. Returns the DnsCache specified by dnsCache(DnsCache) if it is set. Otherwise, returns the default DnsCache.
    • buildConfigurator

      @UnstableApi protected final Consumer<io.netty.resolver.dns.DnsNameResolverBuilder> buildConfigurator(io.netty.channel.EventLoopGroup eventLoopGroup)
      Builds a configurator that configures a DnsNameResolverBuilder with the properties set.