use of org.apache.flink.shaded.netty4.io.netty.channel.EventLoopGroup in project netty by netty.
the class AbstractSingleThreadEventLoopTest method testChannelsRegistered.
@Timeout(value = 5000, unit = TimeUnit.MILLISECONDS)
public void testChannelsRegistered() throws Exception {
EventLoopGroup group = newEventLoopGroup();
final SingleThreadEventLoop loop = (SingleThreadEventLoop) group.next();
try {
final Channel ch1 = newChannel();
final Channel ch2 = newChannel();
int rc = registeredChannels(loop);
boolean channelCountSupported = rc != -1;
if (channelCountSupported) {
assertEquals(0, registeredChannels(loop));
}
assertTrue(loop.register(ch1).syncUninterruptibly().isSuccess());
assertTrue(loop.register(ch2).syncUninterruptibly().isSuccess());
if (channelCountSupported) {
checkNumRegisteredChannels(loop, 2);
}
assertTrue(ch1.deregister().syncUninterruptibly().isSuccess());
if (channelCountSupported) {
checkNumRegisteredChannels(loop, 1);
}
} finally {
group.shutdownGracefully();
}
}
use of org.apache.flink.shaded.netty4.io.netty.channel.EventLoopGroup in project netty by netty.
the class AbstractSingleThreadEventLoopTest method shutdownBeforeStart.
@Test
@SuppressWarnings("deprecation")
public void shutdownBeforeStart() throws Exception {
EventLoopGroup group = newEventLoopGroup();
assertFalse(group.awaitTermination(2, TimeUnit.MILLISECONDS));
group.shutdown();
assertTrue(group.awaitTermination(200, TimeUnit.MILLISECONDS));
}
use of org.apache.flink.shaded.netty4.io.netty.channel.EventLoopGroup in project netty by netty.
the class AbstractSingleThreadEventLoopTest method shutdownGracefullyBeforeStart.
@Test
public void shutdownGracefullyBeforeStart() throws Exception {
EventLoopGroup group = newEventLoopGroup();
assertTrue(group.shutdownGracefully(200L, 1000L, TimeUnit.MILLISECONDS).await(500L));
}
use of org.apache.flink.shaded.netty4.io.netty.channel.EventLoopGroup in project netty by netty.
the class DefaultAuthoritativeDnsServerCacheTest method testExpireWithTTL0.
private static void testExpireWithTTL0(int days) {
EventLoopGroup group = new NioEventLoopGroup(1);
try {
EventLoop loop = group.next();
final DefaultAuthoritativeDnsServerCache cache = new DefaultAuthoritativeDnsServerCache();
cache.cache("netty.io", new InetSocketAddress(NetUtil.LOCALHOST, 53), days, loop);
} finally {
group.shutdownGracefully();
}
}
use of org.apache.flink.shaded.netty4.io.netty.channel.EventLoopGroup in project netty by netty.
the class DefaultAuthoritativeDnsServerCacheTest method testUnresolvedReplacedByResolved.
@Test
public void testUnresolvedReplacedByResolved() throws Exception {
InetSocketAddress unresolved = InetSocketAddress.createUnresolved("ns1", 53);
InetSocketAddress resolved1 = new InetSocketAddress(InetAddress.getByAddress("ns2", new byte[] { 10, 0, 0, 2 }), 53);
InetSocketAddress resolved2 = new InetSocketAddress(InetAddress.getByAddress("ns1", new byte[] { 10, 0, 0, 1 }), 53);
EventLoopGroup group = new DefaultEventLoopGroup(1);
try {
EventLoop loop = group.next();
final DefaultAuthoritativeDnsServerCache cache = new DefaultAuthoritativeDnsServerCache();
cache.cache("netty.io", unresolved, 100, loop);
cache.cache("netty.io", resolved1, 10000, loop);
DnsServerAddressStream entries = cache.get("netty.io");
assertEquals(2, entries.size());
assertEquals(unresolved, entries.next());
assertEquals(resolved1, entries.next());
cache.cache("netty.io", resolved2, 100, loop);
DnsServerAddressStream entries2 = cache.get("netty.io");
assertEquals(2, entries2.size());
assertEquals(resolved2, entries2.next());
assertEquals(resolved1, entries2.next());
} finally {
group.shutdownGracefully();
}
}
Aggregations