Package com.yahoo.transaction
Class NestedTransaction
- java.lang.Object
-
- com.yahoo.transaction.NestedTransaction
-
- All Implemented Interfaces:
java.lang.AutoCloseable
public final class NestedTransaction extends java.lang.Object implements java.lang.AutoCloseable
A transaction which may contain a list of transactions, typically to represent a distributed transaction over multiple systems.- Author:
- bratseth
-
-
Constructor Summary
Constructors Constructor Description NestedTransaction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NestedTransaction
add(Transaction transaction, java.lang.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(java.lang.Runnable runnable)
java.lang.String
toString()
java.util.List<Transaction>
transactions()
Returns the transactions nested in this, as they will be committed.
-
-
-
Method Detail
-
add
@SafeVarargs public final NestedTransaction add(Transaction transaction, java.lang.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
public java.util.List<Transaction> transactions()
Returns the transactions nested in this, as they will be committed.
-
commit
public void commit()
Perform a 2 phase commit
-
onCommitted
public void onCommitted(java.lang.Runnable runnable)
-
close
public void close()
Free up any temporary resources held by this- Specified by:
close
in interfacejava.lang.AutoCloseable
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-