io.netty.bootstrap.AbstractBootstrap Java Examples

The following examples show how to use io.netty.bootstrap.AbstractBootstrap. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SocketTestPermutation.java    From netty-4.1.22 with Apache License 2.0 6 votes vote down vote up
protected <A extends AbstractBootstrap<?, ?>, B extends AbstractBootstrap<?, ?>>
List<BootstrapComboFactory<A, B>> combo(List<BootstrapFactory<A>> sbfs, List<BootstrapFactory<B>> cbfs) {

    List<BootstrapComboFactory<A, B>> list = new ArrayList<BootstrapComboFactory<A, B>>();

    // Populate the combinations
    for (BootstrapFactory<A> sbf: sbfs) {
        for (BootstrapFactory<B> cbf: cbfs) {
            final BootstrapFactory<A> sbf0 = sbf;
            final BootstrapFactory<B> cbf0 = cbf;
            list.add(new BootstrapComboFactory<A, B>() {
                @Override
                public A newServerInstance() {
                    return sbf0.newInstance();
                }

                @Override
                public B newClientInstance() {
                    return cbf0.newInstance();
                }
            });
        }
    }

    return list;
}
 
Example #2
Source File: SocketTestPermutation.java    From netty4.0.27Learn with Apache License 2.0 6 votes vote down vote up
protected <A extends AbstractBootstrap<?, ?>, B extends AbstractBootstrap<?, ?>>
List<BootstrapComboFactory<A, B>> combo(List<BootstrapFactory<A>> sbfs, List<BootstrapFactory<B>> cbfs) {

    List<BootstrapComboFactory<A, B>> list = new ArrayList<BootstrapComboFactory<A, B>>();

    // Populate the combinations
    for (BootstrapFactory<A> sbf: sbfs) {
        for (BootstrapFactory<B> cbf: cbfs) {
            final BootstrapFactory<A> sbf0 = sbf;
            final BootstrapFactory<B> cbf0 = cbf;
            list.add(new BootstrapComboFactory<A, B>() {
                @Override
                public A newServerInstance() {
                    return sbf0.newInstance();
                }

                @Override
                public B newClientInstance() {
                    return cbf0.newInstance();
                }
            });
        }
    }

    return list;
}
 
Example #3
Source File: EpollReuseAddrTest.java    From netty-4.1.22 with Apache License 2.0 5 votes vote down vote up
private static void testMultipleBindDatagramChannelWithoutReusePortFails0(AbstractBootstrap<?, ?> bootstrap) {
    bootstrap.handler(new DummyHandler());
    ChannelFuture future = bootstrap.bind().syncUninterruptibly();
    try {
        bootstrap.bind(future.channel().localAddress()).syncUninterruptibly();
        Assert.fail();
    } catch (Exception e) {
        Assert.assertTrue(e instanceof IOException);
    }
    future.channel().close().syncUninterruptibly();
}
 
Example #4
Source File: EpollReuseAddrTest.java    From netty4.0.27Learn with Apache License 2.0 5 votes vote down vote up
private static void testMultipleBindDatagramChannelWithoutReusePortFails0(AbstractBootstrap<?, ?> bootstrap) {
    bootstrap.handler(new DummyHandler());
    ChannelFuture future = bootstrap.bind().syncUninterruptibly();
    try {
        bootstrap.bind().syncUninterruptibly();
        Assert.fail();
    } catch (Exception e) {
        Assert.assertTrue(e instanceof IOException);
    }
    future.channel().close().syncUninterruptibly();
}
 
Example #5
Source File: NettyConnector.java    From hasor with Apache License 2.0 5 votes vote down vote up
private <T extends AbstractBootstrap<?, ?>> T configBoot(T boot) {
    boot.option(ChannelOption.SO_KEEPALIVE, true);
    // boot.option(ChannelOption.SO_BACKLOG, 128);
    // boot.option(ChannelOption.SO_BACKLOG, 1024);
    // boot.option(ChannelOption.SO_RCVBUF, 1024 * 256);
    // boot.option(ChannelOption.SO_SNDBUF, 1024 * 256);
    boot.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT);
    return boot;
}
 
Example #6
Source File: Iso8583ChannelInitializerTest.java    From jreactive-8583 with Apache License 2.0 5 votes vote down vote up
@Test
public void testInitChannelWithLogger() {
    //given
    configurationBuilder.addLoggingHandler();
    Iso8583ChannelInitializer<Channel, AbstractBootstrap, ConnectorConfiguration> channelInitializer = createChannelInitializer(configurer);

    // when
    channelInitializer.initChannel(channel);

    //then
    verify(pipeline).addLast(same(workerGroup), eq("logging"), any(IsoMessageLoggingHandler.class));
}
 
Example #7
Source File: Iso8583ChannelInitializerTest.java    From jreactive-8583 with Apache License 2.0 5 votes vote down vote up
@Test
public void testInitChannelWithoutLogger() {
    //given
    configurationBuilder.addLoggingHandler(false);

    Iso8583ChannelInitializer<Channel, AbstractBootstrap, ConnectorConfiguration> channelInitializer = createChannelInitializer(configurer);

    //when
    channelInitializer.initChannel(channel);

    //then
    verify(pipeline, never()).addLast(any(EventLoopGroup.class), anyString(), any(IsoMessageLoggingHandler.class));
}
 
Example #8
Source File: Iso8583ChannelInitializerTest.java    From jreactive-8583 with Apache License 2.0 5 votes vote down vote up
@Test
public void testInitChannelWithDefaultLoggingSetting() {
    //given
    Iso8583ChannelInitializer<Channel, AbstractBootstrap, ConnectorConfiguration> channelInitializer = createChannelInitializer(configurer);

    //when
    channelInitializer.initChannel(channel);

    //then
    verify(pipeline, never()).addLast(any(EventLoopGroup.class), anyString(), any(IsoMessageLoggingHandler.class));
}
 
Example #9
Source File: Iso8583ChannelInitializerTest.java    From jreactive-8583 with Apache License 2.0 5 votes vote down vote up
private Iso8583ChannelInitializer<Channel, AbstractBootstrap, ConnectorConfiguration> createChannelInitializer(ConnectorConfigurer<ConnectorConfiguration, AbstractBootstrap> configurer) {
    return new Iso8583ChannelInitializer<>(
            configurationBuilder.build(),
            configurer,
            workerGroup,
            messageFactory,
            handlers);
}
 
Example #10
Source File: BaseNettyServer.java    From datacollector with Apache License 2.0 votes vote down vote up
protected abstract AbstractBootstrap bootstrap(boolean enableEpoll);