當前位置: 首頁>>代碼示例>>Java>>正文


Java UnpooledByteBufAllocator.DEFAULT屬性代碼示例

本文整理匯總了Java中io.netty.buffer.UnpooledByteBufAllocator.DEFAULT屬性的典型用法代碼示例。如果您正苦於以下問題:Java UnpooledByteBufAllocator.DEFAULT屬性的具體用法?Java UnpooledByteBufAllocator.DEFAULT怎麽用?Java UnpooledByteBufAllocator.DEFAULT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在io.netty.buffer.UnpooledByteBufAllocator的用法示例。


在下文中一共展示了UnpooledByteBufAllocator.DEFAULT屬性的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getWriteByteBuf

@Override
protected ByteBuf getWriteByteBuf() {
	
	int length = payload.length;
	CompositeByteBuf result = new CompositeByteBuf(UnpooledByteBufAllocator.DEFAULT, false, payload.length + 1);
	String prefix = String.format("%c%d\r\n", ASTERISK_BYTE, length);
	result.addComponent(Unpooled.wrappedBuffer(prefix.getBytes()));
	for(Object o : payload){
		ByteBuf buff = ParserManager.parse(o);
		result.addComponent(buff);
	}
	result.setIndex(0, result.capacity());
	return result;
}
 
開發者ID:ctripcorp,項目名稱:x-pipe,代碼行數:14,代碼來源:ArrayParser.java

示例2: assertRequest

protected void assertRequest(AsciiRequest<?> request, String expectedCmd) {
  ByteBufAllocator bba = UnpooledByteBufAllocator.DEFAULT;
  ByteBuffer bb = ByteBuffer.allocate(1024);

  ByteBuf out = request.writeRequest(bba, bb);

  byte[] b = new byte[out.readableBytes()];
  out.readBytes(b);
  assertEquals(expectedCmd, new String(b));
}
 
開發者ID:spotify,項目名稱:folsom,代碼行數:10,代碼來源:RequestTestTemplate.java

示例3: setUp

@Before
public void setUp() {
    framer = new ArmeriaMessageFramer(UnpooledByteBufAllocator.DEFAULT, 1024);
}
 
開發者ID:line,項目名稱:armeria,代碼行數:4,代碼來源:ArmeriaMessageFramerTest.java

示例4: alloc

@Override
public ByteBufAllocator alloc() {
    final Channel channel = channel();
    return channel != null ? channel.alloc() : UnpooledByteBufAllocator.DEFAULT;
}
 
開發者ID:line,項目名稱:armeria,代碼行數:5,代碼來源:DefaultClientRequestContext.java

示例5: alloc

@Override
public ByteBufAllocator alloc() {
	// TODO Auto-generated method stub
	return UnpooledByteBufAllocator.DEFAULT;
}
 
開發者ID:Tesora,項目名稱:tesora-dve-pub,代碼行數:5,代碼來源:ChannelHandlerContextStub.java

示例6: ThreadLocalPooledByteBuf

private ThreadLocalPooledByteBuf(Recycler.Handle<ThreadLocalPooledByteBuf> handle) {
    super(UnpooledByteBufAllocator.DEFAULT, 256, Integer.MAX_VALUE);
    this.handle = handle;
}
 
開發者ID:nathanchen,項目名稱:netty-netty-5.0.0.Alpha1,代碼行數:4,代碼來源:ChannelOutboundBuffer.java

示例7: AbstractEndpoint

/**
 * Create a new {@link AbstractEndpoint}.
 *
 * @param hostname the hostname/ipaddr of the remote channel.
 * @param bucket the name of the bucket.
 * @param username the user authorized for bucket access.
 * @param password the password of the user.
 * @param port the port of the remote channel.
 * @param environment the environment of the core.
 * @param responseBuffer the response buffer for passing responses up the stack.
 */
protected AbstractEndpoint(final String hostname, final String bucket, final String username, final String password, final int port,
    final CoreEnvironment environment, final RingBuffer<ResponseEvent> responseBuffer, boolean isTransient,
    final EventLoopGroup ioPool, final boolean pipeline) {
    super(LifecycleState.DISCONNECTED);
    this.bucket = bucket;
    this.username = username;
    this.password = password;
    this.responseBuffer = responseBuffer;
    this.env = environment;
    this.isTransient = isTransient;
    this.ioPool = ioPool;
    this.pipeline = pipeline;
    this.free = true;
    this.hostname = hostname;
    this.connectCallbackGracePeriod = Integer.parseInt(
        System.getProperty("com.couchbase.connectCallbackGracePeriod", DEFAULT_CONNECT_CALLBACK_GRACE_PERIOD)
    );
    LOGGER.debug("Using a connectCallbackGracePeriod of {} on Endpoint {}:{}", connectCallbackGracePeriod,
        hostname, port);
    if (environment.sslEnabled()) {
        this.sslEngineFactory = new SSLEngineFactory(environment);
    }

    Class<? extends Channel> channelClass = NioSocketChannel.class;
    if (ioPool instanceof EpollEventLoopGroup) {
        channelClass = EpollSocketChannel.class;
    } else if (ioPool instanceof OioEventLoopGroup) {
        channelClass = OioSocketChannel.class;
    }

    ByteBufAllocator allocator = env.bufferPoolingEnabled()
            ? PooledByteBufAllocator.DEFAULT : UnpooledByteBufAllocator.DEFAULT;

    boolean tcpNodelay = environment().tcpNodelayEnabled();
    bootstrap = new BootstrapAdapter(new Bootstrap()
        .remoteAddress(hostname, port)
        .group(ioPool)
        .channel(channelClass)
        .option(ChannelOption.ALLOCATOR, allocator)
        .option(ChannelOption.TCP_NODELAY, tcpNodelay)
        .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, env.socketConnectTimeout())
        .handler(new ChannelInitializer<Channel>() {
            @Override
            protected void initChannel(Channel channel) throws Exception {
                ChannelPipeline pipeline = channel.pipeline();
                if (environment.sslEnabled()) {
                    pipeline.addLast(new SslHandler(sslEngineFactory.get()));
                }
                if (LOGGER.isTraceEnabled()) {
                    pipeline.addLast(LOGGING_HANDLER_INSTANCE);
                }
                customEndpointHandlers(pipeline);
            }
        }));
}
 
開發者ID:couchbase,項目名稱:couchbase-jvm-core,代碼行數:66,代碼來源:AbstractEndpoint.java

示例8: ReferenceNettyByteBuf

public ReferenceNettyByteBuf(byte[] initialArray) {
	super(UnpooledByteBufAllocator.DEFAULT, initialArray, initialArray.length);
}
 
開發者ID:qinannmj,項目名稱:FireFly,代碼行數:3,代碼來源:ReferenceNettyByteBuf.java


注:本文中的io.netty.buffer.UnpooledByteBufAllocator.DEFAULT屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。