当前位置: 首页>>代码示例>>Java>>正文


Java HeapChannelBufferFactory类代码示例

本文整理汇总了Java中org.jboss.netty.buffer.HeapChannelBufferFactory的典型用法代码示例。如果您正苦于以下问题:Java HeapChannelBufferFactory类的具体用法?Java HeapChannelBufferFactory怎么用?Java HeapChannelBufferFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HeapChannelBufferFactory类属于org.jboss.netty.buffer包,在下文中一共展示了HeapChannelBufferFactory类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testDecode

import org.jboss.netty.buffer.HeapChannelBufferFactory; //导入依赖的package包/类
@Test
public void testDecode() throws Exception {

    EnforaProtocolDecoder decoder = new EnforaProtocolDecoder(null);
    decoder.setDataManager(new TestDataManager());
    ChannelBufferFactory factory = new HeapChannelBufferFactory();

    byte[] buf1 = {0x00,0x0A,0x08,0x00,0x20,0x20,0x20,0x20,0x20,0x30,0x31,0x31,0x30,0x37,0x30,0x30,0x30,0x30,0x35,0x37,0x30,0x32,0x36,0x37};
    assertNull(decoder.decode(null, null, factory.getBuffer(buf1, 0, buf1.length)));

    byte[] buf2 = {0x00,0x3B,0x00,0x05,0x02,0x00,0x00,0x00,0x00,0x08,0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x31,0x31,0x30,0x37,0x30,0x30,0x30,0x30,0x35,0x37,0x30,0x32,0x36,0x37,0x20,0x38,0x3A,0x00,0x00,0x00,0x00,0x0D,0x00,0x50,(byte)0x84,0x01,0x35,(byte)0x8E,0x64,0x00,0x32,(byte)0xB3,0x77,0x00,0x00,0x03,0x67,(byte)0xB0,0x00,0x00,(byte)0xA8,0x04};
    assertNull(decoder.decode(null, null, factory.getBuffer(buf2, 0, buf2.length)));

    byte[] buf3 = {0x00,0x71,0x00,0x04,0x02,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x38,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x30,0x31,0x32,0x33,0x34,0x35,0x20,0x31,0x33,0x20,0x24,0x47,0x50,0x52,0x4D,0x43,0x2C,0x32,0x32,0x33,0x31,0x35,0x32,0x2E,0x30,0x30,0x2C,0x41,0x2C,0x33,0x35,0x30,0x39,0x2E,0x38,0x36,0x30,0x35,0x39,0x34,0x2C,0x4E,0x2C,0x30,0x33,0x33,0x32,0x32,0x2E,0x37,0x34,0x33,0x38,0x38,0x37,0x2C,0x45,0x2C,0x30,0x2E,0x30,0x2C,0x30,0x2E,0x30,0x2C,0x30,0x32,0x30,0x36,0x31,0x32,0x2C,0x2C,0x2C,0x41,0x2A,0x35,0x32,0x0D,0x0A};
    verify(decoder.decode(null, null, factory.getBuffer(buf3, 0, buf3.length)));

    byte[] buf4 = {0x00,0x76,0x00,0x04,0x02,0x00,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x38,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x30,0x31,0x31,0x38,0x39,0x32,0x30,0x30,0x30,0x36,0x30,0x38,0x31,0x38,0x39,0x20,0x31,0x33,0x20,0x24,0x47,0x50,0x52,0x4D,0x43,0x2C,0x31,0x37,0x31,0x38,0x34,0x31,0x2E,0x30,0x30,0x2C,0x41,0x2C,0x33,0x35,0x30,0x39,0x2E,0x38,0x35,0x32,0x34,0x31,0x30,0x2C,0x4E,0x2C,0x30,0x33,0x33,0x32,0x32,0x2E,0x37,0x35,0x39,0x31,0x31,0x33,0x2C,0x45,0x2C,0x30,0x2E,0x30,0x2C,0x30,0x2E,0x30,0x2C,0x31,0x37,0x30,0x37,0x31,0x32,0x2C,0x33,0x2E,0x34,0x2C,0x57,0x2C,0x41,0x2A,0x32,0x35,0x0D,0x0A,0x00};
    verify(decoder.decode(null, null, factory.getBuffer(buf4, 0, buf4.length)));
}
 
开发者ID:michaelloliveira,项目名称:traccar-mongodb,代码行数:20,代码来源:EnforaProtocolDecoderTest.java

示例2: testElectRouter

import org.jboss.netty.buffer.HeapChannelBufferFactory; //导入依赖的package包/类
/**
 * 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()));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:16,代码来源:OspfInterfaceImplTest.java

示例3: testDecode

import org.jboss.netty.buffer.HeapChannelBufferFactory; //导入依赖的package包/类
@Test
public void testDecode() throws Exception {

    Xt7ProtocolDecoder decoder = new Xt7ProtocolDecoder(null);
    decoder.setDataManager(new TestDataManager());
    ChannelBufferFactory factory = new HeapChannelBufferFactory();

    byte[] buf1 = {0x53,0x54,0x58,0x32,0x30,0x31,0x30,0x31,0x30,0x31,0x38,0x30,0x31,0x20,0x20,0x20,0x20,0x20,0x20,0x02,0x6A,0x24,0x47,0x50,0x52,0x4D,0x43,0x2C,0x31,0x30,0x31,0x30,0x35,0x33,0x2E,0x30,0x30,0x30,0x2C,0x41,0x2C,0x32,0x32,0x33,0x32,0x2E,0x37,0x36,0x30,0x37,0x2C,0x4E,0x2C,0x31,0x31,0x34,0x30,0x34,0x2E,0x37,0x36,0x36,0x39,0x2C,0x45,0x2C,0x30,0x2E,0x30,0x30,0x2C,0x2C,0x32,0x33,0x31,0x31,0x31,0x30,0x2C,0x2C,0x2C,0x41,0x2A,0x37,0x46,0x2C,0x34,0x36,0x30,0x2C,0x30,0x30,0x2C,0x32,0x37,0x39,0x35,0x2C,0x30,0x45,0x36,0x41,0x2C,0x31,0x34,0x2C,0x39,0x34,0x2C,0x31,0x30,0x30,0x30,0x2C,0x30,0x30,0x30,0x30,0x2C,0x39,0x31,0x2C,0x54,0x69,0x6D,0x65,0x72,0x3B,0x31,0x44,0x0D,0x0A};
    verify(decoder.decode(null, null, factory.getBuffer(buf1, 0, buf1.length)));

}
 
开发者ID:michaelloliveira,项目名称:traccar-mongodb,代码行数:12,代码来源:Xt7ProtocolDecoderTest.java

示例4: initialize

import org.jboss.netty.buffer.HeapChannelBufferFactory; //导入依赖的package包/类
@Override
public void initialize(final ChannelPipelineFactory pipelineFactory) {

    this.bootstrap = new ClientBootstrap(this.channelFactory);
    this.bootstrap.setPipelineFactory(pipelineFactory);
    this.bootstrap.setOption("bufferFactory",
            HeapChannelBufferFactory.getInstance(ByteOrder.LITTLE_ENDIAN));
    this.bootstrap.setOption("tcpNoDelay", true);
    this.bootstrap.setOption("keepAlive", true);
    this.bootstrap.setOption("reuseAddress", true);
    this.bootstrap.setOption("connectTimeoutMillis", 10);
    this.bootstrap.setOption("readWriteFair", true);
    this.bootstrap.setOption("remoteAddress", this.isa);
    ((BasicPipelineFactory) pipelineFactory).setChannelFactory(this);
}
 
开发者ID:JMaNGOS,项目名称:JMaNGOS,代码行数:16,代码来源:ClientChannelFactory.java

示例5: initialize

import org.jboss.netty.buffer.HeapChannelBufferFactory; //导入依赖的package包/类
@Override
public void initialize(final ChannelPipelineFactory pipelineFactory) {

    this.bootstrap = new ServerBootstrap(this.channelFactory);
    this.bootstrap.setPipelineFactory(pipelineFactory);
    this.bootstrap.setOption("child.bufferFactory",
            HeapChannelBufferFactory.getInstance(ByteOrder.LITTLE_ENDIAN));
    this.bootstrap.setOption("child.tcpNoDelay", true);
    this.bootstrap.setOption("child.keepAlive", true);
    this.bootstrap.setOption("child.reuseAddress", true);
    this.bootstrap.setOption("child.connectTimeoutMillis", 100);
    this.bootstrap.setOption("readWriteFair", true);
}
 
开发者ID:JMaNGOS,项目名称:JMaNGOS,代码行数:14,代码来源:ServerChannelFactory.java

示例6: channelOpen

import org.jboss.netty.buffer.HeapChannelBufferFactory; //导入依赖的package包/类
@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();
            }
        }
    } );
}
 
开发者ID:apache,项目名称:usergrid,代码行数:31,代码来源:MongoProxyInboundHandler.java

示例7: startServer

import org.jboss.netty.buffer.HeapChannelBufferFactory; //导入依赖的package包/类
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..." );
    }
 
开发者ID:apache,项目名称:usergrid,代码行数:33,代码来源:MongoServer.java

示例8: setEndianness

import org.jboss.netty.buffer.HeapChannelBufferFactory; //导入依赖的package包/类
public void setEndianness(ByteOrder byteOrder) {
    bootstrap.setOption("bufferFactory", new HeapChannelBufferFactory(byteOrder));
    bootstrap.setOption("child.bufferFactory", new HeapChannelBufferFactory(byteOrder));
}
 
开发者ID:bamartinezd,项目名称:traccar-service,代码行数:5,代码来源:TrackerServer.java

示例9: setEndianness

import org.jboss.netty.buffer.HeapChannelBufferFactory; //导入依赖的package包/类
/**
 * Set endianness
 */
void setEndianness(ByteOrder byteOrder) {
    bootstrap.setOption("bufferFactory", new HeapChannelBufferFactory(byteOrder));
    bootstrap.setOption("child.bufferFactory", new HeapChannelBufferFactory(byteOrder));
}
 
开发者ID:michaelloliveira,项目名称:traccar-mongodb,代码行数:8,代码来源:TrackerServer.java

示例10: newPendingBuffer

import org.jboss.netty.buffer.HeapChannelBufferFactory; //导入依赖的package包/类
@Override
protected ChannelBufferOutputStream newPendingBuffer() {
    return new ChannelBufferOutputStream(
            ChannelBuffers.dynamicBuffer(HeapChannelBufferFactory.getInstance()));
}
 
开发者ID:nict-wisdom,项目名称:rasc,代码行数:6,代码来源:NettyTcpClientTransportEx.java

示例11: main

import org.jboss.netty.buffer.HeapChannelBufferFactory; //导入依赖的package包/类
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..." );
}
 
开发者ID:apache,项目名称:usergrid,代码行数:18,代码来源:MongoProxyServer.java

示例12: newCumulationBuffer

import org.jboss.netty.buffer.HeapChannelBufferFactory; //导入依赖的package包/类
/**
 * Create a new {@link ChannelBuffer} which is used for the cumulation.
 * Sub-classes may override this.
 *
 * @param ctx {@link ChannelHandlerContext} for this handler
 * @return buffer the {@link ChannelBuffer} which is used for cumulation
 */
protected ChannelBuffer newCumulationBuffer(
        ChannelHandlerContext ctx, int minimumCapacity) {
    ChannelBufferFactory factory = HeapChannelBufferFactory.getInstance(ByteOrder.BIG_ENDIAN);
    return factory.getBuffer(Math.max(minimumCapacity, 256));
}
 
开发者ID:jle,项目名称:andy,代码行数:13,代码来源:FrameDecoder.java


注:本文中的org.jboss.netty.buffer.HeapChannelBufferFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。