Class 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 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 interface DnsResolver
        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 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 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()