本文整理汇总了Java中com.couchbase.client.deps.io.netty.buffer.Unpooled.buffer方法的典型用法代码示例。如果您正苦于以下问题:Java Unpooled.buffer方法的具体用法?Java Unpooled.buffer怎么用?Java Unpooled.buffer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.couchbase.client.deps.io.netty.buffer.Unpooled
的用法示例。
在下文中一共展示了Unpooled.buffer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: filterFailoverLogResponse
import com.couchbase.client.deps.io.netty.buffer.Unpooled; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private void filterFailoverLogResponse(ByteBuf buf) {
try {
Promise<ByteBuf> promise =
(Promise<ByteBuf>) dcpChannel.outstandingPromises.remove(MessageUtil.getOpaque(buf));
short vbid = dcpChannel.outstandingVbucketInfos.remove(MessageUtil.getOpaque(buf));
ByteBuf flog = Unpooled.buffer();
DcpFailoverLogResponse.init(flog);
DcpFailoverLogResponse.vbucket(flog, DcpFailoverLogResponse.vbucket(buf));
ByteBuf copiedBuf = MessageUtil.getContent(buf).copy().writeShort(vbid);
MessageUtil.setContent(copiedBuf, flog);
copiedBuf.release();
promise.setSuccess(flog);
} finally {
buf.release();
}
}
示例2: filterOpenStreamResponse
import com.couchbase.client.deps.io.netty.buffer.Unpooled; //导入方法依赖的package包/类
private boolean filterOpenStreamResponse(ChannelFlowController flowController, ByteBuf buf) {
try {
Promise<?> promise = dcpChannel.outstandingPromises.remove(MessageUtil.getOpaque(buf));
short vbid = dcpChannel.outstandingVbucketInfos.remove(MessageUtil.getOpaque(buf));
short status = MessageUtil.getStatus(buf);
switch (status) {
case 0x00:
promise.setSuccess(null);
// create a failover log message and emit
ByteBuf flog = Unpooled.buffer();
DcpFailoverLogResponse.init(flog);
DcpFailoverLogResponse.vbucket(flog, DcpOpenStreamResponse.vbucket(buf));
ByteBuf content = MessageUtil.getContent(buf).copy().writeShort(vbid);
MessageUtil.setContent(content, flog);
content.release();
controlEventHandler.onEvent(flowController, flog);
break;
case 0x23:
promise.setFailure(new RollbackException());
// create a rollback message and emit
ByteBuf rb = Unpooled.buffer();
RollbackMessage.init(rb, vbid, DcpOpenStreamResponse.rollbackSeqno(buf));
controlEventHandler.onEvent(flowController, rb);
break;
case 0x07:
promise.setFailure(new NotMyVbucketException());
break;
default:
promise.setFailure(new IllegalStateException("Unhandled Status: " + status));
}
return false;
} finally {
buf.release();
}
}
示例3: testInit
import com.couchbase.client.deps.io.netty.buffer.Unpooled; //导入方法依赖的package包/类
@Test
public void testInit() {
ByteBuf buffer = Unpooled.buffer();
assertFalse(DcpOpenConnectionRequest.is(buffer));
DcpOpenConnectionRequest.init(buffer);
assertEquals(32, buffer.writerIndex());
assertTrue(DcpOpenConnectionRequest.is(buffer));
}
示例4: testSetConnectionName
import com.couchbase.client.deps.io.netty.buffer.Unpooled; //导入方法依赖的package包/类
@Test
public void testSetConnectionName() {
ByteBuf buffer = Unpooled.buffer();
DcpOpenConnectionRequest.init(buffer);
ByteBuf name = Unpooled.copiedBuffer("name", CharsetUtil.UTF_8);
DcpOpenConnectionRequest.connectionName(buffer, name);
assertEquals("name", DcpOpenConnectionRequest.connectionName(buffer).toString(CharsetUtil.UTF_8));
}