| Apache Ignite C++

Public Member Functions | List of all members
ignite::transactions::Transaction Class Reference

Ignite cache transaction. More...

`#include <transaction.h>`

## Public Member Functions
| Transaction (common::concurrent::SharedPointer< impl::transactions::TransactionImpl > impl)
| Constructor. More...
| Transaction (const Transaction &other)
| Copy constructor. More...
Transaction & | operator= (const Transaction &other)
| Assignment operator. More...
| ~Transaction ()
| Destructor.
void | Commit ()
| Commit the transaction. More...
void | Commit (IgniteError &err)
| Commit the transaction. More...
void | Rollback ()
| Rollback the transaction. More...
void | Rollback (IgniteError &err)
| Rollback the transaction. More...
void | Close ()
| Close the transaction. More...
void | Close (IgniteError &err)
| Close the transaction. More...
void | SetRollbackOnly ()
| Make transaction into rollback-only. More...
void | SetRollbackOnly (IgniteError &err)
| Make transaction into rollback-only. More...
bool | IsRollbackOnly ()
| Check if the transaction is rollback-only. More...
bool | IsRollbackOnly (IgniteError &err)
| Check if the transaction is rollback-only. More...
TransactionState::Type | GetState ()
| Get current state. More...
TransactionState::Type | GetState (IgniteError &err)
| Get current state. More...
TransactionConcurrency::Type | GetConcurrency () const
| Get concurrency. More...
TransactionIsolation::Type | GetIsolation () const
| Get isolation. More...
int64_t | GetTimeout () const
| Get timeout. More...
bool | IsValid () const
| Check if the instance is valid and can be used. More...

## Detailed Description

Ignite cache transaction.

Cache transactions have a default 2PC (two-phase-commit) behavior.

See also
  TransactionConcurrency and TransactionIsolation for details on the supported isolation levels and concurrency models.

This class is implemented as a reference to an implementation so copying of this class instance will only create another reference to the same underlying object. Underlying object will be released automatically once all the instances are destructed.

## Constructor & Destructor Documentation

## ◆ Transaction() [1/2]

ignite::transactions::Transaction::Transaction | ( | common::concurrent::SharedPointer< impl::transactions::TransactionImpl > | impl | ) |

Constructor.

Internal method. Should not be used by user.

Parameters

  impl | Implementation.

## ◆ Transaction() [2/2]

ignite::transactions::Transaction::Transaction | ( | const Transaction & | other | ) |

Copy constructor.

Parameters

  other | Other instance.

## Member Function Documentation

## ◆ Close() [1/2]

void ignite::transactions::Transaction::Close | ( |  | ) |

Close the transaction.

This method should only be used on the valid instance.

Exceptions

  IgniteError | class instance in case of failure.

## ◆ Close() [2/2]

void ignite::transactions::Transaction::Close | ( | IgniteError & | err | ) |

Close the transaction.

Properly sets error param in case of failure.

This method should only be used on the valid instance.

Parameters

  err | Error.

## ◆ Commit() [1/2]

void ignite::transactions::Transaction::Commit | ( |  | ) |

Commit the transaction.

This method should only be used on the valid instance.

Exceptions

  IgniteError | class instance in case of failure.

## ◆ Commit() [2/2]

void ignite::transactions::Transaction::Commit | ( | IgniteError & | err | ) |

Commit the transaction.

Properly sets error param in case of failure.

This method should only be used on the valid instance.

Parameters

  err | Error.

## ◆ GetConcurrency()

TransactionConcurrency::Type ignite::transactions::Transaction::GetConcurrency | ( |  | ) | const
| inline

Get concurrency.

This method should only be used on the valid instance.

Returns
  Concurrency.

## ◆ GetIsolation()

TransactionIsolation::Type ignite::transactions::Transaction::GetIsolation | ( |  | ) | const
| inline

Get isolation.

This method should only be used on the valid instance.

Returns
  Isolation.

## ◆ GetState() [1/2]

TransactionState::Type ignite::transactions::Transaction::GetState | ( |  | ) |

Get current state.

This method should only be used on the valid instance.

Returns
  Transaction state.

Exceptions

  IgniteError | class instance in case of failure.

## ◆ GetState() [2/2]

TransactionState::Type ignite::transactions::Transaction::GetState | ( | IgniteError & | err | ) |

Get current state.

Properly sets error param in case of failure.

This method should only be used on the valid instance.

Parameters

  err | Error.

Returns
  Transaction state.

## ◆ GetTimeout()

int64_t ignite::transactions::Transaction::GetTimeout | ( |  | ) | const
| inline

Get timeout.

This method should only be used on the valid instance.

Returns
  Timeout in milliseconds. Zero if timeout is infinite.

## ◆ IsRollbackOnly() [1/2]

bool ignite::transactions::Transaction::IsRollbackOnly | ( |  | ) |

Check if the transaction is rollback-only.

After transaction have been marked as rollback-only it may only be rolled back. Error occurs if such transaction is being commited.

Returns
  True if the transaction is rollback-only.

Exceptions

  IgniteError | class instance in case of failure.

## ◆ IsRollbackOnly() [2/2]

bool ignite::transactions::Transaction::IsRollbackOnly | ( | IgniteError & | err | ) |

Check if the transaction is rollback-only.

After transaction have been marked as rollback-only it may only be rolled back. Error occurs if such transaction is being commited.

Properly sets error param in case of failure.

This method should only be used on the valid instance.

Parameters

  err | Error.

Returns
  True if the transaction is rollback-only.

## ◆ IsValid()

bool ignite::transactions::Transaction::IsValid | ( |  | ) | const
| inline

Check if the instance is valid and can be used.

Invalid instance can be returned if some of the previous operations have resulted in a failure. For example invalid instance can be returned by not-throwing version of method in case of error. Invalid instances also often can be created using default constructor.

Returns
  True if the instance is valid and can be used.

## ◆ operator=()

Transaction & ignite::transactions::Transaction::operator= | ( | const Transaction & | other | ) |

Assignment operator.

Parameters

  other | Other instance.

Returns
  This.

## ◆ Rollback() [1/2]

void ignite::transactions::Transaction::Rollback | ( |  | ) |

Rollback the transaction.

This method should only be used on the valid instance.

Exceptions

  IgniteError | class instance in case of failure.

## ◆ Rollback() [2/2]

void ignite::transactions::Transaction::Rollback | ( | IgniteError & | err | ) |

Rollback the transaction.

Properly sets error param in case of failure.

This method should only be used on the valid instance.

Parameters

  err | Error.

## ◆ SetRollbackOnly() [1/2]

void ignite::transactions::Transaction::SetRollbackOnly | ( |  | ) |

Make transaction into rollback-only.

After transaction have been marked as rollback-only it may only be rolled back. Error occurs if such transaction is being commited.

This method should only be used on the valid instance.

Exceptions

  IgniteError | class instance in case of failure.

## ◆ SetRollbackOnly() [2/2]

void ignite::transactions::Transaction::SetRollbackOnly | ( | IgniteError & | err | ) |

Make transaction into rollback-only.

After transaction have been marked as rollback-only it may only be rolled back. Error occurs if such transaction is being commited.

Properly sets error param in case of failure.

This method should only be used on the valid instance.

Parameters

  err | Error.

The documentation for this class was generated from the following files:

- core/include/ignite/transactions/transaction.h
- transaction.cpp