VMware GemFire Native C++ Reference  9.1
apache::geode::client::InternalCacheTransactionManager2PC Class Referenceabstract

Extension of the apache::geode::client::CacheTransactionManager that enables client application to use Geode transaction as part of the global XA transaction. More...

Inherits apache::geode::client::CacheTransactionManager.

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 (TransactionIdPtr transactionId)=0
 Reports the existence of a transaction for the given transactionId. More...
 
virtual bool exists ()=0
 Reports the existence of a Transaction for this thread. More...
 
virtual TransactionIdPtr getTransactionId ()=0
 Returns the transaction identifier for the current thread. More...
 
virtual bool isSuspended (TransactionIdPtr 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. More...
 
void preserveSB () const
 Atomically increment reference count. More...
 
int32_t refCount ()
 
void releaseSB () const
 Atomically decrement reference count, the SharedBase object is automatically deleted when its reference count goes to zero. More...
 
virtual void resume (TransactionIdPtr 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 TransactionIdPtr suspend ()=0
 Suspends the transaction on the current thread. More...
 
virtual bool tryResume (TransactionIdPtr transactionId)=0
 On the current thread, resumes a transaction that was previously suspended using suspend(). More...
 
virtual bool tryResume (TransactionIdPtr transactionId, int32_t waitTimeInMilliSec)=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

Extension of the apache::geode::client::CacheTransactionManager that enables client application to use Geode transaction as part of the global XA transaction.

The prepare method of this class corresponds to the prepare phases of the 2 phase commit protocol driven by a global transaction manager.

The implementation of the apache::geode::client::CacheTransactionManager commit() and rollback() methods must be 2 phase commit process aware.

Methods of this class are expected to be called by a custom XA Resource Manager that is wrapping and adapting Geode client to XA specification requirements.

Since
8.3

Member Function Documentation

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

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

Exceptions
IllegalStateExceptionif the thread is already associated with a transaction
Since
3.6
virtual void apache::geode::client::CacheTransactionManager::commit ( )
pure virtualinherited

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.
virtual bool apache::geode::client::CacheTransactionManager::exists ( TransactionIdPtr  transactionId)
pure virtualinherited

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)
virtual bool apache::geode::client::CacheTransactionManager::exists ( )
pure virtualinherited

Reports the existence of a Transaction for this thread.

Returns
true if a transaction exists, false otherwise
Since
3.6
virtual TransactionIdPtr apache::geode::client::CacheTransactionManager::getTransactionId ( )
pure virtualinherited

Returns the transaction identifier for the current thread.

Returns
the transaction identifier or null if no transaction exists
Since
3.6.2
virtual bool apache::geode::client::CacheTransactionManager::isSuspended ( TransactionIdPtr  transactionId)
pure virtualinherited

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
transactionId
Returns
true if the transaction is in suspended state, false otherwise
Since
3.6.2
See also
#exists(TransactionId)
virtual void apache::geode::client::InternalCacheTransactionManager2PC::prepare ( )
pure virtual

Performs prepare during 2 phase commit completion.

Locks of the entries modified in the current transaction on the server side.

Calls to subsequent commit() or rollback() methods overridden by this class are expected to succeed after prepare() has returned successfully. Geode commits internal transaction irreversibly on commit() call.

void apache::geode::client::SharedBase::preserveSB ( ) const
inherited

Atomically increment reference count.

int32_t apache::geode::client::SharedBase::refCount ( )
inlineinherited
Returns
the reference count
void apache::geode::client::SharedBase::releaseSB ( ) const
inherited

Atomically decrement reference count, the SharedBase object is automatically deleted when its reference count goes to zero.

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

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
virtual void apache::geode::client::CacheTransactionManager::rollback ( )
pure virtualinherited

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
virtual TransactionIdPtr apache::geode::client::CacheTransactionManager::suspend ( )
pure virtualinherited

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
virtual bool apache::geode::client::CacheTransactionManager::tryResume ( TransactionIdPtr  transactionId)
pure virtualinherited

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
virtual bool apache::geode::client::CacheTransactionManager::tryResume ( TransactionIdPtr  transactionId,
int32_t  waitTimeInMilliSec 
)
pure virtualinherited

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
waitTimeInMilliSecthe maximum milliseconds to wait
Returns
true if the transaction was resumed, false otherwise
Since
3.6.2
See also
#tryResume(TransactionId)

Pivotal GemFire C++ Cache API Documentation