Top Description Fields Constructors Methods
io.netty5.resolver.dns

public final Class DnsNameResolverBuilder

extends Object
Class Inheritance
Imports
io.netty5.channel.ChannelFactory, .EventLoop, .ReflectiveChannelFactory, io.netty5.channel.socket.DatagramChannel, .SocketChannel, io.netty5.resolver.HostsFileEntriesResolver, .ResolvedAddressTypes, io.netty5.util.concurrent.Future, java.net.Inet4Address, .Inet6Address, .ProtocolFamily, .SocketAddress, java.util.ArrayList, .Arrays, .List

A DnsNameResolver builder.

Field Summary

Modifier and TypeField and Description
private AuthoritativeDnsServerCache
private ChannelFactory<? extends DatagramChannel>
private DnsCnameCache
private boolean
private boolean
private DnsQueryLifecycleObserverFactory
private DnsServerAddressStreamProvider
pack-priv volatile EventLoop
private HostsFileEntriesResolver
private SocketAddress
private int
private int
private Integer
private Integer
private int
private Integer
private boolean
private long
private boolean
private DnsCache
private ResolvedAddressTypes
private String[]
private ChannelFactory<? extends SocketChannel>

Constructor Summary

AccessConstructor and Description
public
DnsNameResolverBuilder()

Creates a new builder.

public
DnsNameResolverBuilder(EventLoop
the EventLoop which will perform the communication with the DNS servers.
eventLoop
)

Creates a new builder.

Method Summary

Modifier and TypeMethod and Description
public DnsNameResolverBuilder

Returns:

this
authoritativeDnsServerCache
(DnsCache
the authoritative NS servers cache
authoritativeDnsServerCache
)

Sets the cache for authoritative NS servers
public DnsNameResolverBuilder

Returns:

this
authoritativeDnsServerCache
(AuthoritativeDnsServerCache
the authoritative NS servers cache
authoritativeDnsServerCache
)

Sets the cache for authoritative NS servers

public DnsNameResolver

Returns:

a DnsNameResolver
build
()

Returns a new DnsNameResolver instance.

protected ChannelFactory<? extends DatagramChannel>
public DnsNameResolverBuilder

Returns:

this
channelFactory
(ChannelFactory<? extends DatagramChannel> channelFactory)

Sets the ChannelFactory that will create a DatagramChannel.

public DnsNameResolverBuilder

Returns:

this
channelType
(Class<? extends DatagramChannel>
the type
channelType
)

Sets the ChannelFactory as a ReflectiveChannelFactory of this type.

public DnsNameResolverBuilder

Returns:

this
cnameCache
(DnsCnameCache
the cache used to cache CNAME mappings for a domain.
cnameCache
)

Sets the cache for CNAME mappings.

public DnsNameResolverBuilder

Returns:

this
completeOncePreferredResolved
(boolean
true to enable, false to disable.
completeOncePreferredResolved
)

If true DnsNameResolver#resolveAll(String) will notify the returned Future as soon as all queries for the preferred address-type are complete.

public static ResolvedAddressTypes
computeResolvedAddressTypes(ProtocolFamily...
a valid sequence of ProtocolFamilys
protocolFamilies
)

Compute a ResolvedAddressTypes from some ProtocolFamilys.

public DnsNameResolverBuilder
copy()

Creates a copy of this DnsNameResolverBuilder

public DnsNameResolverBuilder

Returns:

this
decodeIdn
(boolean
if should get decoded
decodeIdn
)

Set if domain / host names should be decoded to unicode when received.

public DnsNameResolverBuilder

Returns:

this
dnsQueryLifecycleObserverFactory
(DnsQueryLifecycleObserverFactory
the factory used to generate objects which can observe individual DNS queries.
lifecycleObserverFactory
)

Set the factory used to generate objects which can observe individual DNS queries.

public DnsNameResolverBuilder

Returns:

this
eventLoop
(EventLoop eventLoop)

Sets the EventLoop which will perform the communication with the DNS servers.

public DnsNameResolverBuilder

Returns:

this
hostsFileEntriesResolver
(HostsFileEntriesResolver
the HostsFileEntriesResolver used to first check if the hostname is locally aliased.
hostsFileEntriesResolver
)

public DnsNameResolverBuilder

Returns:

this
localAddress
(SocketAddress
the bind address
localAddress
)

Configure the address that will be used to bind too.

public DnsNameResolverBuilder

Returns:

this
maxPayloadSize
(int
the capacity of the datagram packet buffer
maxPayloadSize
)

Sets the capacity of the datagram packet buffer (in bytes).

public DnsNameResolverBuilder

Returns:

this
maxQueriesPerResolve
(int
the max number of queries
maxQueriesPerResolve
)

Sets the maximum allowed number of DNS queries to send when resolving a host name.

protected DnsServerAddressStreamProvider
public DnsNameResolverBuilder

Returns:

this.
nameServerProvider
(DnsServerAddressStreamProvider dnsServerAddressStreamProvider)

Set the DnsServerAddressStreamProvider which is used to determine which DNS server is used to resolve each hostname.

public DnsNameResolverBuilder

Returns:

this
ndots
(int
the ndots value
ndots
)

Set the number of dots which must appear in a name before an initial absolute query is made.

public DnsNameResolverBuilder

Returns:

this
negativeTtl
(int
the TTL for failed cached queries
negativeTtl
)

Sets the TTL of the cache for the failed DNS queries (in seconds).

private AuthoritativeDnsServerCache
private DnsCache
private DnsCnameCache
public DnsNameResolverBuilder

Returns:

this
optResourceEnabled
(boolean
if optional records inclusion is enabled
optResourceEnabled
)

Enable the automatic inclusion of a optional records that tries to give the remote DNS server a hint about how much data the resolver can read per response.

public DnsNameResolverBuilder

Returns:

this
queryTimeoutMillis
(long
the query timeout
queryTimeoutMillis
)

Sets the timeout of each DNS query performed by this resolver (in milliseconds).

public DnsNameResolverBuilder

Returns:

this
recursionDesired
(boolean
true if recursion is desired
recursionDesired
)

Sets if this resolver has to send a DNS query with the RD (recursion desired) flag set.

public DnsNameResolverBuilder

Returns:

this
resolveCache
(DnsCache
the DNS resolution results cache
resolveCache
)

Sets the cache for resolution results.

public DnsNameResolverBuilder

Returns:

this
resolvedAddressTypes
(ResolvedAddressTypes
the address types
resolvedAddressTypes
)

Sets the list of the protocol families of the address resolved.

public DnsNameResolverBuilder

Returns:

this
searchDomains
(Iterable<String>
the search domains
searchDomains
)

Set the list of search domains of the resolver.

public DnsNameResolverBuilder

Returns:

this
socketChannelFactory
(ChannelFactory<? extends SocketChannel>
the ChannelFactory or null if TCP fallback should not be supported.
channelFactory
)

Sets the ChannelFactory that will create a SocketChannel for TCP fallback if needed.

public DnsNameResolverBuilder

Returns:

this
socketChannelType
(Class<? extends SocketChannel>
the type or null if TCP fallback should not be supported.
channelType
)

Sets the ChannelFactory as a ReflectiveChannelFactory of this type for TCP fallback if needed.

public DnsNameResolverBuilder

Returns:

this
ttl
(int
the minimum TTL
minTtl
,
int
the maximum TTL
maxTtl
)

Sets the minimum and maximum TTL of the cached DNS resource records (in seconds).

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

authoritativeDnsServerCacheback to summary
private AuthoritativeDnsServerCache authoritativeDnsServerCache
channelFactoryback to summary
private ChannelFactory<? extends DatagramChannel> channelFactory
cnameCacheback to summary
private DnsCnameCache cnameCache
completeOncePreferredResolvedback to summary
private boolean completeOncePreferredResolved
decodeIdnback to summary
private boolean decodeIdn
dnsQueryLifecycleObserverFactoryback to summary
private DnsQueryLifecycleObserverFactory dnsQueryLifecycleObserverFactory
dnsServerAddressStreamProviderback to summary
private DnsServerAddressStreamProvider dnsServerAddressStreamProvider
eventLoopback to summary
pack-priv volatile EventLoop eventLoop
hostsFileEntriesResolverback to summary
private HostsFileEntriesResolver hostsFileEntriesResolver
localAddressback to summary
private SocketAddress localAddress
maxPayloadSizeback to summary
private int maxPayloadSize
maxQueriesPerResolveback to summary
private int maxQueriesPerResolve
maxTtlback to summary
private Integer maxTtl
minTtlback to summary
private Integer minTtl
ndotsback to summary
private int ndots
negativeTtlback to summary
private Integer negativeTtl
optResourceEnabledback to summary
private boolean optResourceEnabled
queryTimeoutMillisback to summary
private long queryTimeoutMillis
recursionDesiredback to summary
private boolean recursionDesired
resolveCacheback to summary
private DnsCache resolveCache
resolvedAddressTypesback to summary
private ResolvedAddressTypes resolvedAddressTypes
searchDomainsback to summary
private String[] searchDomains
socketChannelFactoryback to summary
private ChannelFactory<? extends SocketChannel> socketChannelFactory

Constructor Detail

DnsNameResolverBuilderback to summary
public DnsNameResolverBuilder()

Creates a new builder.

DnsNameResolverBuilderback to summary
public DnsNameResolverBuilder(EventLoop eventLoop)

Creates a new builder.

Parameters
eventLoop:EventLoop

the EventLoop which will perform the communication with the DNS servers.

Method Detail

authoritativeDnsServerCacheback to summary
public DnsNameResolverBuilder authoritativeDnsServerCache(DnsCache authoritativeDnsServerCache)

Sets the cache for authoritative NS servers

Parameters
authoritativeDnsServerCache:DnsCache

the authoritative NS servers cache

Returns:DnsNameResolverBuilder

this

Annotations
@Deprecated
authoritativeDnsServerCacheback to summary
public DnsNameResolverBuilder authoritativeDnsServerCache(AuthoritativeDnsServerCache authoritativeDnsServerCache)

Sets the cache for authoritative NS servers

Parameters
authoritativeDnsServerCache:AuthoritativeDnsServerCache

the authoritative NS servers cache

Returns:DnsNameResolverBuilder

this

buildback to summary
public DnsNameResolver build()

Returns a new DnsNameResolver instance.

Returns:DnsNameResolver

a DnsNameResolver

channelFactoryback to summary
protected ChannelFactory<? extends DatagramChannel> channelFactory()
channelFactoryback to summary
public DnsNameResolverBuilder channelFactory(ChannelFactory<? extends DatagramChannel> channelFactory)

Sets the ChannelFactory that will create a DatagramChannel.

Parameters
channelFactory:ChannelFactory<? extends DatagramChannel>

the ChannelFactory

Returns:DnsNameResolverBuilder

this

channelTypeback to summary
public DnsNameResolverBuilder channelType(Class<? extends DatagramChannel> channelType)

Sets the ChannelFactory as a ReflectiveChannelFactory of this type. Use as an alternative to channelFactory(ChannelFactory).

Parameters
channelType:Class<? extends DatagramChannel>

the type

Returns:DnsNameResolverBuilder

this

cnameCacheback to summary
public DnsNameResolverBuilder cnameCache(DnsCnameCache cnameCache)

Sets the cache for CNAME mappings.

Parameters
cnameCache:DnsCnameCache

the cache used to cache CNAME mappings for a domain.

Returns:DnsNameResolverBuilder

this

completeOncePreferredResolvedback to summary
public DnsNameResolverBuilder completeOncePreferredResolved(boolean completeOncePreferredResolved)

If true DnsNameResolver#resolveAll(String) will notify the returned Future as soon as all queries for the preferred address-type are complete.

Parameters
completeOncePreferredResolved:boolean

true to enable, false to disable.

Returns:DnsNameResolverBuilder

this

computeResolvedAddressTypesback to summary
public static ResolvedAddressTypes computeResolvedAddressTypes(ProtocolFamily... protocolFamilies)

Compute a ResolvedAddressTypes from some ProtocolFamilys. An empty input will return the default value, based on "java.net" System properties. Valid inputs are (), (IPv4), (IPv6), (Ipv4, IPv6) and (IPv6, IPv4).

Parameters
protocolFamilies:ProtocolFamily[]

a valid sequence of ProtocolFamilys

Returns:ResolvedAddressTypes

a ResolvedAddressTypes

copyback to summary
public DnsNameResolverBuilder copy()

Creates a copy of this DnsNameResolverBuilder

Returns:DnsNameResolverBuilder

DnsNameResolverBuilder

decodeIdnback to summary
public DnsNameResolverBuilder decodeIdn(boolean decodeIdn)

Set if domain / host names should be decoded to unicode when received. See rfc3492.

Parameters
decodeIdn:boolean

if should get decoded

Returns:DnsNameResolverBuilder

this

dnsQueryLifecycleObserverFactoryback to summary
public DnsNameResolverBuilder dnsQueryLifecycleObserverFactory(DnsQueryLifecycleObserverFactory lifecycleObserverFactory)

Set the factory used to generate objects which can observe individual DNS queries.

Parameters
lifecycleObserverFactory:DnsQueryLifecycleObserverFactory

the factory used to generate objects which can observe individual DNS queries.

Returns:DnsNameResolverBuilder

this

eventLoopback to summary
public DnsNameResolverBuilder eventLoop(EventLoop eventLoop)

Sets the EventLoop which will perform the communication with the DNS servers.

Parameters
eventLoop:EventLoop

the EventLoop

Returns:DnsNameResolverBuilder

this

hostsFileEntriesResolverback to summary
public DnsNameResolverBuilder hostsFileEntriesResolver(HostsFileEntriesResolver hostsFileEntriesResolver)
Parameters
hostsFileEntriesResolver:HostsFileEntriesResolver

the HostsFileEntriesResolver used to first check if the hostname is locally aliased.

Returns:DnsNameResolverBuilder

this

localAddressback to summary
public DnsNameResolverBuilder localAddress(SocketAddress localAddress)

Configure the address that will be used to bind too. If null the default will be used.

Parameters
localAddress:SocketAddress

the bind address

Returns:DnsNameResolverBuilder

this

maxPayloadSizeback to summary
public DnsNameResolverBuilder maxPayloadSize(int maxPayloadSize)

Sets the capacity of the datagram packet buffer (in bytes). The default value is 4096 bytes.

Parameters
maxPayloadSize:int

the capacity of the datagram packet buffer

Returns:DnsNameResolverBuilder

this

maxQueriesPerResolveback to summary
public DnsNameResolverBuilder maxQueriesPerResolve(int maxQueriesPerResolve)

Sets the maximum allowed number of DNS queries to send when resolving a host name.

Parameters
maxQueriesPerResolve:int

the max number of queries

Returns:DnsNameResolverBuilder

this

nameServerProviderback to summary
protected DnsServerAddressStreamProvider nameServerProvider()
nameServerProviderback to summary
public DnsNameResolverBuilder nameServerProvider(DnsServerAddressStreamProvider dnsServerAddressStreamProvider)

Set the DnsServerAddressStreamProvider which is used to determine which DNS server is used to resolve each hostname.

Returns:DnsNameResolverBuilder

this.

ndotsback to summary
public DnsNameResolverBuilder ndots(int ndots)

Set the number of dots which must appear in a name before an initial absolute query is made. The default value is 1.

Parameters
ndots:int

the ndots value

Returns:DnsNameResolverBuilder

this

negativeTtlback to summary
public DnsNameResolverBuilder negativeTtl(int negativeTtl)

Sets the TTL of the cache for the failed DNS queries (in seconds).

Parameters
negativeTtl:int

the TTL for failed cached queries

Returns:DnsNameResolverBuilder

this

newAuthoritativeDnsServerCacheback to summary
private AuthoritativeDnsServerCache newAuthoritativeDnsServerCache()
newCacheback to summary
private DnsCache newCache()
newCnameCacheback to summary
private DnsCnameCache newCnameCache()
optResourceEnabledback to summary
public DnsNameResolverBuilder optResourceEnabled(boolean optResourceEnabled)

Enable the automatic inclusion of a optional records that tries to give the remote DNS server a hint about how much data the resolver can read per response. Some DNSServer may not support this and so fail to answer queries. If you find problems you may want to disable this.

Parameters
optResourceEnabled:boolean

if optional records inclusion is enabled

Returns:DnsNameResolverBuilder

this

queryTimeoutMillisback to summary
public DnsNameResolverBuilder queryTimeoutMillis(long queryTimeoutMillis)

Sets the timeout of each DNS query performed by this resolver (in milliseconds).

Parameters
queryTimeoutMillis:long

the query timeout

Returns:DnsNameResolverBuilder

this

recursionDesiredback to summary
public DnsNameResolverBuilder recursionDesired(boolean recursionDesired)

Sets if this resolver has to send a DNS query with the RD (recursion desired) flag set.

Parameters
recursionDesired:boolean

true if recursion is desired

Returns:DnsNameResolverBuilder

this

resolveCacheback to summary
public DnsNameResolverBuilder resolveCache(DnsCache resolveCache)

Sets the cache for resolution results.

Parameters
resolveCache:DnsCache

the DNS resolution results cache

Returns:DnsNameResolverBuilder

this

resolvedAddressTypesback to summary
public DnsNameResolverBuilder resolvedAddressTypes(ResolvedAddressTypes resolvedAddressTypes)

Sets the list of the protocol families of the address resolved. You can use DnsNameResolverBuilder#computeResolvedAddressTypes(java.net.ProtocolFamily...) to get a ResolvedAddressTypes out of some ProtocolFamilys.

Parameters
resolvedAddressTypes:ResolvedAddressTypes

the address types

Returns:DnsNameResolverBuilder

this

searchDomainsback to summary
public DnsNameResolverBuilder searchDomains(Iterable<String> searchDomains)

Set the list of search domains of the resolver.

Parameters
searchDomains:Iterable<String>

the search domains

Returns:DnsNameResolverBuilder

this

socketChannelFactoryback to summary
public DnsNameResolverBuilder socketChannelFactory(ChannelFactory<? extends SocketChannel> channelFactory)

Sets the ChannelFactory that will create a SocketChannel for TCP fallback if needed.

Parameters
channelFactory:ChannelFactory<? extends SocketChannel>

the ChannelFactory or null if TCP fallback should not be supported.

Returns:DnsNameResolverBuilder

this

socketChannelTypeback to summary
public DnsNameResolverBuilder socketChannelType(Class<? extends SocketChannel> channelType)

Sets the ChannelFactory as a ReflectiveChannelFactory of this type for TCP fallback if needed. Use as an alternative to socketChannelFactory(ChannelFactory).

Parameters
channelType:Class<? extends SocketChannel>

the type or null if TCP fallback should not be supported.

Returns:DnsNameResolverBuilder

this

ttlback to summary
public DnsNameResolverBuilder 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 0 and Integer#MAX_VALUE, which practically tells this resolver to respect the TTL from the DNS server.

Parameters
minTtl:int

the minimum TTL

maxTtl:int

the maximum TTL

Returns:DnsNameResolverBuilder

this