use of org.opendaylight.protocol.bmp.impl.BmpHandlerFactory in project bgpcep by opendaylight.
the class BmpMonitorImplTest method connectTestClient.
private static Channel connectTestClient(final String routerIp, final BmpMessageRegistry msgRegistry) throws InterruptedException {
final BmpHandlerFactory hf = new BmpHandlerFactory(msgRegistry);
final Bootstrap b = new Bootstrap();
final EventLoopGroup workerGroup;
if (Epoll.isAvailable()) {
b.channel(EpollSocketChannel.class);
workerGroup = new EpollEventLoopGroup();
} else {
b.channel(NioSocketChannel.class);
workerGroup = new NioEventLoopGroup();
}
b.group(workerGroup);
b.option(ChannelOption.SO_KEEPALIVE, true);
b.handler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(final SocketChannel ch) throws Exception {
ch.pipeline().addLast(hf.getDecoders());
ch.pipeline().addLast(hf.getEncoders());
}
});
b.localAddress(new InetSocketAddress(routerIp, 0));
b.option(ChannelOption.SO_REUSEADDR, true);
final ChannelFuture future = b.connect(new InetSocketAddress(MONITOR_LOCAL_ADDRESS, MONITOR_LOCAL_PORT)).sync();
waitFutureSuccess(future);
return future.channel();
}
Aggregations