builder.setPartition(messageId.getPartitionIndex()); builder.setLedgerId(messageId.getLedgerId()); builder.setEntryId(messageId.getEntryId());
protected byte[] toByteArray(int batchIndex) { MessageIdData.Builder builder = MessageIdData.newBuilder(); builder.setLedgerId(ledgerId); builder.setEntryId(entryId); if (partitionIndex >= 0) { builder.setPartition(partitionIndex); } if (batchIndex != -1) { builder.setBatchIndex(batchIndex); } MessageIdData msgId = builder.build(); int size = msgId.getSerializedSize(); ByteBuf serialized = Unpooled.buffer(size, size); ByteBufCodedOutputStream stream = ByteBufCodedOutputStream.get(serialized); try { msgId.writeTo(stream); } catch (IOException e) { // This is in-memory serialization, should not fail throw new RuntimeException(e); } msgId.recycle(); builder.recycle(); stream.recycle(); return serialized.array(); }
builder.setPartition(messageId.getPartitionIndex()); builder.setLedgerId(messageId.getLedgerId()); builder.setEntryId(messageId.getEntryId());
.setLedgerId(pos.getLedgerId()) .setEntryId(pos.getEntryId()) .setPartition(partitionIdx) .build();
protected byte[] toByteArray(int batchIndex) { MessageIdData.Builder builder = MessageIdData.newBuilder(); builder.setLedgerId(ledgerId); builder.setEntryId(entryId); if (partitionIndex >= 0) { builder.setPartition(partitionIndex); } if (batchIndex != -1) { builder.setBatchIndex(batchIndex); } MessageIdData msgId = builder.build(); int size = msgId.getSerializedSize(); ByteBuf serialized = Unpooled.buffer(size, size); ByteBufCodedOutputStream stream = ByteBufCodedOutputStream.get(serialized); try { msgId.writeTo(stream); } catch (IOException e) { // This is in-memory serialization, should not fail throw new RuntimeException(e); } msgId.recycle(); builder.recycle(); stream.recycle(); return serialized.array(); }
@Override protected void handleGetLastMessageId(CommandGetLastMessageId getLastMessageId) { checkArgument(state == State.Connected); CompletableFuture<Consumer> consumerFuture = consumers.get(getLastMessageId.getConsumerId()); if (consumerFuture != null && consumerFuture.isDone() && !consumerFuture.isCompletedExceptionally()) { Consumer consumer = consumerFuture.getNow(null); long requestId = getLastMessageId.getRequestId(); Topic topic = consumer.getSubscription().getTopic(); Position position = topic.getLastMessageId(); int partitionIndex = TopicName.getPartitionIndex(topic.getName()); if (log.isDebugEnabled()) { log.debug("[{}] [{}][{}] Get LastMessageId {} partitionIndex {}", remoteAddress, topic.getName(), consumer.getSubscription().getName(), position, partitionIndex); } MessageIdData messageId = MessageIdData.newBuilder() .setLedgerId(((PositionImpl)position).getLedgerId()) .setEntryId(((PositionImpl)position).getEntryId()) .setPartition(partitionIndex) .build(); ctx.writeAndFlush(Commands.newGetLastMessageIdResponse(requestId, messageId)); } else { ctx.writeAndFlush(Commands.newError(getLastMessageId.getRequestId(), ServerError.MetadataError, "Consumer not found")); } }
public Builder mergeFrom(org.apache.pulsar.common.api.proto.PulsarApi.MessageIdData other) { if (other == org.apache.pulsar.common.api.proto.PulsarApi.MessageIdData.getDefaultInstance()) return this; if (other.hasLedgerId()) { setLedgerId(other.getLedgerId()); } if (other.hasEntryId()) { setEntryId(other.getEntryId()); } if (other.hasPartition()) { setPartition(other.getPartition()); } if (other.hasBatchIndex()) { setBatchIndex(other.getBatchIndex()); } return this; }
public Builder mergeFrom(org.apache.pulsar.common.api.proto.PulsarApi.MessageIdData other) { if (other == org.apache.pulsar.common.api.proto.PulsarApi.MessageIdData.getDefaultInstance()) return this; if (other.hasLedgerId()) { setLedgerId(other.getLedgerId()); } if (other.hasEntryId()) { setEntryId(other.getEntryId()); } if (other.hasPartition()) { setPartition(other.getPartition()); } if (other.hasBatchIndex()) { setBatchIndex(other.getBatchIndex()); } return this; }