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 Transaction
public long getStartTime()
public String getOwnerUuid()
getOwnerUuid
in interface Transaction
public boolean isOriginatedFromClient()
isOriginatedFromClient
in interface Transaction
public Transaction.State getState()
getState
in interface Transaction
public long getTimeoutMillis()
getTimeoutMillis
in interface Transaction
protected TransactionLog getTransactionLog()
public void add(TransactionLogRecord record)
add
in interface Transaction
public TransactionLogRecord get(Object key)
get
in interface Transaction
public void remove(Object key)
remove
in interface Transaction
public void begin() throws IllegalStateException
begin
in interface Transaction
IllegalStateException
public void prepare() throws TransactionException
prepare
in interface Transaction
TransactionException
public 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 Transaction
TransactionException
IllegalStateException
public void rollback() throws IllegalStateException
rollback
in interface Transaction
IllegalStateException
public 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.