Class TransactionBufferDisable
java.lang.Object
org.apache.pulsar.broker.transaction.buffer.impl.TransactionBufferDisable
- All Implemented Interfaces:
TransactionBuffer
Transaction buffer disable.
-
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.appendBufferToTxn(org.apache.pulsar.client.api.transaction.TxnID txnId, long sequenceId, io.netty.buffer.ByteBuf buffer) Append the buffer to the transaction buffer.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.longlongGet the can read max position.longGet the snapshot type.org.apache.pulsar.common.policies.data.TransactionBufferStatsgetStats(boolean lowWaterMarks) Get transaction stats in buffer.org.apache.pulsar.common.policies.data.TransactionBufferStatsgetStats(boolean lowWaterMarks, boolean segmentStats) 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, Position readPosition) Check if the txn is aborted.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.voidsyncMaxReadPositionForNormalPublish(Position position, boolean isMarkerMessage) Sync max read position for normal publish.
-
Constructor Details
-
TransactionBufferDisable
-
-
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
-
appendBufferToTxn
public CompletableFuture<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, Position readPosition) Description copied from interface:TransactionBufferCheck if the txn is aborted. TODO: To avoid broker oom, we will load the aborted txn from snapshot on demand. So we need the readPosition to check if the txn is loaded.- Specified by:
isTxnAbortedin interfaceTransactionBuffer- Parameters:
txnID-TxnIDtxnId.readPosition- the persistent position of the txn message.- Returns:
- whether the txn is aborted.
-
syncMaxReadPositionForNormalPublish
Description copied from interface:TransactionBufferSync max read position for normal publish.- Specified by:
syncMaxReadPositionForNormalPublishin interfaceTransactionBuffer- Parameters:
position-Positionthe position to sync.isMarkerMessage- whether the message is marker message.
-
getMaxReadPosition
Description copied from interface:TransactionBufferGet the can read max position.- Specified by:
getMaxReadPositionin interfaceTransactionBuffer- Returns:
- the stable position.
-
getSnapshotType
Description copied from interface:TransactionBufferGet the snapshot type. The snapshot type can be either "Single" or "Segment". In "Single" mode, a single snapshot log is used to record the transaction buffer stats. In "Segment" mode, a snapshot segment topic is used to record the stats, and a separate snapshot segment index topic is used to index these stats.- Specified by:
getSnapshotTypein interfaceTransactionBuffer- Returns:
- the snapshot type
-
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, boolean segmentStats) Description copied from interface:TransactionBufferGet transaction stats in buffer.- Specified by:
getStatsin interfaceTransactionBuffer- Returns:
- the transaction stats in buffer.
-
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.
-
checkIfTBRecoverCompletely
Description copied from interface:TransactionBufferWait TransactionBuffer recovers completely.- Specified by:
checkIfTBRecoverCompletelyin interfaceTransactionBuffer- Returns:
- a future that will be completed after the transaction buffer recover completely.
-
getOngoingTxnCount
public long getOngoingTxnCount()- Specified by:
getOngoingTxnCountin interfaceTransactionBuffer
-
getAbortedTxnCount
public long getAbortedTxnCount()- Specified by:
getAbortedTxnCountin interfaceTransactionBuffer
-
getCommittedTxnCount
public long getCommittedTxnCount()- Specified by:
getCommittedTxnCountin interfaceTransactionBuffer
-