DnsOptions.Builder
Stay organized with collections
Save and categorize content based on your preferences.
Inherited Method Summary
From class
java.lang.Object
Object
|
clone()
|
boolean
|
equals(Object arg0)
|
void
|
finalize()
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
Public Methods
Creates and returns the final DnsOptions
instance, based on the values in this
builder.
public
DnsOptions.Builder
enableStaleDns
(boolean enable)
Sets whether to use stale DNS results at all.
public
DnsOptions.Builder
preestablishConnectionsToStaleDnsResults
(boolean enable)
Sets whether Cronet should use stale cached DNS records to pre-establish connections.
If enabled, Cronet will optimistically pre-establish connections to servers that
matched the hostname at some point in the past and were cached but the cache entry
expired. Such connections won't be used further until a new DNS lookup confirms the
cached record was up to date.
To use cached DNS records straight away, use enableStaleDns(boolean)
and DnsOptions.StaleDnsOptions
configuration options.
This option may not be available for all networking protocols.
public
DnsOptions.Builder
setPersistHostCachePeriodMillis
(long persistHostCachePeriodMillis)
Sets the minimum period between subsequent writes to disk for DNS cache persistence.
Only relevant if persistHostCache(boolean)
is set to true.
Parameters
persistHostCachePeriodMillis |
|
Returns
- this builder for chaining.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2023-10-26 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-10-26 UTC."],[],[],null,["# DnsOptions.Builder\n\npublic static final class **DnsOptions.Builder** extends Object \nBuilder for [DnsOptions](../../../../reference/org/chromium/net/DnsOptions.html). \n\n### Public Method Summary\n\n|--------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [DnsOptions](../../../../reference/org/chromium/net/DnsOptions.html) | [build](../../../../reference/org/chromium/net/DnsOptions.Builder.html#build())() Creates and returns the final [DnsOptions](../../../../reference/org/chromium/net/DnsOptions.html) instance, based on the values in this builder. |\n| [DnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.Builder.html) | [enableStaleDns](../../../../reference/org/chromium/net/DnsOptions.Builder.html#enableStaleDns(boolean))(boolean enable) Sets whether to use stale DNS results at all. |\n| [DnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.Builder.html) | [persistHostCache](../../../../reference/org/chromium/net/DnsOptions.Builder.html#persistHostCache(boolean))(boolean persistHostCache) Sets whether the DNS cache should be persisted to disk. |\n| [DnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.Builder.html) | [preestablishConnectionsToStaleDnsResults](../../../../reference/org/chromium/net/DnsOptions.Builder.html#preestablishConnectionsToStaleDnsResults(boolean))(boolean enable) Sets whether Cronet should use stale cached DNS records to pre-establish connections. |\n| [DnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.Builder.html) | [setPersistDelay](../../../../reference/org/chromium/net/DnsOptions.Builder.html#setPersistDelay(java.time.Duration))(Duration persistToDiskPeriod) Same as [setPersistHostCachePeriodMillis(long)](../../../../reference/org/chromium/net/DnsOptions.Builder.html#setPersistHostCachePeriodMillis(long)) but using [Duration](../../../../reference/java/time/Duration.html). |\n| [DnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.Builder.html) | [setPersistHostCachePeriodMillis](../../../../reference/org/chromium/net/DnsOptions.Builder.html#setPersistHostCachePeriodMillis(long))(long persistHostCachePeriodMillis) Sets the minimum period between subsequent writes to disk for DNS cache persistence. |\n| [DnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.Builder.html) | [setStaleDnsOptions](../../../../reference/org/chromium/net/DnsOptions.Builder.html#setStaleDnsOptions(org.chromium.net.DnsOptions.StaleDnsOptions.Builder))([DnsOptions.StaleDnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html) staleDnsOptionsBuilder) |\n| [DnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.Builder.html) | [setStaleDnsOptions](../../../../reference/org/chromium/net/DnsOptions.Builder.html#setStaleDnsOptions(org.chromium.net.DnsOptions.StaleDnsOptions))([DnsOptions.StaleDnsOptions](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.html) staleDnsOptions) Sets detailed configuration for stale DNS. |\n| [DnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.Builder.html) | [useBuiltInDnsResolver](../../../../reference/org/chromium/net/DnsOptions.Builder.html#useBuiltInDnsResolver(boolean))(boolean enable) |\n\n### Inherited Method Summary\n\nFrom class java.lang.Object \n\n|------------------|---------------------------|\n| Object | clone() |\n| boolean | equals(Object arg0) |\n| void | finalize() |\n| final Class\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| String | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nPublic Methods\n--------------\n\n#### public [DnsOptions](../../../../reference/org/chromium/net/DnsOptions.html)\n**build**\n()\n\nCreates and returns the final [DnsOptions](../../../../reference/org/chromium/net/DnsOptions.html) instance, based on the values in this\nbuilder. \n\n#### public [DnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.Builder.html)\n**enableStaleDns**\n(boolean enable)\n\nSets whether to use stale DNS results at all. \n\n##### Parameters\n\n| enable | |\n|--------|---|\n\n##### Returns\n\n- the builder for chaining \n\n#### public [DnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.Builder.html)\n**persistHostCache**\n(boolean persistHostCache)\n\nSets whether the DNS cache should be persisted to disk.\n\nOnly relevant if [CronetEngine.Builder.setStoragePath(String)](../../../../reference/org/chromium/net/CronetEngine.Builder.html#setStoragePath(java.lang.String)) is\nset. \n\n##### Parameters\n\n| persistHostCache | |\n|------------------|---|\n\n##### Returns\n\n- the builder for chaining \n\n#### public [DnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.Builder.html)\n**preestablishConnectionsToStaleDnsResults**\n(boolean enable)\n\nSets whether Cronet should use stale cached DNS records to pre-establish connections.\n\nIf enabled, Cronet will optimistically pre-establish connections to servers that\nmatched the hostname at some point in the past and were cached but the cache entry\nexpired. Such connections won't be used further until a new DNS lookup confirms the\ncached record was up to date.\n\nTo use cached DNS records straight away, use [enableStaleDns(boolean)](../../../../reference/org/chromium/net/DnsOptions.Builder.html#enableStaleDns(boolean)) and [DnsOptions.StaleDnsOptions](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.html) configuration options.\n\nThis option may not be available for all networking protocols. \n\n##### Parameters\n\n| enable | |\n|--------|---|\n\n##### Returns\n\n- the builder for chaining \n\n#### public [DnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.Builder.html)\n**setPersistDelay**\n(Duration persistToDiskPeriod)\n\nSame as [setPersistHostCachePeriodMillis(long)](../../../../reference/org/chromium/net/DnsOptions.Builder.html#setPersistHostCachePeriodMillis(long)) but using [Duration](../../../../reference/java/time/Duration.html). \n\n##### Parameters\n\n| persistToDiskPeriod | |\n|---------------------|---|\n\n##### Returns\n\n- the builder for chaining \n\n#### public [DnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.Builder.html)\n**setPersistHostCachePeriodMillis**\n(long persistHostCachePeriodMillis)\n\nSets the minimum period between subsequent writes to disk for DNS cache persistence.\n\nOnly relevant if [persistHostCache(boolean)](../../../../reference/org/chromium/net/DnsOptions.Builder.html#persistHostCache(boolean)) is set to true. \n\n##### Parameters\n\n| persistHostCachePeriodMillis | |\n|------------------------------|---|\n\n##### Returns\n\n- the builder for chaining \n\n#### public [DnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.Builder.html)\n**setStaleDnsOptions**\n([DnsOptions.StaleDnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.Builder.html) staleDnsOptionsBuilder)\n\n\u003cbr /\u003e\n\n##### Parameters\n\n| staleDnsOptionsBuilder | |\n|------------------------|---|\n\n##### See Also\n\n- [setStaleDnsOptions(StaleDnsOptions)](../../../../reference/org/chromium/net/DnsOptions.Builder.html#setStaleDnsOptions(org.chromium.net.DnsOptions.StaleDnsOptions)) \n\n#### public [DnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.Builder.html)\n**setStaleDnsOptions**\n([DnsOptions.StaleDnsOptions](../../../../reference/org/chromium/net/DnsOptions.StaleDnsOptions.html) staleDnsOptions)\n\nSets detailed configuration for stale DNS.\n\nOnly relevant if [enableStaleDns(boolean)](../../../../reference/org/chromium/net/DnsOptions.Builder.html#enableStaleDns(boolean)) is set. \n\n##### Parameters\n\n| staleDnsOptions | |\n|-----------------|---|\n\n##### Returns\n\n- this builder for chaining. \n\n#### public [DnsOptions.Builder](../../../../reference/org/chromium/net/DnsOptions.Builder.html)\n**useBuiltInDnsResolver**\n(boolean enable)\n\n\u003cbr /\u003e\n\n##### Parameters\n\n| enable | |\n|--------|---|"]]