Class MLTransactionMetadataStore
- java.lang.Object
-
- org.apache.pulsar.transaction.coordinator.TransactionMetadataStoreState
-
- org.apache.pulsar.transaction.coordinator.impl.MLTransactionMetadataStore
-
- All Implemented Interfaces:
TransactionMetadataStore
public class MLTransactionMetadataStore extends TransactionMetadataStoreState implements TransactionMetadataStore
The provider that offers managed ledger implementation ofTransactionMetadataStore.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.pulsar.transaction.coordinator.TransactionMetadataStoreState
TransactionMetadataStoreState.State
-
-
Constructor Summary
Constructors Constructor Description MLTransactionMetadataStore(TransactionCoordinatorID tcID, MLTransactionLogImpl mlTransactionLog, TransactionTimeoutTracker timeoutTracker, MLTransactionSequenceIdGenerator sequenceIdGenerator)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.concurrent.CompletableFuture<java.lang.Void>addAckedPartitionToTxn(org.apache.pulsar.client.api.transaction.TxnID txnID, java.util.List<TransactionSubscription> txnSubscriptions)Add the acked partitions to transaction identified by txnid.java.util.concurrent.CompletableFuture<java.lang.Void>addProducedPartitionToTxn(org.apache.pulsar.client.api.transaction.TxnID txnID, java.util.List<java.lang.String> partitions)Add the produced partitions to transaction identified by txnid.java.util.concurrent.CompletableFuture<java.lang.Void>closeAsync()Close the transaction metadata store.org.apache.pulsar.common.policies.data.TransactionCoordinatorStatsgetCoordinatorStats()Get the transaction metadata store stats.longgetLowWaterMark()Get the low water mark of this tc, in order to delete unless transaction in transaction buffer and pending ack.org.apache.bookkeeper.mledger.ManagedLedgergetManagedLedger()TransactionMetadataStoreStatsgetMetadataStoreStats()Get the transaction metadata store stats.java.util.List<TxnMeta>getSlowTransactions(long timeout)Get the transactions witch timeout is bigger than given timeout.TransactionCoordinatorIDgetTransactionCoordinatorID()Get the transaction coordinator id.java.util.concurrent.CompletableFuture<TxnMeta>getTxnMeta(org.apache.pulsar.client.api.transaction.TxnID txnID)Query theTxnMetaof a given transaction txnid.java.util.concurrent.CompletableFuture<TxnStatus>getTxnStatus(org.apache.pulsar.client.api.transaction.TxnID txnID)Query theTxnStatusof a given transaction txnid.java.util.concurrent.CompletableFuture<TransactionMetadataStore>init(TransactionRecoverTracker recoverTracker)java.util.concurrent.CompletableFuture<org.apache.pulsar.client.api.transaction.TxnID>newTransaction(long timeOut, java.lang.String owner)Create a new transaction in the transaction metadata store.static java.util.List<TransactionSubscription>subscriptionToTxnSubscription(java.util.List<org.apache.pulsar.common.api.proto.Subscription> subscriptions)static java.util.List<org.apache.pulsar.common.api.proto.Subscription>txnSubscriptionToSubscription(java.util.List<TransactionSubscription> tnxSubscriptions)java.util.concurrent.CompletableFuture<java.lang.Void>updateTxnStatus(org.apache.pulsar.client.api.transaction.TxnID txnID, TxnStatus newStatus, TxnStatus expectedStatus, boolean isTimeout)Update the transaction from expectedStatus to newStatus.-
Methods inherited from class org.apache.pulsar.transaction.coordinator.TransactionMetadataStoreState
changeToCloseState, changeToClosingState, changeToInitializingState, changeToReadyState, checkIfReady, getState
-
-
-
-
Constructor Detail
-
MLTransactionMetadataStore
public MLTransactionMetadataStore(TransactionCoordinatorID tcID, MLTransactionLogImpl mlTransactionLog, TransactionTimeoutTracker timeoutTracker, MLTransactionSequenceIdGenerator sequenceIdGenerator)
-
-
Method Detail
-
init
public java.util.concurrent.CompletableFuture<TransactionMetadataStore> init(TransactionRecoverTracker recoverTracker)
-
getTxnStatus
public java.util.concurrent.CompletableFuture<TxnStatus> getTxnStatus(org.apache.pulsar.client.api.transaction.TxnID txnID)
Description copied from interface:TransactionMetadataStoreQuery theTxnStatusof a given transaction txnid.- Specified by:
getTxnStatusin interfaceTransactionMetadataStore- Parameters:
txnID- transaction id- Returns:
- a future represents the result of this operation.
it returns
TxnStatusof the given transaction.
-
getTxnMeta
public java.util.concurrent.CompletableFuture<TxnMeta> getTxnMeta(org.apache.pulsar.client.api.transaction.TxnID txnID)
Description copied from interface:TransactionMetadataStoreQuery theTxnMetaof a given transaction txnid.- Specified by:
getTxnMetain interfaceTransactionMetadataStore- Parameters:
txnID- transaction id- Returns:
- a future represents the result of this operation.
it returns
TxnMetaof the given transaction.
-
newTransaction
public java.util.concurrent.CompletableFuture<org.apache.pulsar.client.api.transaction.TxnID> newTransaction(long timeOut, java.lang.String owner)Description copied from interface:TransactionMetadataStoreCreate a new transaction in the transaction metadata store.- Specified by:
newTransactionin interfaceTransactionMetadataStore- Parameters:
timeOut- the timeout duration of the transaction in millsowner- the role which is the owner of the transaction- Returns:
- a future represents the result of creating a new transaction.
it returns
TxnIDas the identifier for identifying the transaction.
-
addProducedPartitionToTxn
public java.util.concurrent.CompletableFuture<java.lang.Void> addProducedPartitionToTxn(org.apache.pulsar.client.api.transaction.TxnID txnID, java.util.List<java.lang.String> partitions)Description copied from interface:TransactionMetadataStoreAdd the produced partitions to transaction identified by txnid.- Specified by:
addProducedPartitionToTxnin interfaceTransactionMetadataStore- Parameters:
txnID- transaction idpartitions- the list of partitions that a transaction produces to- Returns:
- a future represents the result of this operation
-
addAckedPartitionToTxn
public java.util.concurrent.CompletableFuture<java.lang.Void> addAckedPartitionToTxn(org.apache.pulsar.client.api.transaction.TxnID txnID, java.util.List<TransactionSubscription> txnSubscriptions)Description copied from interface:TransactionMetadataStoreAdd the acked partitions to transaction identified by txnid.- Specified by:
addAckedPartitionToTxnin interfaceTransactionMetadataStore- Parameters:
txnID- transaction idtxnSubscriptions- the list of partitions that a transaction acknowledge to- Returns:
- a future represents the result of the operation
-
updateTxnStatus
public java.util.concurrent.CompletableFuture<java.lang.Void> updateTxnStatus(org.apache.pulsar.client.api.transaction.TxnID txnID, TxnStatus newStatus, TxnStatus expectedStatus, boolean isTimeout)Description copied from interface:TransactionMetadataStoreUpdate the transaction from expectedStatus to newStatus.If the current transaction status is not expectedStatus, the update will be failed.
- Specified by:
updateTxnStatusin interfaceTransactionMetadataStore- Parameters:
txnID-TxnIDfor update txn statusnewStatus- the new txn status that the transaction should be updated toexpectedStatus- the expected status that the transaction should beisTimeout- the update txn status operation is it timeout- Returns:
- a future represents the result of the operation
-
getLowWaterMark
public long getLowWaterMark()
Description copied from interface:TransactionMetadataStoreGet the low water mark of this tc, in order to delete unless transaction in transaction buffer and pending ack.- Specified by:
getLowWaterMarkin interfaceTransactionMetadataStore- Returns:
- long
longthe lowWaterMark
-
getTransactionCoordinatorID
public TransactionCoordinatorID getTransactionCoordinatorID()
Description copied from interface:TransactionMetadataStoreGet the transaction coordinator id.- Specified by:
getTransactionCoordinatorIDin interfaceTransactionMetadataStore- Returns:
- transaction coordinator id
-
getCoordinatorStats
public org.apache.pulsar.common.policies.data.TransactionCoordinatorStats getCoordinatorStats()
Description copied from interface:TransactionMetadataStoreGet the transaction metadata store stats.- Specified by:
getCoordinatorStatsin interfaceTransactionMetadataStore- Returns:
- TransactionCoordinatorStats
TransactionCoordinatorStats
-
closeAsync
public java.util.concurrent.CompletableFuture<java.lang.Void> closeAsync()
Description copied from interface:TransactionMetadataStoreClose the transaction metadata store.- Specified by:
closeAsyncin interfaceTransactionMetadataStore- Returns:
- a future represents the result of this operation
-
getMetadataStoreStats
public TransactionMetadataStoreStats getMetadataStoreStats()
Description copied from interface:TransactionMetadataStoreGet the transaction metadata store stats.- Specified by:
getMetadataStoreStatsin interfaceTransactionMetadataStore- Returns:
- TransactionMetadataStoreStats
TransactionMetadataStoreStats
-
getSlowTransactions
public java.util.List<TxnMeta> getSlowTransactions(long timeout)
Description copied from interface:TransactionMetadataStoreGet the transactions witch timeout is bigger than given timeout.- Specified by:
getSlowTransactionsin interfaceTransactionMetadataStore- Returns:
TxnMetathe txnMetas of slow transactions
-
txnSubscriptionToSubscription
public static java.util.List<org.apache.pulsar.common.api.proto.Subscription> txnSubscriptionToSubscription(java.util.List<TransactionSubscription> tnxSubscriptions)
-
subscriptionToTxnSubscription
public static java.util.List<TransactionSubscription> subscriptionToTxnSubscription(java.util.List<org.apache.pulsar.common.api.proto.Subscription> subscriptions)
-
getManagedLedger
public org.apache.bookkeeper.mledger.ManagedLedger getManagedLedger()
-
-