Search in sources :

Example 76 with ChannelPipeline

use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelPipeline in project brave by openzipkin.

the class ITNettyHttpTracing method init.

@Override
protected void init() {
    stop();
    bossGroup = new NioEventLoopGroup(1);
    workerGroup = new NioEventLoopGroup();
    ServerBootstrap b = new ServerBootstrap();
    b.option(ChannelOption.SO_BACKLOG, 1024);
    b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class).childHandler(new ChannelInitializer<Channel>() {

        @Override
        protected void initChannel(final Channel ch) throws Exception {
            ChannelPipeline p = ch.pipeline();
            p.addLast(new HttpServerCodec());
            p.addLast(NettyHttpTracing.create(httpTracing).serverHandler());
            p.addLast(new TestHandler(httpTracing));
        }
    });
    try {
        Channel ch = b.bind(0).sync().channel();
        port = ((InetSocketAddress) ch.localAddress()).getPort();
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        throw new AssertionError(e);
    }
}
Also used : NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) Channel(io.netty.channel.Channel) HttpServerCodec(io.netty.handler.codec.http.HttpServerCodec) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) ServerBootstrap(io.netty.bootstrap.ServerBootstrap) ChannelPipeline(io.netty.channel.ChannelPipeline)

Example 77 with ChannelPipeline

use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelPipeline in project brave by openzipkin.

the class NettyHttpServerBenchmarks method initServer.

@Override
protected int initServer() throws InterruptedException {
    bossGroup = new NioEventLoopGroup(1);
    workerGroup = new NioEventLoopGroup();
    ServerBootstrap b = new ServerBootstrap();
    b.option(ChannelOption.SO_BACKLOG, 1024);
    b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class).childHandler(new ChannelInitializer<Channel>() {

        @Override
        protected void initChannel(final Channel ch) throws Exception {
            ChannelPipeline p = ch.pipeline();
            p.addLast(new HttpServerCodec());
            p.addLast(new TracingDispatchHandler());
            p.addLast(new HelloWorldHandler());
        }
    });
    Channel ch = b.bind(0).sync().channel();
    return ((InetSocketAddress) ch.localAddress()).getPort();
}
Also used : NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) InetSocketAddress(java.net.InetSocketAddress) NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) Channel(io.netty.channel.Channel) HttpServerCodec(io.netty.handler.codec.http.HttpServerCodec) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) ServerBootstrap(io.netty.bootstrap.ServerBootstrap) RunnerException(org.openjdk.jmh.runner.RunnerException) ChannelPipeline(io.netty.channel.ChannelPipeline)

Example 78 with ChannelPipeline

use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelPipeline in project benchmark by seelunzi.

the class ClientIniter method initChannel.

@Override
protected void initChannel(SocketChannel socketChannel) throws Exception {
    ChannelPipeline pipeline = socketChannel.pipeline();
    pipeline.addLast("stringD", new StringDecoder());
    pipeline.addLast("stringC", new StringEncoder());
    pipeline.addLast("http", new HttpClientCodec());
    pipeline.addLast("chat", new ChatClientHandler());
}
Also used : StringEncoder(io.netty.handler.codec.string.StringEncoder) StringDecoder(io.netty.handler.codec.string.StringDecoder) HttpClientCodec(io.netty.handler.codec.http.HttpClientCodec) ChannelPipeline(io.netty.channel.ChannelPipeline)

Example 79 with ChannelPipeline

use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelPipeline in project benchmark by seelunzi.

the class ServerIniterHandler method initChannel.

@Override
protected void initChannel(SocketChannel socketChannel) throws Exception {
    ChannelPipeline pipeline = socketChannel.pipeline();
    pipeline.addLast("docode", new StringDecoder());
    pipeline.addLast("encode", new StringEncoder());
    pipeline.addLast("chat", new ChatServerHandler());
}
Also used : StringEncoder(io.netty.handler.codec.string.StringEncoder) StringDecoder(io.netty.handler.codec.string.StringDecoder) ChannelPipeline(io.netty.channel.ChannelPipeline)

Example 80 with ChannelPipeline

use of org.apache.flink.shaded.netty4.io.netty.channel.ChannelPipeline in project rskj by rsksmart.

the class EthereumChannelInitializerTest method initChannel_AddressIsBanned_ShouldDisconnect.

@Test
public void initChannel_AddressIsBanned_ShouldDisconnect() {
    InetSocketAddress address = Objects.requireNonNull(IpUtils.parseAddress("192.168.100.1:5555"));
    PeerScoringManager peerScoringManager = mock(PeerScoringManager.class);
    doReturn(true).when(peerScoringManager).isAddressBanned(eq(address.getAddress()));
    ChannelManager channelManager = mock(ChannelManager.class);
    doReturn(true).when(channelManager).isAddressBlockAvailable(any());
    ChannelPipeline pipeline = mock(ChannelPipeline.class);
    NioSocketChannel channel = mock(NioSocketChannel.class);
    SocketChannelConfig config = mock(SocketChannelConfig.class);
    ChannelFuture channelFuture = mock(ChannelFuture.class);
    doReturn(address).when(channel).remoteAddress();
    doReturn(pipeline).when(channel).pipeline();
    doReturn(config).when(channel).config();
    doReturn(channelFuture).when(channel).closeFuture();
    EthereumChannelInitializer channelInitializer = new EthereumChannelInitializer("", mock(RskSystemProperties.class), channelManager, mock(CompositeEthereumListener.class), mock(ConfigCapabilities.class), mock(NodeManager.class), mock(RskWireProtocol.Factory.class), mock(Eth62MessageFactory.class), mock(StaticMessages.class), peerScoringManager);
    channelInitializer.initChannel(channel);
    verify(channel, atLeastOnce()).disconnect();
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) InetSocketAddress(java.net.InetSocketAddress) ConfigCapabilities(org.ethereum.net.client.ConfigCapabilities) StaticMessages(org.ethereum.net.message.StaticMessages) Eth62MessageFactory(org.ethereum.net.eth.message.Eth62MessageFactory) Eth62MessageFactory(org.ethereum.net.eth.message.Eth62MessageFactory) ChannelPipeline(io.netty.channel.ChannelPipeline) NioSocketChannel(io.netty.channel.socket.nio.NioSocketChannel) PeerScoringManager(co.rsk.scoring.PeerScoringManager) NodeManager(org.ethereum.net.NodeManager) CompositeEthereumListener(org.ethereum.listener.CompositeEthereumListener) SocketChannelConfig(io.netty.channel.socket.SocketChannelConfig) RskSystemProperties(co.rsk.config.RskSystemProperties) Test(org.junit.Test)

Aggregations

ChannelPipeline (io.netty.channel.ChannelPipeline)370 SocketChannel (io.netty.channel.socket.SocketChannel)107 Channel (io.netty.channel.Channel)90 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)90 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)80 NioSocketChannel (io.netty.channel.socket.nio.NioSocketChannel)78 Bootstrap (io.netty.bootstrap.Bootstrap)77 ServerBootstrap (io.netty.bootstrap.ServerBootstrap)69 ChannelFuture (io.netty.channel.ChannelFuture)68 NioServerSocketChannel (io.netty.channel.socket.nio.NioServerSocketChannel)62 HttpObjectAggregator (io.netty.handler.codec.http.HttpObjectAggregator)62 EventLoopGroup (io.netty.channel.EventLoopGroup)54 SslHandler (io.netty.handler.ssl.SslHandler)52 InetSocketAddress (java.net.InetSocketAddress)49 HttpServerCodec (io.netty.handler.codec.http.HttpServerCodec)43 LoggingHandler (io.netty.handler.logging.LoggingHandler)37 IOException (java.io.IOException)37 StringDecoder (io.netty.handler.codec.string.StringDecoder)36 IdleStateHandler (io.netty.handler.timeout.IdleStateHandler)36 StringEncoder (io.netty.handler.codec.string.StringEncoder)33