Search in sources :

Example 1 with PduCodec

use of net.ripe.rpki.rtr.adapter.netty.PduCodec in project rpki-validator-3 by RIPE-NCC.

the class RtrServer method runNetty.

private void runNetty() throws InterruptedException {
    bossGroup = new NioEventLoopGroup();
    workerGroup = new NioEventLoopGroup();
    try {
        ServerBootstrap b = new ServerBootstrap();
        b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class).childHandler(new ChannelInitializer<SocketChannel>() {

            @Override
            public void initChannel(SocketChannel ch) {
                ChannelTrafficShapingHandler traffic = new ChannelTrafficShapingHandler(0);
                RtrClientHandler rtrClientHandler = rtrClientHandlerProvider.get();
                rtrClientHandler.setTrafficShapingHandler(traffic);
                ch.pipeline().addLast(traffic, new PduCodec(), new ChunkedWriteHandler(), rtrClientHandler);
            }
        }).option(ChannelOption.SO_BACKLOG, 128).childOption(ChannelOption.SO_KEEPALIVE, true);
        log.info("Running RTR at port {}", port);
        ChannelFuture f = b.bind(port).sync();
        f.channel().closeFuture().sync();
    } finally {
        shutdownWorkers();
    }
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) SocketChannel(io.netty.channel.socket.SocketChannel) NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) ChannelTrafficShapingHandler(io.netty.handler.traffic.ChannelTrafficShapingHandler) NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) ChunkedWriteHandler(io.netty.handler.stream.ChunkedWriteHandler) PduCodec(net.ripe.rpki.rtr.adapter.netty.PduCodec) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) ServerBootstrap(io.netty.bootstrap.ServerBootstrap)

Aggregations

ServerBootstrap (io.netty.bootstrap.ServerBootstrap)1 ChannelFuture (io.netty.channel.ChannelFuture)1 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)1 SocketChannel (io.netty.channel.socket.SocketChannel)1 NioServerSocketChannel (io.netty.channel.socket.nio.NioServerSocketChannel)1 ChunkedWriteHandler (io.netty.handler.stream.ChunkedWriteHandler)1 ChannelTrafficShapingHandler (io.netty.handler.traffic.ChannelTrafficShapingHandler)1 PduCodec (net.ripe.rpki.rtr.adapter.netty.PduCodec)1