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


Java Unpooled.buffer方法代碼示例

本文整理匯總了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();
    }
}
 
開發者ID:couchbase,項目名稱:java-dcp-client,代碼行數:18,代碼來源:DcpChannelControlHandler.java

示例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();
    }
}
 
開發者ID:couchbase,項目名稱:java-dcp-client,代碼行數:36,代碼來源:DcpChannelControlHandler.java

示例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));
}
 
開發者ID:couchbase,項目名稱:java-dcp-client,代碼行數:11,代碼來源:OpenConnectionRequestTest.java

示例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));
}
 
開發者ID:couchbase,項目名稱:java-dcp-client,代碼行數:11,代碼來源:OpenConnectionRequestTest.java


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