List of usage examples for io.netty.channel.udt.nio NioUdtProvider MESSAGE_RENDEZVOUS
ChannelFactory MESSAGE_RENDEZVOUS
To view the source code for io.netty.channel.udt.nio NioUdtProvider MESSAGE_RENDEZVOUS.
Click Source Link
From source file:com.flysoloing.learning.network.netty.udt.echo.rendezvous.MsgEchoPeerBase.java
License:Apache License
public void run() throws Exception { // Configure the peer. final ThreadFactory connectFactory = new DefaultThreadFactory("rendezvous"); final NioEventLoopGroup connectGroup = new NioEventLoopGroup(1, connectFactory, NioUdtProvider.MESSAGE_PROVIDER); try {/* w w w . ja v a2 s .c o m*/ final Bootstrap boot = new Bootstrap(); boot.group(connectGroup).channelFactory(NioUdtProvider.MESSAGE_RENDEZVOUS) .handler(new ChannelInitializer<UdtChannel>() { @Override public void initChannel(final UdtChannel ch) throws Exception { ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO), new MsgEchoPeerHandler(messageSize)); } }); // Start the peer. final ChannelFuture f = boot.connect(peer, self).sync(); // Wait until the connection is closed. f.channel().closeFuture().sync(); } finally { // Shut down the event loop to terminate all threads. connectGroup.shutdownGracefully(); } }
From source file:io.aos.netty5.udt.echo.rendezvous.MsgEchoPeerBase.java
License:Apache License
public void run() throws Exception { // Configure the peer. final ExecutorServiceFactory connectFactory = new DefaultExecutorServiceFactory("rendezvous"); final NioEventLoopGroup connectGroup = new NioEventLoopGroup(1, connectFactory, NioUdtProvider.MESSAGE_PROVIDER); try {/*w w w . java 2s .c om*/ final Bootstrap boot = new Bootstrap(); boot.group(connectGroup).channelFactory(NioUdtProvider.MESSAGE_RENDEZVOUS) .handler(new ChannelInitializer<UdtChannel>() { @Override public void initChannel(final UdtChannel ch) throws Exception { ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO), new MsgEchoPeerHandler(messageSize)); } }); // Start the peer. final ChannelFuture f = boot.connect(peer, self).sync(); // Wait until the connection is closed. f.channel().closeFuture().sync(); } finally { // Shut down the event loop to terminate all threads. connectGroup.shutdownGracefully(); } }