org.apache.flink.shaded.netty4.io.netty.channel.socket.nio.NioServerSocketChannel Java Examples

The following examples show how to use org.apache.flink.shaded.netty4.io.netty.channel.socket.nio.NioServerSocketChannel. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClientTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
private Channel createServerChannel(final ChannelHandler... handlers) throws UnknownHostException, InterruptedException {
	ServerBootstrap bootstrap = new ServerBootstrap()
			// Bind address and port
			.localAddress(InetAddress.getLocalHost(), 0)
			// NIO server channels
			.group(nioGroup)
			.channel(NioServerSocketChannel.class)
			// See initializer for pipeline details
			.childHandler(new ChannelInitializer<SocketChannel>() {
				@Override
				protected void initChannel(SocketChannel ch) throws Exception {
					ch.pipeline()
							.addLast(new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE, 0, 4, 0, 4))
							.addLast(handlers);
				}
			});

	return bootstrap.bind().sync().channel();
}
 
Example #2
Source File: ClientTest.java    From flink with Apache License 2.0 6 votes vote down vote up
private Channel createServerChannel(final ChannelHandler... handlers) throws UnknownHostException, InterruptedException {
	ServerBootstrap bootstrap = new ServerBootstrap()
			// Bind address and port
			.localAddress(InetAddress.getLocalHost(), 0)
			// NIO server channels
			.group(nioGroup)
			.channel(NioServerSocketChannel.class)
			// See initializer for pipeline details
			.childHandler(new ChannelInitializer<SocketChannel>() {
				@Override
				protected void initChannel(SocketChannel ch) throws Exception {
					ch.pipeline()
							.addLast(new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE, 0, 4, 0, 4))
							.addLast(handlers);
				}
			});

	return bootstrap.bind().sync().channel();
}
 
Example #3
Source File: ClientTest.java    From flink with Apache License 2.0 6 votes vote down vote up
private Channel createServerChannel(final ChannelHandler... handlers) throws UnknownHostException, InterruptedException {
	ServerBootstrap bootstrap = new ServerBootstrap()
			// Bind address and port
			.localAddress(InetAddress.getLocalHost(), 0)
			// NIO server channels
			.group(nioGroup)
			.channel(NioServerSocketChannel.class)
			// See initializer for pipeline details
			.childHandler(new ChannelInitializer<SocketChannel>() {
				@Override
				protected void initChannel(SocketChannel ch) throws Exception {
					ch.pipeline()
							.addLast(new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE, 0, 4, 0, 4))
							.addLast(handlers);
				}
			});

	return bootstrap.bind().sync().channel();
}
 
Example #4
Source File: NettyServer.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private void initNioBootstrap() {
	// Add the server port number to the name in order to distinguish
	// multiple servers running on the same host.
	String name = NettyConfig.SERVER_THREAD_GROUP_NAME + " (" + config.getServerPort() + ")";

	NioEventLoopGroup nioGroup = new NioEventLoopGroup(config.getServerNumThreads(), getNamedThreadFactory(name));
	bootstrap.group(nioGroup).channel(NioServerSocketChannel.class);
}
 
Example #5
Source File: NettyServer.java    From flink with Apache License 2.0 5 votes vote down vote up
private void initNioBootstrap() {
	// Add the server port number to the name in order to distinguish
	// multiple servers running on the same host.
	String name = NettyConfig.SERVER_THREAD_GROUP_NAME + " (" + config.getServerPort() + ")";

	NioEventLoopGroup nioGroup = new NioEventLoopGroup(config.getServerNumThreads(), getNamedThreadFactory(name));
	bootstrap.group(nioGroup).channel(NioServerSocketChannel.class);
}
 
Example #6
Source File: NettyServer.java    From flink with Apache License 2.0 5 votes vote down vote up
private void initNioBootstrap() {
	// Add the server port number to the name in order to distinguish
	// multiple servers running on the same host.
	String name = NettyConfig.SERVER_THREAD_GROUP_NAME + " (" + config.getServerPort() + ")";

	NioEventLoopGroup nioGroup = new NioEventLoopGroup(config.getServerNumThreads(), getNamedThreadFactory(name));
	bootstrap.group(nioGroup).channel(NioServerSocketChannel.class);
}