public class TransactionImpl extends Object implements Transaction
Transaction.State| Constructor and Description |
|---|
TransactionImpl(TransactionManagerServiceImpl transactionManagerService,
NodeEngine nodeEngine,
TransactionOptions options,
String txOwnerUuid) |
TransactionImpl(TransactionManagerServiceImpl transactionManagerService,
NodeEngine nodeEngine,
TransactionOptions options,
String txOwnerUuid,
boolean originatedFromClient) |
| Modifier and Type | Method and Description |
|---|---|
void |
add(TransactionLogRecord record) |
void |
begin() |
void |
commit() |
protected CreateTxBackupLogOperation |
createCreateTxBackupLogOperation() |
protected PurgeTxBackupLogOperation |
createPurgeTxBackupLogOperation() |
protected ReplicateTxBackupLogOperation |
createReplicateTxBackupLogOperation() |
protected RollbackTxBackupLogOperation |
createRollbackTxBackupLogOperation() |
void |
ensureBackupLogsExist()
Some data-structures like the Transaction List rely on (empty) backup logs to be created before any change on the
data-structure is made.
|
TransactionLogRecord |
get(Object key) |
String |
getOwnerUuid() |
long |
getStartTime() |
Transaction.State |
getState() |
long |
getTimeoutMillis() |
protected TransactionLog |
getTransactionLog() |
String |
getTxnId() |
boolean |
isOriginatedFromClient() |
void |
prepare() |
void |
remove(Object key) |
boolean |
requiresPrepare()
Checks if this Transaction needs to be prepared.
|
void |
rollback() |
String |
toString() |
public TransactionImpl(TransactionManagerServiceImpl transactionManagerService, NodeEngine nodeEngine, TransactionOptions options, String txOwnerUuid)
public TransactionImpl(TransactionManagerServiceImpl transactionManagerService, NodeEngine nodeEngine, TransactionOptions options, String txOwnerUuid, boolean originatedFromClient)
public String getTxnId()
getTxnId in interface Transactionpublic long getStartTime()
public String getOwnerUuid()
getOwnerUuid in interface Transactionpublic boolean isOriginatedFromClient()
isOriginatedFromClient in interface Transactionpublic Transaction.State getState()
getState in interface Transactionpublic long getTimeoutMillis()
getTimeoutMillis in interface Transactionprotected TransactionLog getTransactionLog()
public void add(TransactionLogRecord record)
add in interface Transactionpublic TransactionLogRecord get(Object key)
get in interface Transactionpublic void remove(Object key)
remove in interface Transactionpublic void begin()
throws IllegalStateException
begin in interface TransactionIllegalStateExceptionpublic void prepare()
throws TransactionException
prepare in interface TransactionTransactionExceptionpublic boolean requiresPrepare()
Preparing a transaction costs time since the backup log potentially needs to be copied and each logrecord needs to prepare its content (e.g. by acquiring locks). This takes time.
If a transaction is local or if there is 1 or 0 items in the transaction log, instead of preparing, we are just going to try to commit. If the lock is still acquired, the write succeeds, and if the lock isn't acquired, the write fails; the same effect as a prepare would have.
prepare() is required.public void commit()
throws TransactionException,
IllegalStateException
commit in interface TransactionTransactionExceptionIllegalStateExceptionpublic void rollback()
throws IllegalStateException
rollback in interface TransactionIllegalStateExceptionpublic void ensureBackupLogsExist()
Not every data-structure, e.g. the Transactional Map, relies on it and in some cases can even skip it.
protected CreateTxBackupLogOperation createCreateTxBackupLogOperation()
protected ReplicateTxBackupLogOperation createReplicateTxBackupLogOperation()
protected RollbackTxBackupLogOperation createRollbackTxBackupLogOperation()
protected PurgeTxBackupLogOperation createPurgeTxBackupLogOperation()
Copyright © 2016 Hazelcast, Inc.. All Rights Reserved.