Transaction¶
-
TWO_PHASE
= 1¶ The two phase commit is separated in 2 parts. First it tries to execute the prepare; if there are any conflicts, the prepare will fail. Once the prepare has succeeded, the commit (writing the changes) can be executed.
Hazelcast also provides three phase transaction by automatically copying the backlog to another member so that in case of failure during a commit, another member can continue the commit from backup.
-
ONE_PHASE
= 2¶ The one phase transaction executes a transaction using a single step at the end; committing the changes. There is no prepare of the transactions, so conflicts are not detected. If there is a conflict, then when the transaction commits the changes, some of the changes are written and others are not; leaving the system in a potentially permanent inconsistent state.
-
class
TransactionManager
(client)¶ Bases:
object
Manages the execution of client transactions and provides Transaction objects.
-
logger
= <Logger HazelcastClient.TransactionManager (WARNING)>¶
-
new_transaction
(timeout, durability, transaction_type)¶ Creates a Transaction object with given timeout, durability and transaction type.
- Parameters
timeout – (long), the timeout in seconds determines the maximum lifespan of a transaction.
durability – (int), the durability is the number of machines that can take over if a member fails during a transaction commit or rollback
transaction_type – (Transaction Type), the transaction type which can be
TWO_PHASE
orONE_PHASE
- Returns
(
Transaction
), new created Transaction.
-
-
class
Transaction
(client, connection, timeout, durability, transaction_type)¶ Bases:
object
Provides transactional operations: beginning/committing transactions, but also retrieving transactional data-structures like the TransactionalMap.
-
state
= 'not_started'¶
-
id
= None¶
-
start_time
= None¶
-
thread_id
= None¶
-
logger
= <Logger HazelcastClient.Transaction (WARNING)>¶
-
begin
()¶ Begins this transaction.
-
commit
()¶ Commits this transaction.
-
rollback
()¶ Rollback of this current transaction.
-
get_list
(name)¶ Returns the transactional list instance with the specified name.
- Parameters
name – (str), the specified name.
- Returns
(
TransactionalList
), the instance of Transactional List with the specified name.
-
get_map
(name)¶ Returns the transactional map instance with the specified name.
- Parameters
name – (str), the specified name.
- Returns
(
TransactionalMap
), the instance of Transactional Map with the specified name.
-
get_multi_map
(name)¶ Returns the transactional multimap instance with the specified name.
- Parameters
name – (str), the specified name.
- Returns
(
TransactionalMultiMap
), the instance of Transactional MultiMap with the specified name.
-
get_queue
(name)¶ Returns the transactional queue instance with the specified name.
- Parameters
name – (str), the specified name.
- Returns
(
TransactionalQueue
), the instance of Transactional Queue with the specified name.
-
get_set
(name)¶ Returns the transactional set instance with the specified name.
- Parameters
name – (str), the specified name.
- Returns
(
TransactionalSet
), the instance of Transactional Set with the specified name.
-