Interface Txn
- All Known Implementing Classes:
TxnReadUncommitted, TxnSerializable
public interface Txn
A transaction can hold locks to several resources.
The resources (potentially) locked by a transaction can be accessed using streamAccessedResourcePaths().
References to resources can be acquired via
.
TODO Consider replace of String[] with Array; the former is a pain to use with e.g. guava cache
TODO Consider replace of Stream with Flowable; the former does not have proper resource management
invalid reference
#getResourceApi(String[])
- Author:
- raven
-
Method Summary
Modifier and TypeMethodDescriptionvoidvoidvoidbooleanclaim()Instruct this TxnMgr to try to claim (i.e.voidgetId()Get the id of this transactiongetResourceApi(Path<String> resRelPath) Get access to a resource as seen from this txnbooleanisCommit()booleanbooleanbooleanisStale()Whether the transaction has become stalebooleanisWrite()listVisibleFiles(Path<String> prefix) voidpromote()Promote a read transaction to write.voidsetActivityDate(Instant instant) Update the transaction's most recent activity timestamp to given timestamp; Used to prevent other processes from considering the transaction stale.default InstantUpdate the transaction's most recent activity timestamp to the current time; Used to prevent other processes from considering the transaction stale.void
-
Method Details
-
getTxnMgr
TxnMgr getTxnMgr() -
getId
String getId()Get the id of this transaction -
getResourceApi
Get access to a resource as seen from this txn -
listVisibleFiles
-
streamAccessedResourcePaths
- Throws:
IOException
-
isStale
-
claim
Instruct this TxnMgr to try to claim (i.e. take ownership) of this txn. Should only be used on stale transactions. A claim fails - indicated by a return value of false - if the txn's heartbeat timeout has not been reached. This condition also occurs if another thread won the competition for claiming a txn.- Throws:
IOException
-
isWrite
boolean isWrite() -
addCommit
- Throws:
IOException
-
addFinalize
- Throws:
IOException
-
addRollback
- Throws:
IOException
-
isCommit
- Throws:
IOException
-
isRollback
- Throws:
IOException
-
isFinalize
- Throws:
IOException
-
cleanUpTxn
- Throws:
IOException
-
promote
void promote()Promote a read transaction to write. -
getCreationDate
Instant getCreationDate() -
updateHeartbeat
- Throws:
IOException
-
getMostRecentHeartbeat
- Throws:
IOException
-
getDurationToNextHeartbeat
- Throws:
IOException
-
setActivityDate
Update the transaction's most recent activity timestamp to given timestamp; Used to prevent other processes from considering the transaction stale.- Throws:
IOException
-
getActivityDate
- Throws:
IOException
-
updateActivityDate
Update the transaction's most recent activity timestamp to the current time; Used to prevent other processes from considering the transaction stale.- Throws:
IOException
-