本文整理匯總了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;
}
示例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));
}
示例3: setUp
@Before
public void setUp() {
framer = new ArmeriaMessageFramer(UnpooledByteBufAllocator.DEFAULT, 1024);
}
示例4: alloc
@Override
public ByteBufAllocator alloc() {
final Channel channel = channel();
return channel != null ? channel.alloc() : UnpooledByteBufAllocator.DEFAULT;
}
示例5: alloc
@Override
public ByteBufAllocator alloc() {
// TODO Auto-generated method stub
return UnpooledByteBufAllocator.DEFAULT;
}
示例6: ThreadLocalPooledByteBuf
private ThreadLocalPooledByteBuf(Recycler.Handle<ThreadLocalPooledByteBuf> handle) {
super(UnpooledByteBufAllocator.DEFAULT, 256, Integer.MAX_VALUE);
this.handle = handle;
}
示例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);
}
}));
}
示例8: ReferenceNettyByteBuf
public ReferenceNettyByteBuf(byte[] initialArray) {
super(UnpooledByteBufAllocator.DEFAULT, initialArray, initialArray.length);
}