Search in sources :

Example 41 with DefaultChannelGroup

use of io.netty.channel.group.DefaultChannelGroup in project reactor-netty by reactor.

the class HttpServerTests method testTcpConfiguration_2.

@Test
@SuppressWarnings("deprecation")
void testTcpConfiguration_2() throws Exception {
    CountDownLatch latch = new CountDownLatch(10);
    LoopResources loop = LoopResources.create("testTcpConfiguration");
    ChannelGroup group = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
    doTestTcpConfiguration(HttpServer.from(configureTcpServer(TcpServer.create(), loop, group, latch)), HttpClient.from(configureTcpClient(TcpClient.create(), loop, group, latch)));
    assertThat(latch.await(30, TimeUnit.SECONDS)).isTrue();
    FutureMono.from(group.close()).then(loop.disposeLater()).block(Duration.ofSeconds(30));
}
Also used : DefaultChannelGroup(io.netty.channel.group.DefaultChannelGroup) LoopResources(reactor.netty.resources.LoopResources) CountDownLatch(java.util.concurrent.CountDownLatch) DefaultChannelGroup(io.netty.channel.group.DefaultChannelGroup) ChannelGroup(io.netty.channel.group.ChannelGroup) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) BaseHttpTest(reactor.netty.BaseHttpTest) Test(org.junit.jupiter.api.Test)

Example 42 with DefaultChannelGroup

use of io.netty.channel.group.DefaultChannelGroup in project cdap by caskdata.

the class NettyRouter method startUp.

@Override
protected void startUp() throws Exception {
    // If internal authorization enforcement is enabled, we avoid re-initialization of the token manager.
    if (SecurityUtil.isManagedSecurity(cConf) && !SecurityUtil.isInternalAuthEnabled(cConf)) {
        tokenValidator.startAndWait();
    }
    ChannelGroup channelGroup = new DefaultChannelGroup(ImmediateEventExecutor.INSTANCE);
    serverCancellable = startServer(createServerBootstrap(channelGroup), channelGroup);
    scheduleConfigReloadThread();
}
Also used : DefaultChannelGroup(io.netty.channel.group.DefaultChannelGroup) DefaultChannelGroup(io.netty.channel.group.DefaultChannelGroup) ChannelGroup(io.netty.channel.group.ChannelGroup)

Example 43 with DefaultChannelGroup

use of io.netty.channel.group.DefaultChannelGroup in project netty by netty.

the class ThreadPerChannelEventLoopGroupTest method runTest.

private static void runTest(ThreadPerChannelEventLoopGroup loopGroup) throws InterruptedException {
    int taskCount = 100;
    EventExecutor testExecutor = new TestEventExecutor();
    ChannelGroup channelGroup = new DefaultChannelGroup(testExecutor);
    while (taskCount-- > 0) {
        Channel channel = new EmbeddedChannel(NOOP_HANDLER);
        loopGroup.register(new DefaultChannelPromise(channel, testExecutor));
        channelGroup.add(channel);
    }
    channelGroup.close().sync();
    loopGroup.shutdownGracefully(100, 200, TimeUnit.MILLISECONDS).sync();
    assertTrue(loopGroup.isTerminated());
}
Also used : DefaultChannelGroup(io.netty.channel.group.DefaultChannelGroup) EventExecutor(io.netty.util.concurrent.EventExecutor) SingleThreadEventExecutor(io.netty.util.concurrent.SingleThreadEventExecutor) GlobalEventExecutor(io.netty.util.concurrent.GlobalEventExecutor) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) EmbeddedChannel(io.netty.channel.embedded.EmbeddedChannel) ChannelGroup(io.netty.channel.group.ChannelGroup) DefaultChannelGroup(io.netty.channel.group.DefaultChannelGroup)

Example 44 with DefaultChannelGroup

use of io.netty.channel.group.DefaultChannelGroup in project serve by pytorch.

the class ServerGroups method init.

public final void init() {
    allChannels = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
    serverGroup = Connector.newEventLoopGroup(2);
    childGroup = Connector.newEventLoopGroup(configManager.getNettyThreads());
    if (configManager.isMetricApiEnable()) {
        metricsGroup = Connector.newEventLoopGroup(1);
    }
    backendGroup = Connector.newEventLoopGroup(configManager.getNettyClientThreads());
}
Also used : DefaultChannelGroup(io.netty.channel.group.DefaultChannelGroup)

Example 45 with DefaultChannelGroup

use of io.netty.channel.group.DefaultChannelGroup in project cdap by cdapio.

the class NettyRouter method startUp.

@Override
protected void startUp() throws Exception {
    // If internal authorization enforcement is enabled, we avoid re-initialization of the token manager.
    if (SecurityUtil.isManagedSecurity(cConf) && !SecurityUtil.isInternalAuthEnabled(cConf)) {
        tokenValidator.startAndWait();
    }
    ChannelGroup channelGroup = new DefaultChannelGroup(ImmediateEventExecutor.INSTANCE);
    serverCancellable = startServer(createServerBootstrap(channelGroup), channelGroup);
    scheduleConfigReloadThread();
}
Also used : DefaultChannelGroup(io.netty.channel.group.DefaultChannelGroup) DefaultChannelGroup(io.netty.channel.group.DefaultChannelGroup) ChannelGroup(io.netty.channel.group.ChannelGroup)

Aggregations

DefaultChannelGroup (io.netty.channel.group.DefaultChannelGroup)56 ChannelGroup (io.netty.channel.group.ChannelGroup)29 Channel (io.netty.channel.Channel)23 DefaultEventExecutor (io.netty.util.concurrent.DefaultEventExecutor)15 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)14 InetSocketAddress (java.net.InetSocketAddress)12 CountDownLatch (java.util.concurrent.CountDownLatch)12 List (java.util.List)11 Test (org.junit.Test)11 ChannelInboundHandlerAdapter (io.netty.channel.ChannelInboundHandlerAdapter)10 ChannelOption (io.netty.channel.ChannelOption)9 Test (org.junit.jupiter.api.Test)9 ChannelInitializer (io.netty.channel.ChannelInitializer)8 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)8 Mono (reactor.core.publisher.Mono)8 ByteBuf (io.netty.buffer.ByteBuf)7 ByteBufAllocator (io.netty.buffer.ByteBufAllocator)7 HttpHeaderNames (io.netty.handler.codec.http.HttpHeaderNames)7 GlobalEventExecutor (io.netty.util.concurrent.GlobalEventExecutor)7 ArrayList (java.util.ArrayList)7