Search in sources :

Example 1 with CommandSendReceipt

use of com.yahoo.pulsar.common.api.proto.PulsarApi.CommandSendReceipt in project pulsar by yahoo.

the class ServerCnxTest method testSendCommand.

@Test(timeOut = 30000)
public void testSendCommand() throws Exception {
    resetChannel();
    setChannelConnected();
    ByteBuf clientCommand = Commands.newProducer(successTopicName, 1, /* producer id */
    1, /* request id */
    "prod-name");
    channel.writeInbound(clientCommand);
    assertTrue(getResponse() instanceof CommandProducerSuccess);
    // test SEND success
    MessageMetadata messageMetadata = MessageMetadata.newBuilder().setPublishTime(System.currentTimeMillis()).setProducerName("prod-name").setSequenceId(0).build();
    ByteBuf data = Unpooled.buffer(1024);
    clientCommand = Commands.newSend(1, 0, 1, ChecksumType.None, messageMetadata, data);
    channel.writeInbound(Unpooled.copiedBuffer(clientCommand));
    clientCommand.release();
    assertTrue(getResponse() instanceof CommandSendReceipt);
    channel.finish();
}
Also used : MessageMetadata(com.yahoo.pulsar.common.api.proto.PulsarApi.MessageMetadata) CommandProducerSuccess(com.yahoo.pulsar.common.api.proto.PulsarApi.CommandProducerSuccess) CommandSendReceipt(com.yahoo.pulsar.common.api.proto.PulsarApi.CommandSendReceipt) ByteBuf(io.netty.buffer.ByteBuf) Test(org.testng.annotations.Test)

Example 2 with CommandSendReceipt

use of com.yahoo.pulsar.common.api.proto.PulsarApi.CommandSendReceipt in project pulsar by yahoo.

the class Commands method newSendReceipt.

public static ByteBuf newSendReceipt(long producerId, long sequenceId, long ledgerId, long entryId) {
    CommandSendReceipt.Builder sendReceiptBuilder = CommandSendReceipt.newBuilder();
    sendReceiptBuilder.setProducerId(producerId);
    sendReceiptBuilder.setSequenceId(sequenceId);
    MessageIdData.Builder messageIdBuilder = MessageIdData.newBuilder();
    messageIdBuilder.setLedgerId(ledgerId);
    messageIdBuilder.setEntryId(entryId);
    MessageIdData messageId = messageIdBuilder.build();
    sendReceiptBuilder.setMessageId(messageId);
    CommandSendReceipt sendReceipt = sendReceiptBuilder.build();
    ByteBuf res = serializeWithSize(BaseCommand.newBuilder().setType(Type.SEND_RECEIPT).setSendReceipt(sendReceipt));
    messageIdBuilder.recycle();
    messageId.recycle();
    sendReceiptBuilder.recycle();
    sendReceipt.recycle();
    return res;
}
Also used : MessageIdData(com.yahoo.pulsar.common.api.proto.PulsarApi.MessageIdData) CommandSendReceipt(com.yahoo.pulsar.common.api.proto.PulsarApi.CommandSendReceipt) UnpooledHeapByteBuf(io.netty.buffer.UnpooledHeapByteBuf) RecyclableDuplicateByteBuf(io.netty.buffer.RecyclableDuplicateByteBuf) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

CommandSendReceipt (com.yahoo.pulsar.common.api.proto.PulsarApi.CommandSendReceipt)2 ByteBuf (io.netty.buffer.ByteBuf)2 CommandProducerSuccess (com.yahoo.pulsar.common.api.proto.PulsarApi.CommandProducerSuccess)1 MessageIdData (com.yahoo.pulsar.common.api.proto.PulsarApi.MessageIdData)1 MessageMetadata (com.yahoo.pulsar.common.api.proto.PulsarApi.MessageMetadata)1 RecyclableDuplicateByteBuf (io.netty.buffer.RecyclableDuplicateByteBuf)1 UnpooledHeapByteBuf (io.netty.buffer.UnpooledHeapByteBuf)1 Test (org.testng.annotations.Test)1