Package com.yahoo.transaction
Class NestedTransaction
java.lang.Object
com.yahoo.transaction.NestedTransaction
- All Implemented Interfaces:
AutoCloseable
A transaction which may contain a list of transactions, typically to represent a distributed transaction
over multiple systems.
- Author:
- bratseth
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionfinal NestedTransaction
add
(Transaction transaction, Class<? extends Transaction>... before) Adds a transaction to this.void
close()
Free up any temporary resources held by thisvoid
commit()
Perform a 2 phase commitvoid
onCommitted
(Runnable runnable) toString()
Returns the transactions nested in this, as they will be committed.
-
Constructor Details
-
NestedTransaction
public NestedTransaction()
-
-
Method Details
-
add
@SafeVarargs public final NestedTransaction add(Transaction transaction, Class<? extends Transaction>... before) Adds a transaction to this.- Parameters:
transaction
- the transaction to addbefore
- transaction classes which should commit after this, if present. It is beneficial to order transaction types from the least to most reliable. If conflicting ordering constraints are given this will not be detected at add time but the transaction will fail to commit- Returns:
- this for convenience
-
transactions
Returns the transactions nested in this, as they will be committed. -
commit
public void commit()Perform a 2 phase commit -
onCommitted
-
close
public void close()Free up any temporary resources held by this- Specified by:
close
in interfaceAutoCloseable
-
toString
-