Top Description Fields Constructors Methods
org.apache.hc.client5.http.impl

public Class InMemoryDnsResolver

extends Object
implements DnsResolver
Class Inheritance
All Implemented Interfaces
org.apache.hc.client5.http.DnsResolver
Annotations
@Contract
threading:STATELESS
Imports
java.net.InetAddress, .UnknownHostException, java.util.Arrays, .Map, java.util.concurrent.ConcurrentHashMap, org.apache.hc.client5.http.DnsResolver, org.apache.hc.core5.annotation.Contract, .ThreadingBehavior, org.apache.hc.core5.util.Args, org.slf4j.Logger, .LoggerFactory

In-memory DnsResolver implementation.
Since
4.2

Field Summary

Modifier and TypeField and Description
private final Map<String, InetAddress[]>
dnsMap

In-memory collection that will hold the associations between a host name and an array of InetAddress instances.

private static final Logger
LOG

Logger associated to this class.

Constructor Summary

AccessConstructor and Description
public
InMemoryDnsResolver()

Builds a DNS resolver that will resolve the host names against a collection held in-memory.

Method Summary

Modifier and TypeMethod and Description
public void
add(final String
The host name to be associated with the given IP.
host
,
final InetAddress...
array of IP addresses to be resolved by this DNS overrider to the given host name.
ips
)

Associates the given array of IP addresses to the given host in this DNS overrider.

public InetAddress[]
resolve(final String
The host name to be resolved by this resolver.
host
)

Implements org.apache.hc.client5.http.DnsResolver.resolve.

Returns the IP address for the specified host name, or null if the given host is not recognized or the associated IP address cannot be used to build an InetAddress instance.
public String
resolveCanonicalHostname(final String host)

Implements org.apache.hc.client5.http.DnsResolver.resolveCanonicalHostname.

Gets the fully qualified domain name for given host name.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

dnsMapback to summary
private final Map<String, InetAddress[]> dnsMap

In-memory collection that will hold the associations between a host name and an array of InetAddress instances.

LOGback to summary
private static final Logger LOG

Logger associated to this class.

Constructor Detail

InMemoryDnsResolverback to summary
public InMemoryDnsResolver()

Builds a DNS resolver that will resolve the host names against a collection held in-memory.

Method Detail

addback to summary
public void add(final String host, final InetAddress... ips)

Associates the given array of IP addresses to the given host in this DNS overrider. The IP addresses are assumed to be already resolved.

Parameters
host:String

The host name to be associated with the given IP.

ips:InetAddress[]

array of IP addresses to be resolved by this DNS overrider to the given host name.

resolveback to summary
public InetAddress[] resolve(final String host) throws UnknownHostException

Implements org.apache.hc.client5.http.DnsResolver.resolve.

Doc from org.apache.hc.client5.http.DnsResolver.resolve.

Returns the IP address for the specified host name, or null if the given host is not recognized or the associated IP address cannot be used to build an InetAddress instance.

Parameters
host:String

The host name to be resolved by this resolver.

Returns:InetAddress[]

The IP address associated to the given host name, or null if the host name is not known by the implementation class.

Annotations
@Override
resolveCanonicalHostnameback to summary
public String resolveCanonicalHostname(final String host) throws UnknownHostException

Implements org.apache.hc.client5.http.DnsResolver.resolveCanonicalHostname.

Doc from org.apache.hc.client5.http.DnsResolver.resolveCanonicalHostname.

Gets the fully qualified domain name for given host name.

Annotations
@Override