Class AddressResolverOptions
java.lang.Object
io.vertx.core.dns.AddressResolverOptions
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default value for the cache max TTL = 0x7fffffffstatic final intThe default value for the cache min TTL = 0static final intThe default value for the negative cache TTL = 0static final intThe default value for the hosts refresh value = 0 (disabled)static final TimeUnitThe default time unit for the hosts refresh value = NANOSECONDSstatic final intThe default value for the max dns queries per query = 4static final intThe default ndots value = loads the value from the OS on Linux otherwise use the value 1static final booleanThe default value forsetOptResourceEnabled(boolean)= falsestatic final intThe default value for the query timeout in millis = 5000static final booleanThe default value of the rd flag = truestatic final booleanThe default servers rotate value = loads the value from the OS on Linux otherwise use the value falsestatic final booleanThe default round-robin inet address = falseThe default value of search domains = nullThe default list of DNS servers = null (uses system name server's list like resolve.conf otherwise Google Public DNS) -
Constructor Summary
ConstructorsConstructorDescription -
Method Summary
Modifier and TypeMethodDescriptionaddSearchDomain(String searchDomain) Add a DNS search domain.Add a DNS server address.intintintintintintgetNdots()longbooleanbooleanbooleanbooleansetCacheMaxTimeToLive(int cacheMaxTimeToLive) Set the cache maximum TTL value in seconds.setCacheMinTimeToLive(int cacheMinTimeToLive) Set the cache minimum TTL value in seconds.setCacheNegativeTimeToLive(int cacheNegativeTimeToLive) Set the negative cache TTL value in seconds.setHostsPath(String hostsPath) Set the path of an alternate hosts configuration file to use instead of the one provided by the os.setHostsRefreshPeriod(int hostsRefreshPeriod) Set the hosts configuration refresh period in time unit specified bygetHostsRefreshPeriodUnit(),0disables it.setHostsRefreshPeriodUnit(TimeUnit hostsRefreshPeriodUnit) Set the hosts configuration refresh period time unit.setHostsValue(Buffer hostsValue) Set an alternate hosts configuration file to use instead of the one provided by the os.setMaxQueries(int maxQueries) Set the maximum number of queries when an hostname is resolved.setNdots(int ndots) Set the ndots value used when resolving using search domains, the default value is-1which determines the value from the OS on Linux or uses the value1.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.setQueryTimeout(long queryTimeout) Set the query timeout in milliseconds, i.e the amount of time after a query is considered to be failed.setRdFlag(boolean rdFlag) Set the DNS queries Recursion Desired flag value.setRotateServers(boolean rotateServers) Set totrueto enable round-robin selection of the dns server to use.setRoundRobinInetAddress(boolean roundRobinInetAddress) Set totrueto enable round-robin inet address selection of the ip address to use.setSearchDomains(List<String> searchDomains) Set the lists of DNS search domains.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.g8.8.8.8or {code 192.168.0.1:40000}.toJson()
-
Field Details
-
DEFAULT_SERVERS
-
DEFAULT_OPT_RESOURCE_ENABLED
public static final boolean DEFAULT_OPT_RESOURCE_ENABLEDThe default value forsetOptResourceEnabled(boolean)= false- See Also:
-
DEFAULT_CACHE_MIN_TIME_TO_LIVE
public static final int DEFAULT_CACHE_MIN_TIME_TO_LIVEThe 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_LIVEThe 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_LIVEThe default value for the negative cache TTL = 0- See Also:
-
DEFAULT_QUERY_TIMEOUT
public static final int DEFAULT_QUERY_TIMEOUTThe default value for the query timeout in millis = 5000- See Also:
-
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_PERIODThe default value for the hosts refresh value = 0 (disabled)- See Also:
-
DEFAULT_MAX_QUERIES
public static final int DEFAULT_MAX_QUERIESThe default value for the max dns queries per query = 4- See Also:
-
DEFAULT_RD_FLAG
public static final boolean DEFAULT_RD_FLAGThe default value of the rd flag = true- See Also:
-
DEFAULT_SEARCH_DOMAINS
-
DEFAULT_NDOTS
public static final int DEFAULT_NDOTSThe 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_SERVERSThe 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_ADDRESSThe default round-robin inet address = false- See Also:
-
-
Constructor Details
-
AddressResolverOptions
public AddressResolverOptions() -
AddressResolverOptions
-
AddressResolverOptions
-
-
Method Details
-
getHostsPath
- Returns:
- the path to the alternate hosts configuration file
-
setHostsPath
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
- Returns:
- the hosts configuration file value
-
setHostsValue
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
- Returns:
- the hosts configuration refresh period time unit
-
setHostsRefreshPeriodUnit
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
Set the hosts configuration refresh period in time unit specified bygetHostsRefreshPeriodUnit(),0disables it. The resolver caches the hosts configurationfileafter 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
-
setServers
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.g8.8.8.8or {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
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
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
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
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
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
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
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
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
-
setSearchDomains
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
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
Set the ndots value used when resolving using search domains, the default value is-1which determines the value from the OS on Linux or uses the value1.- 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
truewhen the dns server selection uses round robin
-
setRotateServers
Set totrueto 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
truewhen the inet address selection uses round robin
-
setRoundRobinInetAddress
Set totrueto 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
-