VMware Tanzu GemFire Native C++ Reference 10.3.0
apache::geode::client::CacheTransactionManager Class Referenceabstract

An interface for objects who perform transaction management. More...

#include <CacheTransactionManager.hpp>

Public Member Functions

virtual void begin ()=0
 Creates a new transaction and associates it with the current thread. More...
 
virtual void commit ()=0
 Commit the transaction associated with the current thread. More...
 
virtual bool exists ()=0
 Reports the existence of a Transaction for this thread. More...
 
virtual bool exists (TransactionId &transactionId)=0
 Reports the existence of a transaction for the given transactionId. More...
 
virtual TransactionIdgetTransactionId ()=0
 Returns the transaction identifier for the current thread. More...
 
virtual bool isSuspended (TransactionId &transactionId)=0
 This method can be used to determine if a transaction with the given transaction identifier is currently suspended locally. More...
 
virtual void prepare ()=0
 Performs prepare during 2 phase commit completion, for the transaction associated with the current thread. More...
 
virtual void resume (TransactionId &transactionId)=0
 On the current thread, resumes a transaction that was previously suspended using suspend(). More...
 
virtual void rollback ()=0
 Roll back the transaction associated with the current thread. More...
 
virtual TransactionIdsuspend ()=0
 Suspends the transaction on the current thread. More...
 
virtual bool tryResume (TransactionId &transactionId)=0
 On the current thread, resumes a transaction that was previously suspended using suspend(). More...
 
virtual bool tryResume (TransactionId &transactionId, std::chrono::milliseconds waitTime)=0
 On the current thread, resumes a transaction that was previously suspended using suspend(), or waits for the specified timeout interval if the transaction has not been suspended. More...
 

Detailed Description

An interface for objects who perform transaction management.

Member Function Documentation

◆ begin()

virtual void apache::geode::client::CacheTransactionManager::begin ( )
pure virtual

Creates a new transaction and associates it with the current thread.

Exceptions
IllegalStateExceptionif the thread is already associated with a transaction
Since
3.6

◆ commit()

virtual void apache::geode::client::CacheTransactionManager::commit ( )
pure virtual

Commit the transaction associated with the current thread.

If the commit operation fails due to a conflict it will destroy the transaction state and throw a CommitConflictException. If the commit operation succeeds, it returns after the transaction state has been merged with committed state. When this method completes, the thread is no longer associated with a transaction.

Exceptions
IllegalStateExceptionif the thread is not associated with a transaction
CommitConflictExceptionif the commit operation fails due to a write conflict.
TransactionDataNodeHasDepartedExceptionif the node hosting the transaction data has departed. This is only relevant for transaction that involve PartitionedRegions.
TransactionDataNotColocatedExceptionif at commit time, the data involved in the transaction has moved away from the transaction hosting node. This can only happen if rebalancing/recovery happens during a transaction that involves a PartitionedRegion.
TransactionInDoubtExceptionwhen Geode cannot tell which nodes have applied the transaction and which have not. This only occurs if nodes fail mid-commit, and only then in very rare circumstances.

◆ exists() [1/2]

virtual bool apache::geode::client::CacheTransactionManager::exists ( )
pure virtual

Reports the existence of a Transaction for this thread.

Returns
true if a transaction exists, false otherwise
Since
3.6

◆ exists() [2/2]

virtual bool apache::geode::client::CacheTransactionManager::exists ( TransactionId transactionId)
pure virtual

Reports the existence of a transaction for the given transactionId.

This method can be used to determine if a transaction with the given transaction identifier is currently in progress locally.

Parameters
transactionIdthe given transaction identifier
Returns
true if the transaction is in progress, false otherwise.
Since
3.6.2
See also
#isSuspended(TransactionId)

◆ getTransactionId()

virtual TransactionId & apache::geode::client::CacheTransactionManager::getTransactionId ( )
pure virtual

Returns the transaction identifier for the current thread.

Returns
the transaction identifier or null if no transaction exists
Since
3.6.2

◆ isSuspended()

virtual bool apache::geode::client::CacheTransactionManager::isSuspended ( TransactionId transactionId)
pure virtual

This method can be used to determine if a transaction with the given transaction identifier is currently suspended locally.

This method does not check other members for transaction status.

Parameters
transactionIdtransaction to check if is suspended
Returns
true if the transaction is in suspended state, false otherwise
Since
3.6.2
See also
#exists(TransactionId)

◆ prepare()

virtual void apache::geode::client::CacheTransactionManager::prepare ( )
pure virtual

Performs prepare during 2 phase commit completion, for the transaction associated with the current thread.

Locks of the entries modified in the current transaction on the server side. If the prepare operation fails due to a conflict it will destroy the transaction state and throw a CommitConflictException. If the prepare operation succeeds, transaction state is set to prepared state. When this method completes, the thread is still associated with a transaction, and is waiting on commit or rollback operation.

Exceptions
IllegalStateExceptionif the thread is not associated with a transaction
CommitConflictExceptionif the commit operation fails due to a write conflict.
TransactionDataNodeHasDepartedExceptionif the node hosting the transaction data has departed. This is only relevant for transaction that involve PartitionedRegions.
TransactionDataNotColocatedExceptionif at commit time, the data involved in the transaction has moved away from the transaction hosting node. This can only happen if rebalancing/recovery happens during a transaction that involves a PartitionedRegion.
TransactionInDoubtExceptionwhen Geode cannot tell which nodes have applied the transaction and which have not. This only occurs if nodes fail mid-commit, and only then in very rare circumstances.

◆ resume()

virtual void apache::geode::client::CacheTransactionManager::resume ( TransactionId transactionId)
pure virtual

On the current thread, resumes a transaction that was previously suspended using suspend().

Parameters
transactionIdthe transaction to resume
Exceptions
IllegalStateExceptionif the thread is associated with a transaction or if isSuspended(TransactionId) would return false for the given transactionId
Since
3.6.2

◆ rollback()

virtual void apache::geode::client::CacheTransactionManager::rollback ( )
pure virtual

Roll back the transaction associated with the current thread.

When this method completes, the thread is no longer associated with a transaction and the transaction context is destroyed.

Since
3.6
Exceptions
IllegalStateExceptionif the thread is not associated with a transaction

◆ suspend()

virtual TransactionId & apache::geode::client::CacheTransactionManager::suspend ( )
pure virtual

Suspends the transaction on the current thread.

All subsequent operations performed by this thread will be non-transactional. The suspended transaction can be resumed by calling resume(TransactionId)

Returns
the transaction identifier of the suspended transaction or null if the thread was not associated with a transaction
Since
3.6.2

◆ tryResume() [1/2]

virtual bool apache::geode::client::CacheTransactionManager::tryResume ( TransactionId transactionId)
pure virtual

On the current thread, resumes a transaction that was previously suspended using suspend().

This method is equivalent to

if (isSuspended(txId)) {
  resume(txId);
}

except that this action is performed atomically

Parameters
transactionIdthe transaction to resume
Returns
true if the transaction was resumed, false otherwise
Since
3.6.2

◆ tryResume() [2/2]

virtual bool apache::geode::client::CacheTransactionManager::tryResume ( TransactionId transactionId,
std::chrono::milliseconds  waitTime 
)
pure virtual

On the current thread, resumes a transaction that was previously suspended using suspend(), or waits for the specified timeout interval if the transaction has not been suspended.

This method will return if:

  • Another thread suspends the transaction
  • Another thread calls commit/rollback on the transaction
  • This thread has waited for the specified timeout

This method returns immediately if exists(TransactionId) returns false.

Parameters
transactionIdthe transaction to resume
waitTimethe maximum time to wait
Returns
true if the transaction was resumed, false otherwise
Since
3.6.2
See also
#tryResume(TransactionId)

Apache Geode C++ Cache API Documentation