Search in sources :

Example 1 with SingletonDnsServerAddressStreamProvider

use of io.netty.resolver.dns.SingletonDnsServerAddressStreamProvider in project crate by crate.

the class SrvUnicastHostsProvider method buildResolver.

private DnsNameResolver buildResolver(Settings settings) {
    DnsNameResolverBuilder resolverBuilder = new DnsNameResolverBuilder(eventLoopGroup.next());
    resolverBuilder.channelType(NioDatagramChannel.class);
    InetSocketAddress resolverAddress = parseResolverAddress(settings);
    if (resolverAddress != null) {
        try {
            resolverBuilder.nameServerProvider(new SingletonDnsServerAddressStreamProvider(resolverAddress));
        } catch (IllegalArgumentException e) {
            LOGGER.warn("Could not create custom dns resolver. Using default resolver.", e);
        }
    }
    return resolverBuilder.build();
}
Also used : SingletonDnsServerAddressStreamProvider(io.netty.resolver.dns.SingletonDnsServerAddressStreamProvider) DnsNameResolverBuilder(io.netty.resolver.dns.DnsNameResolverBuilder) InetSocketAddress(java.net.InetSocketAddress)

Example 2 with SingletonDnsServerAddressStreamProvider

use of io.netty.resolver.dns.SingletonDnsServerAddressStreamProvider in project LogHub by fbacchella.

the class NettyNameResolver method configure.

@Override
public boolean configure(Properties properties) {
    DnsNameResolverBuilder builder = new DnsNameResolverBuilder(evg.next()).queryTimeoutMillis(Math.max(timeout - 1, 1) * 1000).channelType(NioDatagramChannel.class);
    try {
        if (getResolver() != null) {
            InetSocketAddress resolverAddr = new InetSocketAddress(InetAddress.getByName(getResolver()), 53);
            builder = builder.nameServerProvider(new SingletonDnsServerAddressStreamProvider(resolverAddr));
        }
    } catch (UnknownHostException e) {
        logger.error("Unknown resolver '{}': {}", getResolver(), e.getMessage());
        return false;
    }
    resolver = builder.build();
    CacheConfiguration config = properties.getDefaultCacheConfig("NameResolver", this).eternal(false).maxEntriesLocalHeap(cacheSize);
    hostCache = properties.getCache(config);
    return super.configure(properties);
}
Also used : SingletonDnsServerAddressStreamProvider(io.netty.resolver.dns.SingletonDnsServerAddressStreamProvider) DnsNameResolverBuilder(io.netty.resolver.dns.DnsNameResolverBuilder) UnknownHostException(java.net.UnknownHostException) InetSocketAddress(java.net.InetSocketAddress) CacheConfiguration(net.sf.ehcache.config.CacheConfiguration)

Aggregations

DnsNameResolverBuilder (io.netty.resolver.dns.DnsNameResolverBuilder)2 SingletonDnsServerAddressStreamProvider (io.netty.resolver.dns.SingletonDnsServerAddressStreamProvider)2 InetSocketAddress (java.net.InetSocketAddress)2 UnknownHostException (java.net.UnknownHostException)1 CacheConfiguration (net.sf.ehcache.config.CacheConfiguration)1