DnsOptions.Builder

public static final class DnsOptions.Builder extends Object

Builder for DnsOptions.

Public Method Summary

DnsOptions
build()
Creates and returns the final DnsOptions instance, based on the values in this builder.
DnsOptions.Builder
enableStaleDns(boolean enable)
Sets whether to use stale DNS results at all.
DnsOptions.Builder
persistHostCache(boolean persistHostCache)
Sets whether the DNS cache should be persisted to disk.
DnsOptions.Builder
preestablishConnectionsToStaleDnsResults(boolean enable)
Sets whether Cronet should use stale cached DNS records to pre-establish connections.
DnsOptions.Builder
setPersistDelay(Duration persistToDiskPeriod)
DnsOptions.Builder
setPersistHostCachePeriodMillis(long persistHostCachePeriodMillis)
Sets the minimum period between subsequent writes to disk for DNS cache persistence.
DnsOptions.Builder
DnsOptions.Builder
setStaleDnsOptions(DnsOptions.StaleDnsOptions staleDnsOptions)
Sets detailed configuration for stale DNS.
DnsOptions.Builder
useBuiltInDnsResolver(boolean enable)

Inherited Method Summary

Public Methods

public DnsOptions build ()

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.

Parameters
enable
Returns
  • the builder for chaining

public DnsOptions.Builder persistHostCache (boolean persistHostCache)

Sets whether the DNS cache should be persisted to disk.

Only relevant if CronetEngine.Builder.setStoragePath(String) is set.

Parameters
persistHostCache
Returns
  • the builder for chaining

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.

Parameters
enable
Returns
  • the builder for chaining

public DnsOptions.Builder setPersistDelay (Duration persistToDiskPeriod)

Parameters
persistToDiskPeriod
Returns
  • the builder for chaining

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
  • the builder for chaining

public DnsOptions.Builder setStaleDnsOptions (DnsOptions.StaleDnsOptions.Builder staleDnsOptionsBuilder)

Parameters
staleDnsOptionsBuilder

public DnsOptions.Builder setStaleDnsOptions (DnsOptions.StaleDnsOptions staleDnsOptions)

Sets detailed configuration for stale DNS. Only relevant if enableStaleDns(boolean) is set.

Parameters
staleDnsOptions
Returns
  • this builder for chaining.

public DnsOptions.Builder useBuiltInDnsResolver (boolean enable)

Parameters
enable