Search in sources :

Example 1 with MessageIdData

use of org.apache.pulsar.common.api.proto.MessageIdData in project pulsar by apache.

the class Consumer method messageAcked.

public CompletableFuture<Void> messageAcked(CommandAck ack) {
    this.lastAckedTimestamp = System.currentTimeMillis();
    Map<String, Long> properties = Collections.emptyMap();
    if (ack.getPropertiesCount() > 0) {
        properties = ack.getPropertiesList().stream().collect(Collectors.toMap(KeyLongValue::getKey, KeyLongValue::getValue));
    }
    if (ack.getAckType() == AckType.Cumulative) {
        if (ack.getMessageIdsCount() != 1) {
            log.warn("[{}] [{}] Received multi-message ack", subscription, consumerId);
        }
        if (Subscription.isIndividualAckMode(subType)) {
            log.warn("[{}] [{}] Received cumulative ack on shared subscription, ignoring", subscription, consumerId);
        }
        PositionImpl position = PositionImpl.EARLIEST;
        if (ack.getMessageIdsCount() == 1) {
            MessageIdData msgId = ack.getMessageIdAt(0);
            if (msgId.getAckSetsCount() > 0) {
                long[] ackSets = new long[msgId.getAckSetsCount()];
                for (int j = 0; j < msgId.getAckSetsCount(); j++) {
                    ackSets[j] = msgId.getAckSetAt(j);
                }
                position = PositionImpl.get(msgId.getLedgerId(), msgId.getEntryId(), ackSets);
            } else {
                position = PositionImpl.get(msgId.getLedgerId(), msgId.getEntryId());
            }
        }
        if (ack.hasTxnidMostBits() && ack.hasTxnidLeastBits()) {
            List<PositionImpl> positionsAcked = Collections.singletonList(position);
            return transactionCumulativeAcknowledge(ack.getTxnidMostBits(), ack.getTxnidLeastBits(), positionsAcked);
        } else {
            List<Position> positionsAcked = Collections.singletonList(position);
            subscription.acknowledgeMessage(positionsAcked, AckType.Cumulative, properties);
            return CompletableFuture.completedFuture(null);
        }
    } else {
        if (ack.hasTxnidLeastBits() && ack.hasTxnidMostBits()) {
            return individualAckWithTransaction(ack);
        } else {
            return individualAckNormal(ack, properties);
        }
    }
}
Also used : MessageIdData(org.apache.pulsar.common.api.proto.MessageIdData) InitialPosition(org.apache.pulsar.common.api.proto.CommandSubscribe.InitialPosition) Position(org.apache.bookkeeper.mledger.Position) PositionImpl(org.apache.bookkeeper.mledger.impl.PositionImpl) KeyLongValue(org.apache.pulsar.common.api.proto.KeyLongValue)

Example 2 with MessageIdData

use of org.apache.pulsar.common.api.proto.MessageIdData in project pulsar by apache.

the class Consumer method individualAckWithTransaction.

// this method is for individual ack carry the transaction
private CompletableFuture<Void> individualAckWithTransaction(CommandAck ack) {
    // Individual ack
    List<MutablePair<PositionImpl, Integer>> positionsAcked = new ArrayList<>();
    if (!isTransactionEnabled()) {
        return FutureUtil.failedFuture(new BrokerServiceException.NotAllowedException("Server don't support transaction ack!"));
    }
    for (int i = 0; i < ack.getMessageIdsCount(); i++) {
        MessageIdData msgId = ack.getMessageIdAt(i);
        PositionImpl position;
        long ackedCount = 0;
        long batchSize = getBatchSize(msgId);
        Consumer ackOwnerConsumer = getAckOwnerConsumer(msgId.getLedgerId(), msgId.getEntryId());
        if (msgId.getAckSetsCount() > 0) {
            long[] ackSets = new long[msgId.getAckSetsCount()];
            for (int j = 0; j < msgId.getAckSetsCount(); j++) {
                ackSets[j] = msgId.getAckSetAt(j);
            }
            position = PositionImpl.get(msgId.getLedgerId(), msgId.getEntryId(), ackSets);
            ackedCount = getAckedCountForTransactionAck(batchSize, ackSets);
        } else {
            position = PositionImpl.get(msgId.getLedgerId(), msgId.getEntryId());
            ackedCount = batchSize;
        }
        positionsAcked.add(new MutablePair<>(position, (int) batchSize));
        addAndGetUnAckedMsgs(ackOwnerConsumer, -(int) ackedCount);
        checkCanRemovePendingAcksAndHandle(position, msgId);
        checkAckValidationError(ack, position);
    }
    CompletableFuture<Void> completableFuture = transactionIndividualAcknowledge(ack.getTxnidMostBits(), ack.getTxnidLeastBits(), positionsAcked);
    if (Subscription.isIndividualAckMode(subType)) {
        completableFuture.whenComplete((v, e) -> positionsAcked.forEach(positionLongMutablePair -> {
            if (positionLongMutablePair.getLeft().getAckSet() != null) {
                if (((PersistentSubscription) subscription).checkIsCanDeleteConsumerPendingAck(positionLongMutablePair.left)) {
                    removePendingAcks(positionLongMutablePair.left);
                }
            }
        }));
    }
    return completableFuture;
}
Also used : LongAdder(java.util.concurrent.atomic.LongAdder) AtomicIntegerFieldUpdater(java.util.concurrent.atomic.AtomicIntegerFieldUpdater) Setter(lombok.Setter) MutableInt(org.apache.commons.lang3.mutable.MutableInt) TopicName(org.apache.pulsar.common.naming.TopicName) LongPair(org.apache.pulsar.common.util.collections.ConcurrentLongLongPairHashMap.LongPair) Getter(lombok.Getter) AckType(org.apache.pulsar.common.api.proto.CommandAck.AckType) MessageIdData(org.apache.pulsar.common.api.proto.MessageIdData) Entry(org.apache.bookkeeper.mledger.Entry) LoggerFactory(org.slf4j.LoggerFactory) CompletableFuture(java.util.concurrent.CompletableFuture) KeySharedMeta(org.apache.pulsar.common.api.proto.KeySharedMeta) ArrayList(java.util.ArrayList) Commands(org.apache.pulsar.common.protocol.Commands) SubType(org.apache.pulsar.common.api.proto.CommandSubscribe.SubType) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) TxnID(org.apache.pulsar.client.api.transaction.TxnID) Lists(com.google.common.collect.Lists) KeyLongValue(org.apache.pulsar.common.api.proto.KeyLongValue) DateFormatter(org.apache.pulsar.common.util.DateFormatter) MutablePair(org.apache.commons.lang3.tuple.MutablePair) Map(java.util.Map) ConsumerStatsImpl(org.apache.pulsar.common.policies.data.stats.ConsumerStatsImpl) CommandAck(org.apache.pulsar.common.api.proto.CommandAck) PositionImpl(org.apache.bookkeeper.mledger.impl.PositionImpl) DEFAULT_CONSUMER_EPOCH(org.apache.pulsar.common.protocol.Commands.DEFAULT_CONSUMER_EPOCH) Logger(org.slf4j.Logger) Promise(io.netty.util.concurrent.Promise) InitialPosition(org.apache.pulsar.common.api.proto.CommandSubscribe.InitialPosition) TransactionConflictException(org.apache.pulsar.transaction.common.exception.TransactionConflictException) BitSetRecyclable(org.apache.pulsar.common.util.collections.BitSetRecyclable) MoreObjects(com.google.common.base.MoreObjects) Position(org.apache.bookkeeper.mledger.Position) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) PersistentTopic(org.apache.pulsar.broker.service.persistent.PersistentTopic) FutureUtil(org.apache.pulsar.common.util.FutureUtil) MessageId(org.apache.pulsar.client.api.MessageId) PersistentSubscription(org.apache.pulsar.broker.service.persistent.PersistentSubscription) ConcurrentLongLongPairHashMap(org.apache.pulsar.common.util.collections.ConcurrentLongLongPairHashMap) BitSet(java.util.BitSet) Future(io.netty.util.concurrent.Future) Collections(java.util.Collections) Rate(org.apache.pulsar.common.stats.Rate) MessageIdData(org.apache.pulsar.common.api.proto.MessageIdData) PositionImpl(org.apache.bookkeeper.mledger.impl.PositionImpl) ArrayList(java.util.ArrayList) MutablePair(org.apache.commons.lang3.tuple.MutablePair)

Example 3 with MessageIdData

use of org.apache.pulsar.common.api.proto.MessageIdData in project pulsar by apache.

the class TransactionConsumeTest method appendTransactionMessages.

private List<MessageIdData> appendTransactionMessages(TxnID txnID, PersistentTopic topic, int transactionMsgCnt, List<String> sendMessageList) throws ExecutionException, InterruptedException, PulsarClientException {
    // Change the state of TB to Ready.
    @Cleanup Producer<String> producer = PulsarClient.builder().serviceUrl(pulsarServiceList.get(0).getBrokerServiceUrl()).enableTransaction(true).build().newProducer(Schema.STRING).topic(CONSUME_TOPIC).sendTimeout(0, TimeUnit.SECONDS).create();
    List<MessageIdData> positionList = new ArrayList<>();
    for (int i = 0; i < transactionMsgCnt; i++) {
        final int j = i;
        MessageMetadata metadata = new MessageMetadata().setProducerName("producerName").setSequenceId(i).setTxnidMostBits(txnID.getMostSigBits()).setTxnidLeastBits(txnID.getLeastSigBits()).setPublishTime(System.currentTimeMillis());
        String msg = TXN_MSG_CONTENT + i;
        sendMessageList.add(msg);
        ByteBuf headerAndPayload = Commands.serializeMetadataAndPayload(Commands.ChecksumType.Crc32c, metadata, Unpooled.copiedBuffer(msg.getBytes(UTF_8)));
        CompletableFuture<PositionImpl> completableFuture = new CompletableFuture<>();
        topic.publishTxnMessage(txnID, headerAndPayload, new Topic.PublishContext() {

            @Override
            public String getProducerName() {
                return "test";
            }

            public long getSequenceId() {
                return j + 30;
            }

            /**
             * Return the producer name for the original producer.
             *
             * For messages published locally, this will return the same local producer name, though in case of replicated
             * messages, the original producer name will differ
             */
            public String getOriginalProducerName() {
                return "test";
            }

            public long getOriginalSequenceId() {
                return j + 30;
            }

            public long getHighestSequenceId() {
                return j + 30;
            }

            public long getOriginalHighestSequenceId() {
                return j + 30;
            }

            public long getNumberOfMessages() {
                return j + 30;
            }

            @Override
            public void completed(Exception e, long ledgerId, long entryId) {
                completableFuture.complete(PositionImpl.get(ledgerId, entryId));
            }
        });
        positionList.add(new MessageIdData().setLedgerId(completableFuture.get().getLedgerId()).setEntryId(completableFuture.get().getEntryId()));
    }
    log.info("append messages to TB finish.");
    return positionList;
}
Also used : MessageIdData(org.apache.pulsar.common.api.proto.MessageIdData) PositionImpl(org.apache.bookkeeper.mledger.impl.PositionImpl) ArrayList(java.util.ArrayList) ByteBuf(io.netty.buffer.ByteBuf) Cleanup(lombok.Cleanup) PulsarClientException(org.apache.pulsar.client.api.PulsarClientException) ExecutionException(java.util.concurrent.ExecutionException) MessageMetadata(org.apache.pulsar.common.api.proto.MessageMetadata) CompletableFuture(java.util.concurrent.CompletableFuture) Topic(org.apache.pulsar.broker.service.Topic) PersistentTopic(org.apache.pulsar.broker.service.persistent.PersistentTopic)

Example 4 with MessageIdData

use of org.apache.pulsar.common.api.proto.MessageIdData in project pulsar by apache.

the class CompactedTopicTest method testEntryLookup.

@Test
public void testEntryLookup() throws Exception {
    BookKeeper bk = pulsar.getBookKeeperClientFactory().create(this.conf, null, null, Optional.empty(), null);
    Triple<Long, List<Pair<MessageIdData, Long>>, List<Pair<MessageIdData, Long>>> compactedLedgerData = buildCompactedLedger(bk, 500);
    List<Pair<MessageIdData, Long>> positions = compactedLedgerData.getMiddle();
    List<Pair<MessageIdData, Long>> idsInGaps = compactedLedgerData.getRight();
    LedgerHandle lh = bk.openLedger(compactedLedgerData.getLeft(), Compactor.COMPACTED_TOPIC_LEDGER_DIGEST_TYPE, Compactor.COMPACTED_TOPIC_LEDGER_PASSWORD);
    long lastEntryId = lh.getLastAddConfirmed();
    AsyncLoadingCache<Long, MessageIdData> cache = CompactedTopicImpl.createCache(lh, 50);
    MessageIdData firstPositionId = positions.get(0).getLeft();
    Pair<MessageIdData, Long> lastPosition = positions.get(positions.size() - 1);
    // check ids before and after ids in compacted ledger
    Assert.assertEquals(CompactedTopicImpl.findStartPoint(new PositionImpl(0, 0), lastEntryId, cache).get(), Long.valueOf(0));
    Assert.assertEquals(CompactedTopicImpl.findStartPoint(new PositionImpl(Long.MAX_VALUE, 0), lastEntryId, cache).get(), Long.valueOf(CompactedTopicImpl.NEWER_THAN_COMPACTED));
    // entry 0 is never in compacted ledger due to how we generate dummy
    Assert.assertEquals(CompactedTopicImpl.findStartPoint(new PositionImpl(firstPositionId.getLedgerId(), 0), lastEntryId, cache).get(), Long.valueOf(0));
    // check next id after last id in compacted ledger
    Assert.assertEquals(CompactedTopicImpl.findStartPoint(new PositionImpl(lastPosition.getLeft().getLedgerId(), lastPosition.getLeft().getEntryId() + 1), lastEntryId, cache).get(), Long.valueOf(CompactedTopicImpl.NEWER_THAN_COMPACTED));
    // shuffle to make cache work hard
    Collections.shuffle(positions, r);
    Collections.shuffle(idsInGaps, r);
    // Check ids we know are in compacted ledger
    for (Pair<MessageIdData, Long> p : positions) {
        PositionImpl pos = new PositionImpl(p.getLeft().getLedgerId(), p.getLeft().getEntryId());
        Long got = CompactedTopicImpl.findStartPoint(pos, lastEntryId, cache).get();
        Assert.assertEquals(got, p.getRight());
    }
    // Check ids we know are in the gaps of the compacted ledger
    for (Pair<MessageIdData, Long> gap : idsInGaps) {
        PositionImpl pos = new PositionImpl(gap.getLeft().getLedgerId(), gap.getLeft().getEntryId());
        Assert.assertEquals(CompactedTopicImpl.findStartPoint(pos, lastEntryId, cache).get(), gap.getRight());
    }
}
Also used : MessageIdData(org.apache.pulsar.common.api.proto.MessageIdData) LedgerHandle(org.apache.bookkeeper.client.LedgerHandle) PositionImpl(org.apache.bookkeeper.mledger.impl.PositionImpl) AtomicLong(java.util.concurrent.atomic.AtomicLong) BookKeeper(org.apache.bookkeeper.client.BookKeeper) List(java.util.List) ArrayList(java.util.ArrayList) Pair(org.apache.commons.lang3.tuple.Pair) Test(org.testng.annotations.Test) MockedPulsarServiceBaseTest(org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest)

Example 5 with MessageIdData

use of org.apache.pulsar.common.api.proto.MessageIdData in project pulsar by apache.

the class ServerCnx method handleSeek.

@Override
protected void handleSeek(CommandSeek seek) {
    checkArgument(state == State.Connected);
    final long requestId = seek.getRequestId();
    CompletableFuture<Consumer> consumerFuture = consumers.get(seek.getConsumerId());
    if (!seek.hasMessageId() && !seek.hasMessagePublishTime()) {
        commandSender.sendErrorResponse(requestId, ServerError.MetadataError, "Message id and message publish time were not present");
        return;
    }
    boolean consumerCreated = consumerFuture != null && consumerFuture.isDone() && !consumerFuture.isCompletedExceptionally();
    if (consumerCreated && seek.hasMessageId()) {
        Consumer consumer = consumerFuture.getNow(null);
        Subscription subscription = consumer.getSubscription();
        MessageIdData msgIdData = seek.getMessageId();
        long[] ackSet = null;
        if (msgIdData.getAckSetsCount() > 0) {
            ackSet = new long[msgIdData.getAckSetsCount()];
            for (int i = 0; i < ackSet.length; i++) {
                ackSet[i] = msgIdData.getAckSetAt(i);
            }
        }
        Position position = new PositionImpl(msgIdData.getLedgerId(), msgIdData.getEntryId(), ackSet);
        subscription.resetCursor(position).thenRun(() -> {
            log.info("[{}] [{}][{}] Reset subscription to message id {}", remoteAddress, subscription.getTopic().getName(), subscription.getName(), position);
            commandSender.sendSuccessResponse(requestId);
        }).exceptionally(ex -> {
            log.warn("[{}][{}] Failed to reset subscription: {}", remoteAddress, subscription, ex.getMessage(), ex);
            commandSender.sendErrorResponse(requestId, ServerError.UnknownError, "Error when resetting subscription: " + ex.getCause().getMessage());
            return null;
        });
    } else if (consumerCreated && seek.hasMessagePublishTime()) {
        Consumer consumer = consumerFuture.getNow(null);
        Subscription subscription = consumer.getSubscription();
        long timestamp = seek.getMessagePublishTime();
        subscription.resetCursor(timestamp).thenRun(() -> {
            log.info("[{}] [{}][{}] Reset subscription to publish time {}", remoteAddress, subscription.getTopic().getName(), subscription.getName(), timestamp);
            commandSender.sendSuccessResponse(requestId);
        }).exceptionally(ex -> {
            log.warn("[{}][{}] Failed to reset subscription: {}", remoteAddress, subscription, ex.getMessage(), ex);
            commandSender.sendErrorResponse(requestId, ServerError.UnknownError, "Reset subscription to publish time error: " + ex.getCause().getMessage());
            return null;
        });
    } else {
        commandSender.sendErrorResponse(requestId, ServerError.MetadataError, "Consumer not found");
    }
}
Also used : CommandAuthResponse(org.apache.pulsar.common.api.proto.CommandAuthResponse) CommandUnsubscribe(org.apache.pulsar.common.api.proto.CommandUnsubscribe) ServiceUnitNotReadyException(org.apache.pulsar.broker.service.BrokerServiceException.ServiceUnitNotReadyException) CommandProducer(org.apache.pulsar.common.api.proto.CommandProducer) MessageIdData(org.apache.pulsar.common.api.proto.MessageIdData) ByteBufPair(org.apache.pulsar.common.protocol.ByteBufPair) StringUtils(org.apache.commons.lang3.StringUtils) ProtocolVersion(org.apache.pulsar.common.api.proto.ProtocolVersion) TxnID(org.apache.pulsar.client.api.transaction.TxnID) MLTransactionMetadataStore(org.apache.pulsar.transaction.coordinator.impl.MLTransactionMetadataStore) TopicOperation(org.apache.pulsar.common.policies.data.TopicOperation) MutableLong(org.apache.commons.lang3.mutable.MutableLong) Map(java.util.Map) BrokerInterceptor(org.apache.pulsar.broker.intercept.BrokerInterceptor) RestException(org.apache.pulsar.broker.web.RestException) NamespaceOperation(org.apache.pulsar.common.policies.data.NamespaceOperation) BaseCommand(org.apache.pulsar.common.api.proto.BaseCommand) CommandAck(org.apache.pulsar.common.api.proto.CommandAck) PositionImpl(org.apache.bookkeeper.mledger.impl.PositionImpl) InterceptException(org.apache.pulsar.common.intercept.InterceptException) CommandFlow(org.apache.pulsar.common.api.proto.CommandFlow) CommandConsumerStats(org.apache.pulsar.common.api.proto.CommandConsumerStats) ServerError(org.apache.pulsar.common.api.proto.ServerError) Set(java.util.Set) CommandNewTxn(org.apache.pulsar.common.api.proto.CommandNewTxn) StringUtils.isNotBlank(org.apache.commons.lang3.StringUtils.isNotBlank) BatchMessageIdImpl(org.apache.pulsar.client.impl.BatchMessageIdImpl) MessageMetadata(org.apache.pulsar.common.api.proto.MessageMetadata) SafeRun(org.apache.bookkeeper.mledger.util.SafeRun) SslHandler(io.netty.handler.ssl.SslHandler) AsyncCallbacks(org.apache.bookkeeper.mledger.AsyncCallbacks) ExceptionUtils(org.apache.commons.lang3.exception.ExceptionUtils) ClientCnx(org.apache.pulsar.client.impl.ClientCnx) ChannelOption(io.netty.channel.ChannelOption) SchemaRegistryService(org.apache.pulsar.broker.service.schema.SchemaRegistryService) AuthenticationState(org.apache.pulsar.broker.authentication.AuthenticationState) CommandGetTopicsOfNamespace(org.apache.pulsar.common.api.proto.CommandGetTopicsOfNamespace) TopicNotFoundException(org.apache.pulsar.broker.service.BrokerServiceException.TopicNotFoundException) SchemaType(org.apache.pulsar.common.schema.SchemaType) Commands(org.apache.pulsar.common.protocol.Commands) CommandCloseProducer(org.apache.pulsar.common.api.proto.CommandCloseProducer) Strings(com.google.common.base.Strings) SubType(org.apache.pulsar.common.api.proto.CommandSubscribe.SubType) ServerMetadataException(org.apache.pulsar.broker.service.BrokerServiceException.ServerMetadataException) SSLSession(javax.net.ssl.SSLSession) CommandGetOrCreateSchema(org.apache.pulsar.common.api.proto.CommandGetOrCreateSchema) ProtocolVersion.v5(org.apache.pulsar.common.api.proto.ProtocolVersion.v5) CommandGetSchema(org.apache.pulsar.common.api.proto.CommandGetSchema) SchemaInfoUtil(org.apache.pulsar.client.impl.schema.SchemaInfoUtil) CommandRedeliverUnacknowledgedMessages(org.apache.pulsar.common.api.proto.CommandRedeliverUnacknowledgedMessages) Metadata(org.apache.pulsar.common.naming.Metadata) Promise(io.netty.util.concurrent.Promise) AuthenticationProvider(org.apache.pulsar.broker.authentication.AuthenticationProvider) InitialPosition(org.apache.pulsar.common.api.proto.CommandSubscribe.InitialPosition) lombok.val(lombok.val) PulsarService(org.apache.pulsar.broker.PulsarService) KeySharedMode(org.apache.pulsar.common.api.proto.KeySharedMode) CommandEndTxnOnSubscription(org.apache.pulsar.common.api.proto.CommandEndTxnOnSubscription) CommandConnect(org.apache.pulsar.common.api.proto.CommandConnect) SchemaData(org.apache.pulsar.common.protocol.schema.SchemaData) ProducerAccessMode(org.apache.pulsar.common.api.proto.ProducerAccessMode) CommandLookupTopic(org.apache.pulsar.common.api.proto.CommandLookupTopic) MutableInt(org.apache.commons.lang3.mutable.MutableInt) SocketAddress(java.net.SocketAddress) CommandAddPartitionToTxn(org.apache.pulsar.common.api.proto.CommandAddPartitionToTxn) LoggerFactory(org.slf4j.LoggerFactory) AuthData(org.apache.pulsar.common.api.AuthData) Exceptions(org.apache.pulsar.functions.utils.Exceptions) AuthenticationException(javax.naming.AuthenticationException) KeyValue(org.apache.pulsar.common.api.proto.KeyValue) PersistentTopicsBase.unsafeGetPartitionedTopicMetadataAsync(org.apache.pulsar.broker.admin.impl.PersistentTopicsBase.unsafeGetPartitionedTopicMetadataAsync) CommandEndTxnOnPartition(org.apache.pulsar.common.api.proto.CommandEndTxnOnPartition) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) BacklogQuotaType(org.apache.pulsar.common.policies.data.BacklogQuota.BacklogQuotaType) Gauge(io.prometheus.client.Gauge) TxnAction(org.apache.pulsar.common.api.proto.TxnAction) NamespaceName(org.apache.pulsar.common.naming.NamespaceName) Schema(org.apache.pulsar.common.api.proto.Schema) TransactionMetadataStoreService(org.apache.pulsar.broker.TransactionMetadataStoreService) PulsarClientException(org.apache.pulsar.client.api.PulsarClientException) IdentityHashMap(java.util.IdentityHashMap) SubscriptionNotFoundException(org.apache.pulsar.broker.service.BrokerServiceException.SubscriptionNotFoundException) Position(org.apache.bookkeeper.mledger.Position) InetSocketAddress(java.net.InetSocketAddress) Collectors(java.util.stream.Collectors) CommandEndTxn(org.apache.pulsar.common.api.proto.CommandEndTxn) AuthenticationDataSource(org.apache.pulsar.broker.authentication.AuthenticationDataSource) Objects(java.util.Objects) ManagedLedgerException(org.apache.bookkeeper.mledger.ManagedLedgerException) MessageIdImpl(org.apache.pulsar.client.impl.MessageIdImpl) PersistentTopic(org.apache.pulsar.broker.service.persistent.PersistentTopic) FutureUtil(org.apache.pulsar.common.util.FutureUtil) PersistentSubscription(org.apache.pulsar.broker.service.persistent.PersistentSubscription) Optional(java.util.Optional) IncompatibleSchemaException(org.apache.pulsar.broker.service.schema.exceptions.IncompatibleSchemaException) PulsarHandler(org.apache.pulsar.common.protocol.PulsarHandler) CommandTcClientConnectRequest(org.apache.pulsar.common.api.proto.CommandTcClientConnectRequest) TopicName(org.apache.pulsar.common.naming.TopicName) CommandAddSubscriptionToTxn(org.apache.pulsar.common.api.proto.CommandAddSubscriptionToTxn) Entry(org.apache.bookkeeper.mledger.Entry) CommandSend(org.apache.pulsar.common.api.proto.CommandSend) BacklogQuota(org.apache.pulsar.common.policies.data.BacklogQuota) CompletableFuture(java.util.concurrent.CompletableFuture) TopicLookupBase.lookupTopicAsync(org.apache.pulsar.broker.lookup.TopicLookupBase.lookupTopicAsync) KeySharedMeta(org.apache.pulsar.common.api.proto.KeySharedMeta) CommandSubscribe(org.apache.pulsar.common.api.proto.CommandSubscribe) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) ByteBuf(io.netty.buffer.ByteBuf) CoordinatorException(org.apache.pulsar.transaction.coordinator.exceptions.CoordinatorException) FastThreadLocal(io.netty.util.concurrent.FastThreadLocal) CommandPartitionedTopicMetadata(org.apache.pulsar.common.api.proto.CommandPartitionedTopicMetadata) CommandSeek(org.apache.pulsar.common.api.proto.CommandSeek) ConsumerStatsImpl(org.apache.pulsar.common.policies.data.stats.ConsumerStatsImpl) NoSuchElementException(java.util.NoSuchElementException) CommandGetLastMessageId(org.apache.pulsar.common.api.proto.CommandGetLastMessageId) CommandUtils(org.apache.pulsar.common.protocol.CommandUtils) ManagedLedgerImpl(org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl) AuthenticationDataCommand(org.apache.pulsar.broker.authentication.AuthenticationDataCommand) DEFAULT_CONSUMER_EPOCH(org.apache.pulsar.common.protocol.Commands.DEFAULT_CONSUMER_EPOCH) Logger(org.slf4j.Logger) Semaphore(java.util.concurrent.Semaphore) ServiceConfiguration(org.apache.pulsar.broker.ServiceConfiguration) FeatureFlags(org.apache.pulsar.common.api.proto.FeatureFlags) CommandCloseConsumer(org.apache.pulsar.common.api.proto.CommandCloseConsumer) SchemaVersion(org.apache.pulsar.common.protocol.schema.SchemaVersion) Commands.newLookupErrorResponse(org.apache.pulsar.common.protocol.Commands.newLookupErrorResponse) TimeUnit(java.util.concurrent.TimeUnit) HAProxyMessage(io.netty.handler.codec.haproxy.HAProxyMessage) ConcurrentLongHashMap(org.apache.pulsar.common.util.collections.ConcurrentLongHashMap) ConsumerBusyException(org.apache.pulsar.broker.service.BrokerServiceException.ConsumerBusyException) ChannelHandler(io.netty.channel.ChannelHandler) VisibleForTesting(com.google.common.annotations.VisibleForTesting) TransactionCoordinatorID(org.apache.pulsar.transaction.coordinator.TransactionCoordinatorID) Collections(java.util.Collections) CommandCloseConsumer(org.apache.pulsar.common.api.proto.CommandCloseConsumer) MessageIdData(org.apache.pulsar.common.api.proto.MessageIdData) InitialPosition(org.apache.pulsar.common.api.proto.CommandSubscribe.InitialPosition) Position(org.apache.bookkeeper.mledger.Position) PositionImpl(org.apache.bookkeeper.mledger.impl.PositionImpl) CommandEndTxnOnSubscription(org.apache.pulsar.common.api.proto.CommandEndTxnOnSubscription) PersistentSubscription(org.apache.pulsar.broker.service.persistent.PersistentSubscription)

Aggregations

MessageIdData (org.apache.pulsar.common.api.proto.MessageIdData)24 ByteBuf (io.netty.buffer.ByteBuf)12 CompletableFuture (java.util.concurrent.CompletableFuture)8 PositionImpl (org.apache.bookkeeper.mledger.impl.PositionImpl)8 ArrayList (java.util.ArrayList)7 Collections (java.util.Collections)6 List (java.util.List)6 MessageId (org.apache.pulsar.client.api.MessageId)6 FutureUtil (org.apache.pulsar.common.util.FutureUtil)6 Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)5 Map (java.util.Map)5 Objects (java.util.Objects)5 AtomicLong (java.util.concurrent.atomic.AtomicLong)5 Collectors (java.util.stream.Collectors)5 PersistentTopic (org.apache.pulsar.broker.service.persistent.PersistentTopic)5 PulsarClientException (org.apache.pulsar.client.api.PulsarClientException)5 CommandAck (org.apache.pulsar.common.api.proto.CommandAck)5 InitialPosition (org.apache.pulsar.common.api.proto.CommandSubscribe.InitialPosition)5 MessageMetadata (org.apache.pulsar.common.api.proto.MessageMetadata)5 IOException (java.io.IOException)4