Class AbstractDnsResolverBuilder<SELF extends AbstractDnsResolverBuilder<SELF>>

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

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

    • AbstractDnsResolverBuilder

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

    • self

      protected final SELF self()
      Return this.
    • traceEnabled

      @Deprecated public SELF 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. This flag is enabled by default.
    • queryTimeout

      public SELF 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 SELF 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 SELF 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 SELF 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 SELF 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 SELF 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 SELF serverAddresses(InetSocketAddress... serverAddresses)
      Sets the DNS server addresses to send queries to. Operating system default is used by default.
    • serverAddresses

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

      protected final DnsServerAddressStreamProvider serverAddressStreamProvider()
    • serverAddressStreamProvider

      public SELF serverAddressStreamProvider(DnsServerAddressStreamProvider serverAddressStreamProvider)
      Sets the DnsServerAddressStreamProvider which is used to determine which DNS server is used to resolve each hostname.
    • dnsServerAddressStreamProvider

      @Deprecated public SELF dnsServerAddressStreamProvider(DnsServerAddressStreamProvider dnsServerAddressStreamProvider)
      Sets the DnsServerAddressStreamProvider which is used to determine which DNS server is used to resolve each hostname.
    • maxPayloadSize

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

      public SELF 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 HostsFileEntriesResolver hostsFileEntriesResolver()
    • hostsFileEntriesResolver

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

      public SELF dnsQueryLifecycleObserverFactory(DnsQueryLifecycleObserverFactory observerFactory)
      Sets the DnsQueryLifecycleObserverFactory that is used to generate objects which can observe individual DNS queries.
    • disableDnsQueryMetrics

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

      public SELF 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 SELF searchDomains(String... searchDomains)
      Sets the search domains of the resolver.
    • searchDomains

      public SELF 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 SELF ndots(int ndots)
      Sets the number of dots which must appear in a name before an initial absolute query is made.
    • decodeIdn

      public SELF 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 MeterRegistry meterRegistry()
      Returns MeterRegistry that collects the DNS query metrics.
    • meterRegistry

      public SELF meterRegistry(MeterRegistry meterRegistry)
      Sets MeterRegistry to collect the DNS query metrics.
    • cacheSpec

      protected final String cacheSpec()
    • cacheSpec

      public SELF 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 SELF 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 SELF 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 SELF 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<DnsNameResolverBuilder> buildConfigurator(EventLoopGroup eventLoopGroup)
      Builds a configurator that configures a DnsNameResolverBuilder with the properties set.