Class PendingAckHandleImpl

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.concurrent.CompletableFuture<java.lang.Void> abortTxn​(org.apache.pulsar.client.api.transaction.TxnID txnId, Consumer consumer, long lowWaterMark)
      Abort a transaction.
      boolean checkIfPendingAckStoreInit()
      Check if the PendingAckStore is init.
      boolean checkIsCanDeleteConsumerPendingAck​(org.apache.bookkeeper.mledger.impl.PositionImpl position)
      Judge the all ack set point have acked by normal ack and transaction pending ack.
      void clearIndividualPosition​(org.apache.bookkeeper.mledger.Position position)
      When the position is actually deleted, we can use this method to clear the cache for individual ack messages.
      java.util.concurrent.CompletableFuture<java.lang.Void> closeAsync()
      Close the pending ack handle.
      java.util.concurrent.CompletableFuture<java.lang.Void> commitTxn​(org.apache.pulsar.client.api.transaction.TxnID txnID, java.util.Map<java.lang.String,​java.lang.Long> properties, long lowWaterMark)
      Commit a transaction.
      void completeHandleFuture()  
      java.util.concurrent.CompletableFuture<java.lang.Void> cumulativeAcknowledgeMessage​(org.apache.pulsar.client.api.transaction.TxnID txnID, java.util.List<org.apache.bookkeeper.mledger.impl.PositionImpl> positions)
      Acknowledge message(s) for an ongoing transaction.
      void exceptionHandleFuture​(java.lang.Throwable t)  
      org.apache.bookkeeper.mledger.impl.PositionImpl getPositionInPendingAck​(org.apache.bookkeeper.mledger.impl.PositionImpl position)
      If it returns null, it means this Position is not in pendingAck.
      org.apache.pulsar.common.policies.data.TransactionPendingAckStats getStats()
      Get pending ack handle stats.
      java.util.concurrent.CompletableFuture<org.apache.bookkeeper.mledger.ManagedLedger> getStoreManageLedger()  
      java.lang.String getSubName()  
      java.lang.String getTopicName()  
      org.apache.pulsar.common.policies.data.TransactionInPendingAckStats getTransactionInPendingAckStats​(org.apache.pulsar.client.api.transaction.TxnID txnID)
      Get transaction in pending ack stats.
      protected void handleAbort​(org.apache.pulsar.client.api.transaction.TxnID txnID, org.apache.pulsar.common.api.proto.CommandAck.AckType ackType)  
      protected void handleCacheRequest()  
      protected void handleCommit​(org.apache.pulsar.client.api.transaction.TxnID txnID, org.apache.pulsar.common.api.proto.CommandAck.AckType ackType, java.util.Map<java.lang.String,​java.lang.Long> properties)  
      protected void handleCumulativeAckRecover​(org.apache.pulsar.client.api.transaction.TxnID txnID, org.apache.bookkeeper.mledger.impl.PositionImpl position)  
      protected void handleIndividualAckRecover​(org.apache.pulsar.client.api.transaction.TxnID txnID, java.util.List<org.apache.commons.lang3.tuple.MutablePair<org.apache.bookkeeper.mledger.impl.PositionImpl,​java.lang.Integer>> positions)  
      java.util.concurrent.CompletableFuture<java.lang.Void> individualAcknowledgeMessage​(org.apache.pulsar.client.api.transaction.TxnID txnID, java.util.List<org.apache.commons.lang3.tuple.MutablePair<org.apache.bookkeeper.mledger.impl.PositionImpl,​java.lang.Integer>> positions)
      Acknowledge message(s) for an ongoing transaction.
      java.util.concurrent.CompletableFuture<java.lang.Void> internalAbortTxn​(org.apache.pulsar.client.api.transaction.TxnID txnId, Consumer consumer, long lowWaterMark, java.util.concurrent.CompletableFuture<java.lang.Void> abortFuture)  
      void internalCumulativeAcknowledgeMessage​(org.apache.pulsar.client.api.transaction.TxnID txnID, java.util.List<org.apache.bookkeeper.mledger.impl.PositionImpl> positions, java.util.concurrent.CompletableFuture<java.lang.Void> completableFuture)  
      void internalIndividualAcknowledgeMessage​(org.apache.pulsar.client.api.transaction.TxnID txnID, java.util.List<org.apache.commons.lang3.tuple.MutablePair<org.apache.bookkeeper.mledger.impl.PositionImpl,​java.lang.Integer>> positions, java.util.concurrent.CompletableFuture<java.lang.Void> completableFuture)  
      java.util.concurrent.CompletableFuture<PendingAckHandle> pendingAckHandleFuture()
      Pending ack recover whether ready future.
      void syncBatchPositionAckSetForTransaction​(org.apache.bookkeeper.mledger.impl.PositionImpl position)
      Sync the position ack set, in order to clean up the cache of this position for pending ack handle.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • internalIndividualAcknowledgeMessage

        public void internalIndividualAcknowledgeMessage​(org.apache.pulsar.client.api.transaction.TxnID txnID,
                                                         java.util.List<org.apache.commons.lang3.tuple.MutablePair<org.apache.bookkeeper.mledger.impl.PositionImpl,​java.lang.Integer>> positions,
                                                         java.util.concurrent.CompletableFuture<java.lang.Void> completableFuture)
      • individualAcknowledgeMessage

        public java.util.concurrent.CompletableFuture<java.lang.Void> individualAcknowledgeMessage​(org.apache.pulsar.client.api.transaction.TxnID txnID,
                                                                                                   java.util.List<org.apache.commons.lang3.tuple.MutablePair<org.apache.bookkeeper.mledger.impl.PositionImpl,​java.lang.Integer>> positions)
        Description copied from interface: PendingAckHandle
        Acknowledge message(s) for an ongoing transaction.

        It can be of CommandAck.AckType.Individual. Single messages acked by ongoing transaction will be put in pending_ack state and only marked as deleted after transaction is committed.

        If transaction is aborted all messages acked by it will be put back to pending state.

        Client will not send batch size to server, we get the batch size from consumer pending ack. When we get the Batch size, we can accurate batch ack of this position.

        Specified by:
        individualAcknowledgeMessage in interface PendingAckHandle
        Parameters:
        txnID - TxnID TransactionID of an ongoing transaction trying to sck message.
        positions - MutablePair the pair of positions and these batch size.
        Returns:
        the future of this operation.
      • internalCumulativeAcknowledgeMessage

        public void internalCumulativeAcknowledgeMessage​(org.apache.pulsar.client.api.transaction.TxnID txnID,
                                                         java.util.List<org.apache.bookkeeper.mledger.impl.PositionImpl> positions,
                                                         java.util.concurrent.CompletableFuture<java.lang.Void> completableFuture)
      • cumulativeAcknowledgeMessage

        public java.util.concurrent.CompletableFuture<java.lang.Void> cumulativeAcknowledgeMessage​(org.apache.pulsar.client.api.transaction.TxnID txnID,
                                                                                                   java.util.List<org.apache.bookkeeper.mledger.impl.PositionImpl> positions)
        Description copied from interface: PendingAckHandle
        Acknowledge message(s) for an ongoing transaction.

        It can be of CommandAck.AckType.Cumulative. Single messages acked by ongoing transaction will be put in pending_ack state and only marked as deleted after transaction is committed.

        For a moment, we only allow one transaction cumulative ack multiple times when the position is greater than the old one.

        We have a transaction with cumulative ack, if other transaction want to cumulative ack, we will return TransactionConflictException.

        If an ongoing transaction cumulative acked a message and then try to ack single message which is greater than that one it cumulative acked, it'll succeed.

        Specified by:
        cumulativeAcknowledgeMessage in interface PendingAckHandle
        Parameters:
        txnID - TxnID TransactionID of an ongoing transaction trying to sck message.
        positions - MutablePair the pair of positions and these batch size.
        Returns:
        the future of this operation.
      • commitTxn

        public java.util.concurrent.CompletableFuture<java.lang.Void> commitTxn​(org.apache.pulsar.client.api.transaction.TxnID txnID,
                                                                                java.util.Map<java.lang.String,​java.lang.Long> properties,
                                                                                long lowWaterMark)
        Description copied from interface: PendingAckHandle
        Commit a transaction.
        Specified by:
        commitTxn in interface PendingAckHandle
        Parameters:
        txnID - TxnID to identify the transaction.
        properties - Additional user-defined properties that can be associated with a particular cursor position.
        lowWaterMark - the low water mark of this transaction
        Returns:
        the future of this operation.
      • internalAbortTxn

        public java.util.concurrent.CompletableFuture<java.lang.Void> internalAbortTxn​(org.apache.pulsar.client.api.transaction.TxnID txnId,
                                                                                       Consumer consumer,
                                                                                       long lowWaterMark,
                                                                                       java.util.concurrent.CompletableFuture<java.lang.Void> abortFuture)
      • abortTxn

        public java.util.concurrent.CompletableFuture<java.lang.Void> abortTxn​(org.apache.pulsar.client.api.transaction.TxnID txnId,
                                                                               Consumer consumer,
                                                                               long lowWaterMark)
        Description copied from interface: PendingAckHandle
        Abort a transaction.
        Specified by:
        abortTxn in interface PendingAckHandle
        Parameters:
        txnId - TxnID to identify the transaction.
        consumer - Consumer which aborting transaction.
        lowWaterMark - the low water mark of this transaction
        Returns:
        the future of this operation.
      • syncBatchPositionAckSetForTransaction

        public void syncBatchPositionAckSetForTransaction​(org.apache.bookkeeper.mledger.impl.PositionImpl position)
        Description copied from interface: PendingAckHandle
        Sync the position ack set, in order to clean up the cache of this position for pending ack handle.
        Specified by:
        syncBatchPositionAckSetForTransaction in interface PendingAckHandle
        Parameters:
        position - Position which position need to sync and carry it batch size
      • checkIsCanDeleteConsumerPendingAck

        public boolean checkIsCanDeleteConsumerPendingAck​(org.apache.bookkeeper.mledger.impl.PositionImpl position)
        Description copied from interface: PendingAckHandle
        Judge the all ack set point have acked by normal ack and transaction pending ack.
        Specified by:
        checkIsCanDeleteConsumerPendingAck in interface PendingAckHandle
        Parameters:
        position - Position which position need to check
      • handleAbort

        protected void handleAbort​(org.apache.pulsar.client.api.transaction.TxnID txnID,
                                   org.apache.pulsar.common.api.proto.CommandAck.AckType ackType)
      • handleCommit

        protected void handleCommit​(org.apache.pulsar.client.api.transaction.TxnID txnID,
                                    org.apache.pulsar.common.api.proto.CommandAck.AckType ackType,
                                    java.util.Map<java.lang.String,​java.lang.Long> properties)
      • handleCumulativeAckRecover

        protected void handleCumulativeAckRecover​(org.apache.pulsar.client.api.transaction.TxnID txnID,
                                                  org.apache.bookkeeper.mledger.impl.PositionImpl position)
      • handleIndividualAckRecover

        protected void handleIndividualAckRecover​(org.apache.pulsar.client.api.transaction.TxnID txnID,
                                                  java.util.List<org.apache.commons.lang3.tuple.MutablePair<org.apache.bookkeeper.mledger.impl.PositionImpl,​java.lang.Integer>> positions)
      • getTopicName

        public java.lang.String getTopicName()
      • getSubName

        public java.lang.String getSubName()
      • clearIndividualPosition

        public void clearIndividualPosition​(org.apache.bookkeeper.mledger.Position position)
        Description copied from interface: PendingAckHandle
        When the position is actually deleted, we can use this method to clear the cache for individual ack messages.
        Specified by:
        clearIndividualPosition in interface PendingAckHandle
        Parameters:
        position - Position which position need to clear
      • getStats

        public org.apache.pulsar.common.policies.data.TransactionPendingAckStats getStats()
        Description copied from interface: PendingAckHandle
        Get pending ack handle stats.
        Specified by:
        getStats in interface PendingAckHandle
        Returns:
        the stats of this pending ack handle.
      • completeHandleFuture

        public void completeHandleFuture()
      • exceptionHandleFuture

        public void exceptionHandleFuture​(java.lang.Throwable t)
      • getTransactionInPendingAckStats

        public org.apache.pulsar.common.policies.data.TransactionInPendingAckStats getTransactionInPendingAckStats​(org.apache.pulsar.client.api.transaction.TxnID txnID)
        Description copied from interface: PendingAckHandle
        Get transaction in pending ack stats.
        Specified by:
        getTransactionInPendingAckStats in interface PendingAckHandle
        Parameters:
        txnID - the txnID
        Returns:
        the stats of this transaction in pending ack.
      • closeAsync

        public java.util.concurrent.CompletableFuture<java.lang.Void> closeAsync()
        Description copied from interface: PendingAckHandle
        Close the pending ack handle.
        Specified by:
        closeAsync in interface PendingAckHandle
        Returns:
        the future of this operation.
      • getStoreManageLedger

        public java.util.concurrent.CompletableFuture<org.apache.bookkeeper.mledger.ManagedLedger> getStoreManageLedger()
      • getPositionInPendingAck

        public org.apache.bookkeeper.mledger.impl.PositionImpl getPositionInPendingAck​(org.apache.bookkeeper.mledger.impl.PositionImpl position)
        Description copied from interface: PendingAckHandle
        If it returns null, it means this Position is not in pendingAck.

        If it does not return null, it means this Position is in pendingAck and if it is batch Position, it will return the corresponding ackSet in pendingAck

        Specified by:
        getPositionInPendingAck in interface PendingAckHandle
        Parameters:
        position - Position witch need to get in pendingAck
        Returns:
        Position return the position in pendingAck
      • handleCacheRequest

        protected void handleCacheRequest()