Class NettyDnsResolver

  • All Implemented Interfaces:
    DnsResolver

    public class NettyDnsResolver
    extends java.lang.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 Detail

      • CIRCUIT_BREAKER_STATE_CHANGE_EVENT_UEI

        public static final java.lang.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 java.util.concurrent.CompletableFuture<java.util.Optional<java.net.InetAddress>> lookup​(java.lang.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 interface DnsResolver
        Parameters:
        hostname - hostname to lookup
        Returns:
        a future
      • reverseLookup

        public java.util.concurrent.CompletableFuture<java.util.Optional<java.lang.String>> reverseLookup​(java.net.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 interface DnsResolver
        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 java.lang.String getNameservers()
      • setNameservers

        public void setNameservers​(java.lang.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 java.util.List<java.net.InetSocketAddress> toSocketAddresses​(java.lang.String commaSeparatedAddressesWithPorts)