org.jboss.netty.buffer.HeapChannelBufferFactory Java Examples
The following examples show how to use
org.jboss.netty.buffer.HeapChannelBufferFactory.
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: NettyServer.java From aion-germany with GNU General Public License v3.0 | 5 votes |
/** * @param channelFactory * @param listenAddress * @param port * @param channelPipelineFactory * @return Channel */ private Channel initChannel(ChannelFactory channelFactory, InetSocketAddress address, ChannelPipelineFactory channelPipelineFactory) { ServerBootstrap bootstrap = new ServerBootstrap(channelFactory); bootstrap.setPipelineFactory(channelPipelineFactory); bootstrap.setOption("child.bufferFactory", HeapChannelBufferFactory.getInstance(ByteOrder.LITTLE_ENDIAN)); bootstrap.setOption("child.tcpNoDelay", true); bootstrap.setOption("child.keepAlive", true); bootstrap.setOption("child.reuseAddress", true); bootstrap.setOption("child.connectTimeoutMillis", 100); bootstrap.setOption("readWriteFair", true); return bootstrap.bind(address); }
Example #2
Source File: OspfInterfaceImplTest.java From onos with Apache License 2.0 | 5 votes |
/** * Tests electRouter() method. */ @Test public void testElectRouter() throws Exception { ospfInterface.setOspfArea(ospfArea); ospfInterface.setDr(Ip4Address.valueOf("3.3.3.3")); ospfInterface.setBdr(Ip4Address.valueOf("3.3.3.3")); ospfInterface.setIpNetworkMask(Ip4Address.valueOf("255.255.255.255")); ChannelConfig channelConfig = EasyMock.createMock(ChannelConfig.class); EasyMock.expect(channelConfig.getBufferFactory()).andReturn(new HeapChannelBufferFactory()); Channel channel = EasyMock.createMock(Channel.class); ospfInterface.electRouter(channel); assertThat(ospfInterface.dr(), is(notNullValue())); }
Example #3
Source File: MongoProxyInboundHandler.java From usergrid with Apache License 2.0 | 5 votes |
@Override public void channelOpen( ChannelHandlerContext ctx, ChannelStateEvent e ) throws Exception { // Suspend incoming traffic until connected to the remote host. final Channel inboundChannel = e.getChannel(); inboundChannel.setReadable( false ); // Start the connection attempt. ClientBootstrap cb = new ClientBootstrap( cf ); cb.setOption( "bufferFactory", HeapChannelBufferFactory.getInstance( ByteOrder.LITTLE_ENDIAN ) ); cb.getPipeline().addLast( "framer", new MongoMessageFrame() ); cb.getPipeline().addLast( "handler", new OutboundHandler( e.getChannel() ) ); ChannelFuture f = cb.connect( new InetSocketAddress( remoteHost, remotePort ) ); outboundChannel = f.getChannel(); f.addListener( new ChannelFutureListener() { @Override public void operationComplete( ChannelFuture future ) throws Exception { if ( future.isSuccess() ) { // Connection attempt succeeded: // Begin to accept incoming traffic. inboundChannel.setReadable( true ); } else { // Close the connection if the connection attempt has // failed. inboundChannel.close(); } } } ); }
Example #4
Source File: MongoServer.java From usergrid with Apache License 2.0 | 5 votes |
public void startServer() { if ( ( properties != null ) && ( Boolean .parseBoolean( properties.getProperty( "usergrid.mongo.disable", "false" ) ) ) ) { logger.info( "Usergrid Mongo Emulation Server Disabled" ); return; } logger.info( "Starting Usergrid Mongo Emulation Server" ); if ( realm != null ) { securityManager = new DefaultSecurityManager( realm ); } // Configure the server. ServerBootstrap bootstrap = new ServerBootstrap( new NioServerSocketChannelFactory( Executors.newCachedThreadPool(), Executors.newCachedThreadPool() ) ); bootstrap.setOption( "child.bufferFactory", HeapChannelBufferFactory.getInstance( ByteOrder.LITTLE_ENDIAN ) ); // Set up the pipeline factory. ExecutionHandler executionHandler = new ExecutionHandler( new OrderedMemoryAwareThreadPoolExecutor( 16, 1048576, 1048576 ) ); // TODO if config'ed for SSL, start the SslMSPF instead, change port as well? bootstrap.setPipelineFactory( new MongoServerPipelineFactory( emf, smf, management, securityManager, executionHandler ) ); // Bind and start to accept incoming connections. channel = bootstrap.bind( new InetSocketAddress( 27017 ) ); logger.info( "Usergrid Mongo API Emulation Server accepting connections..." ); }
Example #5
Source File: MongoProxyServer.java From usergrid with Apache License 2.0 | 4 votes |
public static void main( String[] args ) throws Exception { logger.info( "Starting Usergrid Mongo Proxy Server" ); // Configure the server. Executor executor = Executors.newCachedThreadPool(); ServerBootstrap bootstrap = new ServerBootstrap( new NioServerSocketChannelFactory( executor, executor ) ); bootstrap.setOption( "child.bufferFactory", HeapChannelBufferFactory.getInstance( ByteOrder.LITTLE_ENDIAN ) ); ClientSocketChannelFactory cf = new NioClientSocketChannelFactory( executor, executor ); bootstrap.setPipelineFactory( new MongoProxyPipelineFactory( cf, "localhost", 12345 ) ); bootstrap.bind( new InetSocketAddress( 27017 ) ); logger.info( "Usergrid Mongo Proxy Server accepting connections..." ); }
Example #6
Source File: NettyTcpClientTransport.java From msgpack-rpc-java with Apache License 2.0 | 4 votes |
@Override protected ChannelBufferOutputStream newPendingBuffer() { return new ChannelBufferOutputStream( ChannelBuffers.dynamicBuffer(HeapChannelBufferFactory.getInstance())); }