use of org.apache.flink.shaded.netty4.io.netty.channel.EventLoopGroup in project netty by netty.
the class DefaultAuthoritativeDnsServerCacheTest method testExpire.
@Test
public void testExpire() throws Throwable {
InetSocketAddress resolved1 = new InetSocketAddress(InetAddress.getByAddress("ns1", new byte[] { 10, 0, 0, 1 }), 53);
InetSocketAddress resolved2 = new InetSocketAddress(InetAddress.getByAddress("ns2", new byte[] { 10, 0, 0, 2 }), 53);
EventLoopGroup group = new DefaultEventLoopGroup(1);
try {
EventLoop loop = group.next();
final DefaultAuthoritativeDnsServerCache cache = new DefaultAuthoritativeDnsServerCache();
cache.cache("netty.io", resolved1, 1, loop);
cache.cache("netty.io", resolved2, 10000, loop);
Throwable error = loop.schedule(new Callable<Throwable>() {
@Override
public Throwable call() {
try {
assertNull(cache.get("netty.io"));
return null;
} catch (Throwable cause) {
return cause;
}
}
}, 1, TimeUnit.SECONDS).get();
if (error != null) {
throw error;
}
} finally {
group.shutdownGracefully();
}
}
use of org.apache.flink.shaded.netty4.io.netty.channel.EventLoopGroup in project netty by netty.
the class DefaultDnsCnameCacheTest method testExpire.
@Test
public void testExpire() throws Throwable {
EventLoopGroup group = new DefaultEventLoopGroup(1);
try {
EventLoop loop = group.next();
final DefaultDnsCnameCache cache = new DefaultDnsCnameCache();
cache.cache("netty.io", "mapping.netty.io", 1, loop);
Throwable error = loop.schedule(new Callable<Throwable>() {
@Override
public Throwable call() {
try {
assertNull(cache.get("netty.io"));
return null;
} catch (Throwable cause) {
return cause;
}
}
}, 1, TimeUnit.SECONDS).get();
if (error != null) {
throw error;
}
} finally {
group.shutdownGracefully();
}
}
use of org.apache.flink.shaded.netty4.io.netty.channel.EventLoopGroup in project netty by netty.
the class DefaultDnsCnameCacheTest method testExpireWithTTL0.
private static void testExpireWithTTL0(int days) {
EventLoopGroup group = new DefaultEventLoopGroup(1);
try {
EventLoop loop = group.next();
final DefaultDnsCnameCache cache = new DefaultDnsCnameCache();
cache.cache("netty.io", "mapping.netty.io", TimeUnit.DAYS.toSeconds(days), loop);
assertEquals("mapping.netty.io", cache.get("netty.io"));
} finally {
group.shutdownGracefully();
}
}
use of org.apache.flink.shaded.netty4.io.netty.channel.EventLoopGroup in project netty by netty.
the class DnsNameResolverClientSubnetTest method testSubnetQuery.
// See https://www.gsic.uva.es/~jnisigl/dig-edns-client-subnet.html
// Ignore as this needs to query real DNS servers.
@Disabled
@Test
public void testSubnetQuery() throws Exception {
EventLoopGroup group = new NioEventLoopGroup(1);
DnsNameResolver resolver = newResolver(group).build();
try {
// Same as:
// # /.bind-9.9.3-edns/bin/dig @ns1.google.com www.google.es +client=157.88.0.0/24
Future<List<InetAddress>> future = resolver.resolveAll("www.google.es", Collections.<DnsRecord>singleton(// 157.88.0.0 / 24
new DefaultDnsOptEcsRecord(1024, 24, SocketUtils.addressByName("157.88.0.0").getAddress())));
for (InetAddress address : future.syncUninterruptibly().getNow()) {
System.out.println(address);
}
} finally {
resolver.close();
group.shutdownGracefully(0, 0, TimeUnit.SECONDS);
}
}
use of org.apache.flink.shaded.netty4.io.netty.channel.EventLoopGroup in project netty by netty.
the class DefaultDnsCacheTest method testExpire.
@Test
public void testExpire() throws Throwable {
InetAddress addr1 = InetAddress.getByAddress(new byte[] { 10, 0, 0, 1 });
InetAddress addr2 = InetAddress.getByAddress(new byte[] { 10, 0, 0, 2 });
EventLoopGroup group = new DefaultEventLoopGroup(1);
try {
EventLoop loop = group.next();
final DefaultDnsCache cache = new DefaultDnsCache();
cache.cache("netty.io", null, addr1, 1, loop);
cache.cache("netty.io", null, addr2, 10000, loop);
Throwable error = loop.schedule(new Callable<Throwable>() {
@Override
public Throwable call() {
try {
assertNull(cache.get("netty.io", null));
return null;
} catch (Throwable cause) {
return cause;
}
}
}, 1, TimeUnit.SECONDS).get();
if (error != null) {
throw error;
}
} finally {
group.shutdownGracefully();
}
}
Aggregations