Class TopicTransactionBuffer
java.lang.Object
org.apache.pulsar.broker.transaction.buffer.impl.TopicTransactionBufferState
org.apache.pulsar.broker.transaction.buffer.impl.TopicTransactionBuffer
- All Implemented Interfaces:
io.netty.util.TimerTask,TransactionBuffer
public class TopicTransactionBuffer
extends TopicTransactionBufferState
implements TransactionBuffer, io.netty.util.TimerTask
Transaction buffer based on normal persistent topic.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classNested classes/interfaces inherited from class org.apache.pulsar.broker.transaction.buffer.impl.TopicTransactionBufferState
TopicTransactionBufferState.State -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal org.apache.pulsar.common.util.RecoverTimeRecord -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabortTxn(org.apache.pulsar.client.api.transaction.TxnID txnID, long lowWaterMark) Abort the transaction and all the entries of this transaction will be discarded.CompletableFuture<org.apache.bookkeeper.mledger.Position>appendBufferToTxn(org.apache.pulsar.client.api.transaction.TxnID txnId, long sequenceId, io.netty.buffer.ByteBuf buffer) Append the buffer to the transaction buffer.checkIfTBRecoverCompletely(boolean isTxnEnabled) Wait TransactionBuffer Recovers completely.Clear up the snapshot of the TransactionBuffer.Close the buffer asynchronously.commitTxn(org.apache.pulsar.client.api.transaction.TxnID txnID, long lowWaterMark) Commit the transaction and seal the buffer for this transaction.longlongorg.apache.bookkeeper.mledger.impl.PositionImplGet the can read max position.longorg.apache.pulsar.common.policies.data.TransactionBufferStatsgetStats(boolean lowWaterMarks) Get transaction stats in buffer.org.apache.pulsar.common.policies.data.TransactionInBufferStatsgetTransactionInBufferStats(org.apache.pulsar.client.api.transaction.TxnID txnID) Get transaction in buffer stats.getTransactionMeta(org.apache.pulsar.client.api.transaction.TxnID txnID) Return the metadata of a transaction in the buffer.booleanisTxnAborted(org.apache.pulsar.client.api.transaction.TxnID txnID) Close the buffer asynchronously.openTransactionBufferReader(org.apache.pulsar.client.api.transaction.TxnID txnID, long startSequenceId) Open aTransactionBufferReaderto read entries of a given transaction starting from the provided sequenceId.Purge all the data of the transactions who are committed and stored in the provided data ledgers.voidrun(io.netty.util.Timeout timeout) voidsyncMaxReadPositionForNormalPublish(org.apache.bookkeeper.mledger.impl.PositionImpl position) Sync max read position for normal publish.Methods inherited from class org.apache.pulsar.broker.transaction.buffer.impl.TopicTransactionBufferState
changeToCloseState, changeToInitializingState, changeToNoSnapshotState, changeToReadyState, changeToReadyStateFromNoSnapshot, checkIfNoSnapshot, checkIfReady, getState
-
Field Details
-
recoverTime
public final org.apache.pulsar.common.util.RecoverTimeRecord recoverTime
-
-
Constructor Details
-
TopicTransactionBuffer
-
-
Method Details
-
getTransactionMeta
public CompletableFuture<TransactionMeta> getTransactionMeta(org.apache.pulsar.client.api.transaction.TxnID txnID) Description copied from interface:TransactionBufferReturn the metadata of a transaction in the buffer.- Specified by:
getTransactionMetain interfaceTransactionBuffer- Parameters:
txnID- the transaction id- Returns:
- a future represents the result of the operation
-
checkIfTBRecoverCompletely
Description copied from interface:TransactionBufferWait TransactionBuffer Recovers completely. Take snapshot after TB Recovers completely.- Specified by:
checkIfTBRecoverCompletelyin interfaceTransactionBuffer- Returns:
- a future which has completely if isTxn = false. Or a future return by takeSnapshot.
-
getOngoingTxnCount
public long getOngoingTxnCount()- Specified by:
getOngoingTxnCountin interfaceTransactionBuffer
-
getAbortedTxnCount
public long getAbortedTxnCount()- Specified by:
getAbortedTxnCountin interfaceTransactionBuffer
-
getCommittedTxnCount
public long getCommittedTxnCount()- Specified by:
getCommittedTxnCountin interfaceTransactionBuffer
-
appendBufferToTxn
public CompletableFuture<org.apache.bookkeeper.mledger.Position> appendBufferToTxn(org.apache.pulsar.client.api.transaction.TxnID txnId, long sequenceId, io.netty.buffer.ByteBuf buffer) Description copied from interface:TransactionBufferAppend the buffer to the transaction buffer.The entry will be indexed by txnId and sequenceId.
- Specified by:
appendBufferToTxnin interfaceTransactionBuffer- Parameters:
txnId- the transaction idsequenceId- the sequence id of the entry in this transaction buffer.buffer- the entry buffer- Returns:
- a future represents the result of the operation.
-
openTransactionBufferReader
public CompletableFuture<TransactionBufferReader> openTransactionBufferReader(org.apache.pulsar.client.api.transaction.TxnID txnID, long startSequenceId) Description copied from interface:TransactionBufferOpen aTransactionBufferReaderto read entries of a given transaction starting from the provided sequenceId.- Specified by:
openTransactionBufferReaderin interfaceTransactionBuffer- Parameters:
txnID- transaction idstartSequenceId- the sequence id to start read- Returns:
- a future represents the result of open operation.
-
commitTxn
public CompletableFuture<Void> commitTxn(org.apache.pulsar.client.api.transaction.TxnID txnID, long lowWaterMark) Description copied from interface:TransactionBufferCommit the transaction and seal the buffer for this transaction.If a transaction is sealed, no more entries can be
TransactionBuffer.appendBufferToTxn(TxnID, long, ByteBuf).- Specified by:
commitTxnin interfaceTransactionBuffer- Parameters:
txnID- the transaction idlowWaterMark- the low water mark of this transaction- Returns:
- a future represents the result of commit operation.
-
abortTxn
public CompletableFuture<Void> abortTxn(org.apache.pulsar.client.api.transaction.TxnID txnID, long lowWaterMark) Description copied from interface:TransactionBufferAbort the transaction and all the entries of this transaction will be discarded.- Specified by:
abortTxnin interfaceTransactionBuffer- Parameters:
txnID- the transaction idlowWaterMark- the low water mark of this transaction- Returns:
- a future represents the result of abort operation.
-
purgeTxns
Description copied from interface:TransactionBufferPurge all the data of the transactions who are committed and stored in the provided data ledgers.This method will be called by the broker before they delete the ledgers. It ensures that all the transactions committed in those ledgers can be purged.
- Specified by:
purgeTxnsin interfaceTransactionBuffer- Parameters:
dataLedgers- the list of data ledgers.- Returns:
- a future represents the result of purge operations.
-
clearSnapshot
Description copied from interface:TransactionBufferClear up the snapshot of the TransactionBuffer.- Specified by:
clearSnapshotin interfaceTransactionBuffer- Returns:
- Clear up operation result.
-
closeAsync
Description copied from interface:TransactionBufferClose the buffer asynchronously.- Specified by:
closeAsyncin interfaceTransactionBuffer- Returns:
-
isTxnAborted
public boolean isTxnAborted(org.apache.pulsar.client.api.transaction.TxnID txnID) Description copied from interface:TransactionBufferClose the buffer asynchronously.- Specified by:
isTxnAbortedin interfaceTransactionBuffer- Parameters:
txnID-TxnIDtxnId.- Returns:
- the txnId is aborted.
-
syncMaxReadPositionForNormalPublish
public void syncMaxReadPositionForNormalPublish(org.apache.bookkeeper.mledger.impl.PositionImpl position) Description copied from interface:TransactionBufferSync max read position for normal publish.- Specified by:
syncMaxReadPositionForNormalPublishin interfaceTransactionBuffer- Parameters:
position-PositionImplthe position to sync.
-
getMaxReadPosition
public org.apache.bookkeeper.mledger.impl.PositionImpl getMaxReadPosition()Description copied from interface:TransactionBufferGet the can read max position.- Specified by:
getMaxReadPositionin interfaceTransactionBuffer- Returns:
- the stable position.
-
getTransactionInBufferStats
public org.apache.pulsar.common.policies.data.TransactionInBufferStats getTransactionInBufferStats(org.apache.pulsar.client.api.transaction.TxnID txnID) Description copied from interface:TransactionBufferGet transaction in buffer stats.- Specified by:
getTransactionInBufferStatsin interfaceTransactionBuffer- Returns:
- the transaction in buffer stats.
-
getStats
public org.apache.pulsar.common.policies.data.TransactionBufferStats getStats(boolean lowWaterMarks) Description copied from interface:TransactionBufferGet transaction stats in buffer.- Specified by:
getStatsin interfaceTransactionBuffer- Returns:
- the transaction stats in buffer.
-
run
public void run(io.netty.util.Timeout timeout) - Specified by:
runin interfaceio.netty.util.TimerTask
-