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);
}
}
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();
}
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());
}
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());
}
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();
}
Aggregations