public Builder mergeFrom(org.apache.pulsar.common.api.proto.PulsarApi.CommandAck other) { if (other == org.apache.pulsar.common.api.proto.PulsarApi.CommandAck.getDefaultInstance()) return this; if (other.hasConsumerId()) { setConsumerId(other.getConsumerId()); if (other.hasAckType()) { setAckType(other.getAckType()); if (other.hasValidationError()) { setValidationError(other.getValidationError());
CommandAck ack = cmd.getAck(); handleAck(ack); for (int i = 0; i < ack.getMessageIdCount(); i++) { ack.getMessageId(i).recycle(); ack.recycle(); break;
CommandAck ack = cmd.getAck(); handleAck(ack); for (int i = 0; i < ack.getMessageIdCount(); i++) { ack.getMessageId(i).recycle(); ack.recycle(); break;
message_ = org.apache.pulsar.common.api.proto.PulsarApi.CommandMessage.getDefaultInstance(); bitField0_ = (bitField0_ & ~0x00000100); ack_ = org.apache.pulsar.common.api.proto.PulsarApi.CommandAck.getDefaultInstance(); bitField0_ = (bitField0_ & ~0x00000200); flow_ = org.apache.pulsar.common.api.proto.PulsarApi.CommandFlow.getDefaultInstance();
sendError_ = org.apache.pulsar.common.api.proto.PulsarApi.CommandSendError.getDefaultInstance(); message_ = org.apache.pulsar.common.api.proto.PulsarApi.CommandMessage.getDefaultInstance(); ack_ = org.apache.pulsar.common.api.proto.PulsarApi.CommandAck.getDefaultInstance(); flow_ = org.apache.pulsar.common.api.proto.PulsarApi.CommandFlow.getDefaultInstance(); unsubscribe_ = org.apache.pulsar.common.api.proto.PulsarApi.CommandUnsubscribe.getDefaultInstance();
void messageAcked(CommandAck ack) { Map<String,Long> properties = Collections.emptyMap(); if (ack.getPropertiesCount() > 0) { properties = ack.getPropertiesList().stream() .collect(Collectors.toMap((e) -> e.getKey(), (e) -> e.getValue())); if (ack.getAckType() == AckType.Cumulative) { if (ack.getMessageIdCount() != 1) { log.warn("[{}] [{}] Received multi-message ack at {} - Reason: {}", subscription, consumerId); return; MessageIdData msgId = ack.getMessageId(0); PositionImpl position = PositionImpl.get(msgId.getLedgerId(), msgId.getEntryId()); subscription.acknowledgeMessage(Collections.singletonList(position), AckType.Cumulative, properties); for (int i = 0; i < ack.getMessageIdCount(); i++) { MessageIdData msgId = ack.getMessageId(i); PositionImpl position = PositionImpl.get(msgId.getLedgerId(), msgId.getEntryId()); positionsAcked.add(position); if (ack.hasValidationError()) { log.error("[{}] [{}] Received ack for corrupted message at {} - Reason: {}", subscription, consumerId, position, ack.getValidationError());
public static ByteBuf newMultiMessageAck(long consumerId, List<Pair<Long, Long>> entries) { CommandAck.Builder ackBuilder = CommandAck.newBuilder(); ackBuilder.setConsumerId(consumerId); ackBuilder.setAckType(AckType.Individual); int entriesCount = entries.size(); for (int i = 0; i < entriesCount; i++) { long ledgerId = entries.get(i).getLeft(); long entryId = entries.get(i).getRight(); MessageIdData.Builder messageIdDataBuilder = MessageIdData.newBuilder(); messageIdDataBuilder.setLedgerId(ledgerId); messageIdDataBuilder.setEntryId(entryId); MessageIdData messageIdData = messageIdDataBuilder.build(); ackBuilder.addMessageId(messageIdData); messageIdDataBuilder.recycle(); } CommandAck ack = ackBuilder.build(); ByteBuf res = serializeWithSize(BaseCommand.newBuilder().setType(Type.ACK).setAck(ack)); for (int i = 0; i < entriesCount; i++) { ack.getMessageId(i).recycle(); } ack.recycle(); ackBuilder.recycle(); return res; }
public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; if (isInitialized != -1) return isInitialized == 1; if (!hasConsumerId()) { memoizedIsInitialized = 0; return false; } if (!hasAckType()) { memoizedIsInitialized = 0; return false; } for (int i = 0; i < getMessageIdCount(); i++) { if (!getMessageId(i).isInitialized()) { memoizedIsInitialized = 0; return false; } } for (int i = 0; i < getPropertiesCount(); i++) { if (!getProperties(i).isInitialized()) { memoizedIsInitialized = 0; return false; } } memoizedIsInitialized = 1; return true; }
public Builder mergeFrom(org.apache.pulsar.common.api.proto.PulsarApi.CommandAck other) { if (other == org.apache.pulsar.common.api.proto.PulsarApi.CommandAck.getDefaultInstance()) return this; if (other.hasConsumerId()) { setConsumerId(other.getConsumerId()); if (other.hasAckType()) { setAckType(other.getAckType()); if (other.hasValidationError()) { setValidationError(other.getValidationError());
public org.apache.pulsar.common.api.proto.PulsarApi.CommandAck getDefaultInstanceForType() { return org.apache.pulsar.common.api.proto.PulsarApi.CommandAck.getDefaultInstance(); }
public Builder clearAck() { ack_ = org.apache.pulsar.common.api.proto.PulsarApi.CommandAck.getDefaultInstance(); bitField0_ = (bitField0_ & ~0x00000200); return this; }
@Override protected void handleAck(CommandAck ack) { checkArgument(state == State.Connected); CompletableFuture<Consumer> consumerFuture = consumers.get(ack.getConsumerId()); if (consumerFuture != null && consumerFuture.isDone() && !consumerFuture.isCompletedExceptionally()) { consumerFuture.getNow(null).messageAcked(ack); } }
public Builder mergeAck(org.apache.pulsar.common.api.proto.PulsarApi.CommandAck value) { if (((bitField0_ & 0x00000200) == 0x00000200) && ack_ != org.apache.pulsar.common.api.proto.PulsarApi.CommandAck.getDefaultInstance()) { ack_ = org.apache.pulsar.common.api.proto.PulsarApi.CommandAck.newBuilder(ack_).mergeFrom(value).buildPartial(); } else { ack_ = value; } bitField0_ |= 0x00000200; return this; } public Builder clearAck() {
message_ = org.apache.pulsar.common.api.proto.PulsarApi.CommandMessage.getDefaultInstance(); bitField0_ = (bitField0_ & ~0x00000100); ack_ = org.apache.pulsar.common.api.proto.PulsarApi.CommandAck.getDefaultInstance(); bitField0_ = (bitField0_ & ~0x00000200); flow_ = org.apache.pulsar.common.api.proto.PulsarApi.CommandFlow.getDefaultInstance();
sendError_ = org.apache.pulsar.common.api.proto.PulsarApi.CommandSendError.getDefaultInstance(); message_ = org.apache.pulsar.common.api.proto.PulsarApi.CommandMessage.getDefaultInstance(); ack_ = org.apache.pulsar.common.api.proto.PulsarApi.CommandAck.getDefaultInstance(); flow_ = org.apache.pulsar.common.api.proto.PulsarApi.CommandFlow.getDefaultInstance(); unsubscribe_ = org.apache.pulsar.common.api.proto.PulsarApi.CommandUnsubscribe.getDefaultInstance();
public static ByteBuf newMultiMessageAck(long consumerId, List<Pair<Long, Long>> entries) { CommandAck.Builder ackBuilder = CommandAck.newBuilder(); ackBuilder.setConsumerId(consumerId); ackBuilder.setAckType(AckType.Individual); int entriesCount = entries.size(); for (int i = 0; i < entriesCount; i++) { long ledgerId = entries.get(i).getLeft(); long entryId = entries.get(i).getRight(); MessageIdData.Builder messageIdDataBuilder = MessageIdData.newBuilder(); messageIdDataBuilder.setLedgerId(ledgerId); messageIdDataBuilder.setEntryId(entryId); MessageIdData messageIdData = messageIdDataBuilder.build(); ackBuilder.addMessageId(messageIdData); messageIdDataBuilder.recycle(); } CommandAck ack = ackBuilder.build(); ByteBuf res = serializeWithSize(BaseCommand.newBuilder().setType(Type.ACK).setAck(ack)); for (int i = 0; i < entriesCount; i++) { ack.getMessageId(i).recycle(); } ack.recycle(); ackBuilder.recycle(); return res; }
public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; if (isInitialized != -1) return isInitialized == 1; if (!hasConsumerId()) { memoizedIsInitialized = 0; return false; } if (!hasAckType()) { memoizedIsInitialized = 0; return false; } for (int i = 0; i < getMessageIdCount(); i++) { if (!getMessageId(i).isInitialized()) { memoizedIsInitialized = 0; return false; } } for (int i = 0; i < getPropertiesCount(); i++) { if (!getProperties(i).isInitialized()) { memoizedIsInitialized = 0; return false; } } memoizedIsInitialized = 1; return true; }
public org.apache.pulsar.common.api.proto.PulsarApi.CommandAck getDefaultInstanceForType() { return org.apache.pulsar.common.api.proto.PulsarApi.CommandAck.getDefaultInstance(); }
public Builder clearAck() { ack_ = org.apache.pulsar.common.api.proto.PulsarApi.CommandAck.getDefaultInstance(); bitField0_ = (bitField0_ & ~0x00000200); return this; }
public Builder mergeAck(org.apache.pulsar.common.api.proto.PulsarApi.CommandAck value) { if (((bitField0_ & 0x00000200) == 0x00000200) && ack_ != org.apache.pulsar.common.api.proto.PulsarApi.CommandAck.getDefaultInstance()) { ack_ = org.apache.pulsar.common.api.proto.PulsarApi.CommandAck.newBuilder(ack_).mergeFrom(value).buildPartial(); } else { ack_ = value; } bitField0_ |= 0x00000200; return this; } public Builder clearAck() {