|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface Transaction
All changes on transaction objects must be done through a Transaction. The transaction make sure that changes on java objects are:
registerLifecycleListener(TransactionLifecycleListener).
When the Transaction is reset, the lifecycle tasks are dropped. So the lifecycle task need to be registered again.
Condition functionality already provided. For more information see the
registerRetryLatch(Latch).
Because a custom Latch implementation can be provided, you have a lot of control on the blocking behavior.
But atm it is not possible to get fairness on when the Latch is opened. Policies to customize starvation,
lifelocking, deadlocking will be added in the future.
| Method Summary | |
|---|---|
void |
abort()
Aborts this Transaction. |
void |
commit()
Commits this Transaction. |
TransactionConfig |
getConfig()
Gets the TransactionConfig that is used by this Transaction. |
long |
getReadVersion()
Returns the clock version of the stm when this Transaction started. |
TransactionStatus |
getStatus()
Returns the status of this Transaction. |
void |
prepare()
Prepares this transaction to be committed. |
void |
registerLifecycleListener(TransactionLifecycleListener listener)
Registers a TransactionLifecycleListener on this Transaction. |
void |
registerRetryLatch(Latch latch)
Registers the retry Latch on this Transaction. |
void |
restart()
Restarts this Transaction. |
| Method Detail |
|---|
TransactionConfig getConfig()
TransactionConfig that is used by this Transaction.
long getReadVersion()
TransactionStatus getStatus()
void commit()
CommitFailureException - if the commit failed. Check the class hierarchy of the CommitFailureException for more information.
DeadTransactionException - if this transaction already is aborted.void prepare()
CommitFailureException - if the transaction can't be prepared.
DeadTransactionException - if the transaction already is committed or aborted.void abort()
DeadTransactionException - if this transaction already is committedvoid restart()
void registerRetryLatch(Latch latch)
Future because it also pops closed once some event occurs (an interesting write
in the case of a Latch).
latch - the Latch to register.
java.lang.NullPointerException - if latch is null.
NoRetryPossibleException - if the retry can't make progress, e.g. because the transaction has not
loaded any object.
DeadTransactionException - if this transaction already is committed or aborted.
java.lang.UnsupportedOperationException - if the Transaction doesn't support this operation (for example because it
doesn't do readtracking).void registerLifecycleListener(TransactionLifecycleListener listener)
TransactionStatus of that transaction. Without this functionality it would not
be possible to execute compensating or deferred action once a transaction aborts or commits.
If the execution of one of the listeners fails, the others won't be executed. If one of the listeners fails
before the commit/abort, the transaction is aborted (no matter what).
The listeners are executed in the order they are registered.
If the same listener is added multiple times, it will be notified multiple times.
The listener will be executed on the thread that starts the commit/abort.
If the listener is added after the Transaction is prepared, the preCommit event will not be called on the
listener.
If the listener accesses the stm after the transaction has been committed or aborted, it could see changes
made after that transaction. So all assumptions about state are possibly wrong so one needs to take care of
re-validating state if needed.
A good use case of this feature is starting up threads. If you need to start threads, you don't want to start
them immediately because eventually the transaction could be aborted.
listener - the TransactionLifecycleListener to registerLifecycleListener
java.lang.NullPointerException - if listener is null.
DeadTransactionException - if transaction already is aborted or committed.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||