Class AddressResolverOptions

java.lang.Object
io.vertx.core.dns.AddressResolverOptions

public class AddressResolverOptions extends Object
Configuration options for Vert.x hostname resolver. The resolver uses the local hosts file and performs DNS A and AAAA queries.
Author:
Julien Viet
  • Field Details

    • DEFAULT_SERVERS

      public static final List<String> DEFAULT_SERVERS
      The default list of DNS servers = null (uses system name server's list like resolve.conf otherwise Google Public DNS)
    • DEFAULT_OPT_RESOURCE_ENABLED

      public static final boolean DEFAULT_OPT_RESOURCE_ENABLED
      The default value for setOptResourceEnabled(boolean) = false
      See Also:
    • DEFAULT_CACHE_MIN_TIME_TO_LIVE

      public static final int DEFAULT_CACHE_MIN_TIME_TO_LIVE
      The default value for the cache min TTL = 0
      See Also:
    • DEFAULT_CACHE_MAX_TIME_TO_LIVE

      public static final int DEFAULT_CACHE_MAX_TIME_TO_LIVE
      The default value for the cache max TTL = 0x7fffffff
      See Also:
    • DEFAULT_CACHE_NEGATIVE_TIME_TO_LIVE

      public static final int DEFAULT_CACHE_NEGATIVE_TIME_TO_LIVE
      The default value for the negative cache TTL = 0
      See Also:
    • DEFAULT_QUERY_TIMEOUT

      public static final int DEFAULT_QUERY_TIMEOUT
      The default value for the query timeout in millis = 5000
      See Also:
    • DEFAULT_HOSTS_REFRESH_PERIOD_UNIT

      public static final TimeUnit DEFAULT_HOSTS_REFRESH_PERIOD_UNIT
      The default time unit for the hosts refresh value = NANOSECONDS
    • DEFAULT_HOSTS_REFRESH_PERIOD

      public static final int DEFAULT_HOSTS_REFRESH_PERIOD
      The default value for the hosts refresh value = 0 (disabled)
      See Also:
    • DEFAULT_MAX_QUERIES

      public static final int DEFAULT_MAX_QUERIES
      The default value for the max dns queries per query = 4
      See Also:
    • DEFAULT_RD_FLAG

      public static final boolean DEFAULT_RD_FLAG
      The default value of the rd flag = true
      See Also:
    • DEFAULT_SEARCH_DOMAINS

      public static final List<String> DEFAULT_SEARCH_DOMAINS
      The default value of search domains = null
    • DEFAULT_NDOTS

      public static final int DEFAULT_NDOTS
      The default ndots value = loads the value from the OS on Linux otherwise use the value 1
    • DEFAULT_ROTATE_SERVERS

      public static final boolean DEFAULT_ROTATE_SERVERS
      The default servers rotate value = loads the value from the OS on Linux otherwise use the value false
    • DEFAULT_ROUND_ROBIN_INET_ADDRESS

      public static final boolean DEFAULT_ROUND_ROBIN_INET_ADDRESS
      The default round-robin inet address = false
      See Also:
  • Constructor Details

    • AddressResolverOptions

      public AddressResolverOptions()
    • AddressResolverOptions

      public AddressResolverOptions(AddressResolverOptions other)
    • AddressResolverOptions

      public AddressResolverOptions(JsonObject json)
  • Method Details

    • getHostsPath

      public String getHostsPath()
      Returns:
      the path to the alternate hosts configuration file
    • setHostsPath

      public AddressResolverOptions setHostsPath(String hostsPath)
      Set the path of an alternate hosts configuration file to use instead of the one provided by the os.

      The default value is null, so the operating system hosts config is used.

      Parameters:
      hostsPath - the hosts path
      Returns:
      a reference to this, so the API can be used fluently
    • getHostsValue

      public Buffer getHostsValue()
      Returns:
      the hosts configuration file value
    • setHostsValue

      public AddressResolverOptions setHostsValue(Buffer hostsValue)
      Set an alternate hosts configuration file to use instead of the one provided by the os.

      The value should contain the hosts content literaly, for instance 127.0.0.1 localhost

      The default value is null, so the operating system hosts config is used.

      Parameters:
      hostsValue - the hosts content
      Returns:
      a reference to this, so the API can be used fluently
    • getHostsRefreshPeriodUnit

      public TimeUnit getHostsRefreshPeriodUnit()
      Returns:
      the hosts configuration refresh period time unit
    • setHostsRefreshPeriodUnit

      public AddressResolverOptions setHostsRefreshPeriodUnit(TimeUnit hostsRefreshPeriodUnit)
      Set the hosts configuration refresh period time unit. If not specified, default is nanoseconds.
      Parameters:
      hostsRefreshPeriodUnit - specify time unit
      Returns:
      a reference to this, so the API can be used fluently
    • getHostsRefreshPeriod

      public int getHostsRefreshPeriod()
      Returns:
      the hosts configuration refresh period in time unit specified by getHostsRefreshPeriodUnit().
    • setHostsRefreshPeriod

      public AddressResolverOptions setHostsRefreshPeriod(int hostsRefreshPeriod)
      Set the hosts configuration refresh period in time unit specified by getHostsRefreshPeriodUnit(), 0 disables it.

      The resolver caches the hosts configuration file after it has read it. When the content of this file can change, setting a positive refresh period will load the configuration file again when necessary.

      Parameters:
      hostsRefreshPeriod - the hosts configuration refresh period
    • getServers

      public List<String> getServers()
      Returns:
      the list of dns server
    • setServers

      public AddressResolverOptions setServers(List<String> servers)
      Set the list of DNS server addresses, an address is the IP of the dns server, followed by an optional colon and a port, e.g 8.8.8.8 or {code 192.168.0.1:40000}. When the list is empty, the resolver will use the list of the system DNS server addresses from the environment, if that list cannot be retrieved it will use Google's public DNS servers "8.8.8.8" and "8.8.4.4".
      Parameters:
      servers - the list of DNS servers
      Returns:
      a reference to this, so the API can be used fluently
    • addServer

      public AddressResolverOptions addServer(String server)
      Add a DNS server address.
      Parameters:
      server - the server to add
      Returns:
      a reference to this, so the API can be used fluently
    • isOptResourceEnabled

      public boolean isOptResourceEnabled()
      Returns:
      true if an optional record is automatically included in DNS queries
    • setOptResourceEnabled

      public AddressResolverOptions setOptResourceEnabled(boolean optResourceEnabled)
      Set to true to enable the automatic inclusion in DNS queries of an optional record that hints the remote DNS server about how much data the resolver can read per response.
      Parameters:
      optResourceEnabled - true to enable, false otherwise
      Returns:
      a reference to this, so the API can be used fluently
    • getCacheMinTimeToLive

      public int getCacheMinTimeToLive()
      Returns:
      the cache min TTL in seconds
    • setCacheMinTimeToLive

      public AddressResolverOptions setCacheMinTimeToLive(int cacheMinTimeToLive)
      Set the cache minimum TTL value in seconds. After resolution successful IP addresses are cached with their DNS response TTL, use this to set a minimum value to all responses TTL.
      Parameters:
      cacheMinTimeToLive - the cache min TTL in seconds
      Returns:
      a reference to this, so the API can be used fluently
    • getCacheMaxTimeToLive

      public int getCacheMaxTimeToLive()
      Returns:
      the cache max TTL in seconds
    • setCacheMaxTimeToLive

      public AddressResolverOptions setCacheMaxTimeToLive(int cacheMaxTimeToLive)
      Set the cache maximum TTL value in seconds. After successful resolution IP addresses are cached with their DNS response TTL, use this to set a maximum value to all responses TTL.
      Parameters:
      cacheMaxTimeToLive - the cache max TTL in seconds
      Returns:
      a reference to this, so the API can be used fluently
    • getCacheNegativeTimeToLive

      public int getCacheNegativeTimeToLive()
      Returns:
      the cache negative TTL in seconds
    • setCacheNegativeTimeToLive

      public AddressResolverOptions setCacheNegativeTimeToLive(int cacheNegativeTimeToLive)
      Set the negative cache TTL value in seconds. After a failed hostname resolution, DNS queries won't be retried for a period of time equals to the negative TTL. This allows to reduce the response time of negative replies and reduce the amount of messages to DNS servers.
      Parameters:
      cacheNegativeTimeToLive - the cache negative TTL in seconds
      Returns:
      a reference to this, so the API can be used fluently
    • getQueryTimeout

      public long getQueryTimeout()
      Returns:
      the query timeout in milliseconds
    • setQueryTimeout

      public AddressResolverOptions setQueryTimeout(long queryTimeout)
      Set the query timeout in milliseconds, i.e the amount of time after a query is considered to be failed.
      Parameters:
      queryTimeout - the query timeout in milliseconds
      Returns:
      a reference to this, so the API can be used fluently
    • getMaxQueries

      public int getMaxQueries()
      Returns:
      the maximum number of queries to be sent during a resolution
    • setMaxQueries

      public AddressResolverOptions setMaxQueries(int maxQueries)
      Set the maximum number of queries when an hostname is resolved.
      Parameters:
      maxQueries - the max number of queries to be sent
      Returns:
      a reference to this, so the API can be used fluently
    • getRdFlag

      public boolean getRdFlag()
      Returns:
      the DNS queries Recursion Desired flag value
    • setRdFlag

      public AddressResolverOptions setRdFlag(boolean rdFlag)
      Set the DNS queries Recursion Desired flag value.
      Parameters:
      rdFlag - the flag value
      Returns:
      a reference to this, so the API can be used fluently
    • getSearchDomains

      public List<String> getSearchDomains()
      Returns:
      the list of search domains
    • setSearchDomains

      public AddressResolverOptions setSearchDomains(List<String> searchDomains)
      Set the lists of DNS search domains.

      When the search domain list is null, the effective search domain list will be populated using the system DNS search domains.

      Parameters:
      searchDomains - the search domains
    • addSearchDomain

      public AddressResolverOptions addSearchDomain(String searchDomain)
      Add a DNS search domain.
      Parameters:
      searchDomain - the search domain to add
      Returns:
      a reference to this, so the API can be used fluently
    • getNdots

      public int getNdots()
      Returns:
      the ndots value
    • setNdots

      public AddressResolverOptions setNdots(int ndots)
      Set the ndots value used when resolving using search domains, the default value is -1 which determines the value from the OS on Linux or uses the value 1.
      Parameters:
      ndots - the new ndots value
      Returns:
      a reference to this, so the API can be used fluently
    • isRotateServers

      public boolean isRotateServers()
      Returns:
      the value true when the dns server selection uses round robin
    • setRotateServers

      public AddressResolverOptions setRotateServers(boolean rotateServers)
      Set to true to enable round-robin selection of the dns server to use. It spreads the query load among the servers and avoids all lookup to hit the first server of the list.
      Returns:
      a reference to this, so the API can be used fluently
    • isRoundRobinInetAddress

      public boolean isRoundRobinInetAddress()
      Returns:
      the value true when the inet address selection uses round robin
    • setRoundRobinInetAddress

      public AddressResolverOptions setRoundRobinInetAddress(boolean roundRobinInetAddress)
      Set to true to enable round-robin inet address selection of the ip address to use.
      Returns:
      a reference to this, so the API can be used fluently
    • toJson

      public JsonObject toJson()