Class NettyDnsResolver
- java.lang.Object
-
- org.opennms.netmgt.dnsresolver.netty.NettyDnsResolver
-
- All Implemented Interfaces:
DnsResolver
public class NettyDnsResolver extends Object implements DnsResolver
Asynchronous DNS resolution using Netty. Creates multiple resolvers (aka contexts) (defaults to 2*num cores) against which the queries are randomized in order to improve performance. Uses a circuit breaker in order to ensure that callers do not continue to be bogged down if resolution fails.- Author:
- jwhite
-
-
Field Summary
Fields Modifier and Type Field Description static String
CIRCUIT_BREAKER_STATE_CHANGE_EVENT_UEI
-
Constructor Summary
Constructors Constructor Description NettyDnsResolver(EventForwarder eventForwarder, com.codahale.metrics.MetricRegistry metrics)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
destroy()
boolean
getBreakerEnabled()
int
getBreakerFailureRateThreshold()
int
getBreakerRingBufferSizeInClosedState()
int
getBreakerRingBufferSizeInHalfOpenState()
int
getBreakerWaitDurationInOpenState()
int
getBulkheadMaxConcurrentCalls()
long
getBulkheadMaxWaitDurationMillis()
io.github.resilience4j.circuitbreaker.CircuitBreaker
getCircuitBreaker()
long
getMaxCacheSize()
int
getMaxTtlSeconds()
int
getMinTtlSeconds()
io.netty.resolver.dns.DnsServerAddressStreamProvider
getNameServerProvider()
String
getNameservers()
int
getNegativeTtlSeconds()
int
getNumContexts()
long
getQueryTimeoutMillis()
void
init()
CompletableFuture<Optional<InetAddress>>
lookup(String hostname)
Perform a DNS lookup for the given hostname.CompletableFuture<Optional<String>>
reverseLookup(InetAddress inetAddress)
Perform a reverse DNS lookup for the given IP address.void
setBreakerEnabled(boolean breakerEnabled)
void
setBreakerFailureRateThreshold(int breakerFailureRateThreshold)
void
setBreakerRingBufferSizeInClosedState(int breakerRingBufferSizeInClosedState)
void
setBreakerRingBufferSizeInHalfOpenState(int breakerRingBufferSizeInHalfOpenState)
void
setBreakerWaitDurationInOpenState(int breakerWaitDurationInOpenState)
void
setBulkheadMaxConcurrentCalls(int bulkheadMaxConcurrentCalls)
void
setBulkheadMaxWaitDurationMillis(long bulkheadMaxWaitDurationMillis)
void
setMaxCacheSize(long maxCacheSize)
void
setMaxTtlSeconds(int maxTtlSeconds)
void
setMinTtlSeconds(int minTtlSeconds)
void
setNameservers(String nameservers)
void
setNegativeTtlSeconds(int negativeTtlSeconds)
void
setNumContexts(int numContexts)
void
setQueryTimeoutMillis(long queryTimeoutMillis)
static List<InetSocketAddress>
toSocketAddresses(String commaSeparatedAddressesWithPorts)
-
-
-
Field Detail
-
CIRCUIT_BREAKER_STATE_CHANGE_EVENT_UEI
public static final String CIRCUIT_BREAKER_STATE_CHANGE_EVENT_UEI
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
NettyDnsResolver
public NettyDnsResolver(EventForwarder eventForwarder, com.codahale.metrics.MetricRegistry metrics)
-
-
Method Detail
-
init
public void init()
-
destroy
public void destroy()
-
lookup
public CompletableFuture<Optional<InetAddress>> lookup(String hostname)
Description copied from interface:DnsResolver
Perform a DNS lookup for the given hostname. Returns a future that contains the lookup results. If the optional is empty the lookup was completed but no result was found.- Specified by:
lookup
in interfaceDnsResolver
- Parameters:
hostname
- hostname to lookup- Returns:
- a future
-
reverseLookup
public CompletableFuture<Optional<String>> reverseLookup(InetAddress inetAddress)
Description copied from interface:DnsResolver
Perform a reverse DNS lookup for the given IP address. Returns a future that contains the lookup results. If the optional is empty the lookup was completed but no result was found.- Specified by:
reverseLookup
in interfaceDnsResolver
- Parameters:
inetAddress
- IP address to lookup- Returns:
- a future
-
getBreakerEnabled
public boolean getBreakerEnabled()
-
setBreakerEnabled
public void setBreakerEnabled(boolean breakerEnabled)
-
getBreakerFailureRateThreshold
public int getBreakerFailureRateThreshold()
-
setBreakerFailureRateThreshold
public void setBreakerFailureRateThreshold(int breakerFailureRateThreshold)
-
getBreakerWaitDurationInOpenState
public int getBreakerWaitDurationInOpenState()
-
setBreakerWaitDurationInOpenState
public void setBreakerWaitDurationInOpenState(int breakerWaitDurationInOpenState)
-
getBreakerRingBufferSizeInHalfOpenState
public int getBreakerRingBufferSizeInHalfOpenState()
-
setBreakerRingBufferSizeInHalfOpenState
public void setBreakerRingBufferSizeInHalfOpenState(int breakerRingBufferSizeInHalfOpenState)
-
getBreakerRingBufferSizeInClosedState
public int getBreakerRingBufferSizeInClosedState()
-
setBreakerRingBufferSizeInClosedState
public void setBreakerRingBufferSizeInClosedState(int breakerRingBufferSizeInClosedState)
-
getBulkheadMaxConcurrentCalls
public int getBulkheadMaxConcurrentCalls()
-
setBulkheadMaxConcurrentCalls
public void setBulkheadMaxConcurrentCalls(int bulkheadMaxConcurrentCalls)
-
getBulkheadMaxWaitDurationMillis
public long getBulkheadMaxWaitDurationMillis()
-
setBulkheadMaxWaitDurationMillis
public void setBulkheadMaxWaitDurationMillis(long bulkheadMaxWaitDurationMillis)
-
getNumContexts
public int getNumContexts()
-
setNumContexts
public void setNumContexts(int numContexts)
-
getNameservers
public String getNameservers()
-
setNameservers
public void setNameservers(String nameservers)
-
getQueryTimeoutMillis
public long getQueryTimeoutMillis()
-
setQueryTimeoutMillis
public void setQueryTimeoutMillis(long queryTimeoutMillis)
-
getMinTtlSeconds
public int getMinTtlSeconds()
-
setMinTtlSeconds
public void setMinTtlSeconds(int minTtlSeconds)
-
getMaxTtlSeconds
public int getMaxTtlSeconds()
-
setMaxTtlSeconds
public void setMaxTtlSeconds(int maxTtlSeconds)
-
getNegativeTtlSeconds
public int getNegativeTtlSeconds()
-
setNegativeTtlSeconds
public void setNegativeTtlSeconds(int negativeTtlSeconds)
-
getMaxCacheSize
public long getMaxCacheSize()
-
setMaxCacheSize
public void setMaxCacheSize(long maxCacheSize)
-
getCircuitBreaker
public io.github.resilience4j.circuitbreaker.CircuitBreaker getCircuitBreaker()
-
getNameServerProvider
public io.netty.resolver.dns.DnsServerAddressStreamProvider getNameServerProvider()
-
toSocketAddresses
public static List<InetSocketAddress> toSocketAddresses(String commaSeparatedAddressesWithPorts)
-
-