List of usage examples for io.netty.channel.udt.nio NioUdtProvider MESSAGE_PROVIDER
SelectorProvider MESSAGE_PROVIDER
To view the source code for io.netty.channel.udt.nio NioUdtProvider MESSAGE_PROVIDER.
Click Source Link
From source file:com.flysoloing.learning.network.netty.udt.echo.message.MsgEchoClient.java
License:Apache License
public static void main(String[] args) throws Exception { // Configure the client. final ThreadFactory connectFactory = new DefaultThreadFactory("connect"); final NioEventLoopGroup connectGroup = new NioEventLoopGroup(1, connectFactory, NioUdtProvider.MESSAGE_PROVIDER); try {//from www .ja v a 2 s . co m final Bootstrap boot = new Bootstrap(); boot.group(connectGroup).channelFactory(NioUdtProvider.MESSAGE_CONNECTOR) .handler(new ChannelInitializer<UdtChannel>() { @Override public void initChannel(final UdtChannel ch) throws Exception { ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO), new MsgEchoClientHandler()); } }); // Start the client. final ChannelFuture f = boot.connect(HOST, PORT).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:com.flysoloing.learning.network.netty.udt.echo.message.MsgEchoServer.java
License:Apache License
public static void main(String[] args) throws Exception { final ThreadFactory acceptFactory = new DefaultThreadFactory("accept"); final ThreadFactory connectFactory = new DefaultThreadFactory("connect"); final NioEventLoopGroup acceptGroup = new NioEventLoopGroup(1, acceptFactory, NioUdtProvider.MESSAGE_PROVIDER); final NioEventLoopGroup connectGroup = new NioEventLoopGroup(1, connectFactory, NioUdtProvider.MESSAGE_PROVIDER); // Configure the server. try {/*from w w w.j av a 2 s . c o m*/ final ServerBootstrap boot = new ServerBootstrap(); boot.group(acceptGroup, connectGroup).channelFactory(NioUdtProvider.MESSAGE_ACCEPTOR) .option(ChannelOption.SO_BACKLOG, 10).handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new ChannelInitializer<UdtChannel>() { @Override public void initChannel(final UdtChannel ch) throws Exception { ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO), new MsgEchoServerHandler()); } }); // Start the server. final ChannelFuture future = boot.bind(PORT).sync(); // Wait until the server socket is closed. future.channel().closeFuture().sync(); } finally { // Shut down all event loops to terminate all threads. acceptGroup.shutdownGracefully(); connectGroup.shutdownGracefully(); } }
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 {//from w w w . jav a2 s . co 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:com.seagate.kinetic.client.io.provider.nio.udt.UdtWorkerGroup.java
License:Open Source License
public static synchronized void initWorkerGroup() { if (workerGroup == null) { tfactory = new NioClientThreadFactory("kinetic.client.nio.udt"); workerGroup = new NioEventLoopGroup(0, tfactory, NioUdtProvider.MESSAGE_PROVIDER); }// w w w.j a v a2 s . c o m }
From source file:com.seagate.kinetic.simulator.io.provider.nio.udt.UdtTransportProvider.java
License:Open Source License
public void doInit() throws InterruptedException { this.port = this.service.getServiceConfiguration().getPort(); final ThreadFactory acceptFactory = new NioThreadFactory("UdtAccept"); final ThreadFactory connectFactory = new NioThreadFactory("UdtConnect"); bossGroup = new NioEventLoopGroup(10, acceptFactory, NioUdtProvider.MESSAGE_PROVIDER); workerGroup = new NioEventLoopGroup(10, connectFactory, NioUdtProvider.MESSAGE_PROVIDER); msChannelInitializer = new UdtChannelInitializer(this.service); bootstrap = new ServerBootstrap(); bootstrap.group(bossGroup, workerGroup).channelFactory(NioUdtProvider.MESSAGE_ACCEPTOR) .option(ChannelOption.SO_BACKLOG, 1000).option(ChannelOption.SO_REUSEADDR, true) .childHandler(msChannelInitializer); logger.info("Kinetic udt service binding on port =" + port); channelFuture = bootstrap.bind(port).sync(); logger.info("Kinetic udt service bound on port =" + port); }
From source file:io.aos.netty5.udt.echo.message.MsgEchoClient.java
License:Apache License
public static void main(String[] args) throws Exception { // Configure the client. final ExecutorServiceFactory connectFactory = new DefaultExecutorServiceFactory("connect"); final NioEventLoopGroup connectGroup = new NioEventLoopGroup(1, connectFactory, NioUdtProvider.MESSAGE_PROVIDER); try {//from www . j a va 2s .co m final Bootstrap boot = new Bootstrap(); boot.group(connectGroup).channelFactory(NioUdtProvider.MESSAGE_CONNECTOR) .handler(new ChannelInitializer<UdtChannel>() { @Override public void initChannel(final UdtChannel ch) throws Exception { ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO), new MsgEchoClientHandler()); } }); // Start the client. final ChannelFuture f = boot.connect(HOST, PORT).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.message.MsgEchoServer.java
License:Apache License
public static void main(String[] args) throws Exception { final ExecutorServiceFactory acceptFactory = new DefaultExecutorServiceFactory("accept"); final ExecutorServiceFactory connectFactory = new DefaultExecutorServiceFactory("connect"); final NioEventLoopGroup acceptGroup = new NioEventLoopGroup(1, acceptFactory, NioUdtProvider.MESSAGE_PROVIDER); final NioEventLoopGroup connectGroup = new NioEventLoopGroup(1, connectFactory, NioUdtProvider.MESSAGE_PROVIDER); // Configure the server. try {/*from w ww . ja va2s.co m*/ final ServerBootstrap boot = new ServerBootstrap(); boot.group(acceptGroup, connectGroup).channelFactory(NioUdtProvider.MESSAGE_ACCEPTOR) .option(ChannelOption.SO_BACKLOG, 10).handler(new LoggingHandler(LogLevel.INFO)) .childHandler(new ChannelInitializer<UdtChannel>() { @Override public void initChannel(final UdtChannel ch) throws Exception { ch.pipeline().addLast(new LoggingHandler(LogLevel.INFO), new MsgEchoServerHandler()); } }); // Start the server. final ChannelFuture future = boot.bind(PORT).sync(); // Wait until the server socket is closed. future.channel().closeFuture().sync(); } finally { // Shut down all event loops to terminate all threads. acceptGroup.shutdownGracefully(); 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 {//from www. j ava2s . 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(); } }