Search in sources :

Example 6 with CommandSuccess

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

the class ServerCnxTest method testAckCommand.

@Test(timeOut = 30000)
public void testAckCommand() throws Exception {
    resetChannel();
    setChannelConnected();
    ByteBuf clientCommand = Commands.newSubscribe(successTopicName, successSubName, 1, /* consumer id */
    1, /*
                   * request id
                   */
    SubType.Exclusive, 0, "test");
    channel.writeInbound(clientCommand);
    assertTrue(getResponse() instanceof CommandSuccess);
    PositionImpl pos = new PositionImpl(0, 0);
    clientCommand = Commands.newAck(1, /* consumer id */
    pos.getLedgerId(), pos.getEntryId(), AckType.Individual, null);
    channel.writeInbound(clientCommand);
    // verify nothing is sent out on the wire after ack
    assertNull(channel.outboundMessages().peek());
    channel.finish();
}
Also used : CommandSuccess(com.yahoo.pulsar.common.api.proto.PulsarApi.CommandSuccess) PositionImpl(org.apache.bookkeeper.mledger.impl.PositionImpl) ByteBuf(io.netty.buffer.ByteBuf) Test(org.testng.annotations.Test)

Example 7 with CommandSuccess

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

the class Commands method newSuccess.

public static ByteBuf newSuccess(long requestId) {
    CommandSuccess.Builder successBuilder = CommandSuccess.newBuilder();
    successBuilder.setRequestId(requestId);
    CommandSuccess success = successBuilder.build();
    ByteBuf res = serializeWithSize(BaseCommand.newBuilder().setType(Type.SUCCESS).setSuccess(success));
    successBuilder.recycle();
    success.recycle();
    return res;
}
Also used : CommandSuccess(com.yahoo.pulsar.common.api.proto.PulsarApi.CommandSuccess) UnpooledHeapByteBuf(io.netty.buffer.UnpooledHeapByteBuf) RecyclableDuplicateByteBuf(io.netty.buffer.RecyclableDuplicateByteBuf) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

CommandSuccess (com.yahoo.pulsar.common.api.proto.PulsarApi.CommandSuccess)7 ByteBuf (io.netty.buffer.ByteBuf)7 Test (org.testng.annotations.Test)6 PersistentTopic (com.yahoo.pulsar.broker.service.persistent.PersistentTopic)3 AuthorizationManager (com.yahoo.pulsar.broker.authorization.AuthorizationManager)2 CommandError (com.yahoo.pulsar.common.api.proto.PulsarApi.CommandError)2 CommandProducerSuccess (com.yahoo.pulsar.common.api.proto.PulsarApi.CommandProducerSuccess)1 RecyclableDuplicateByteBuf (io.netty.buffer.RecyclableDuplicateByteBuf)1 UnpooledHeapByteBuf (io.netty.buffer.UnpooledHeapByteBuf)1 PositionImpl (org.apache.bookkeeper.mledger.impl.PositionImpl)1 Matchers.anyObject (org.mockito.Matchers.anyObject)1