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
invalid reference
#getResourceApi(String[])
. 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
Author:
raven
  • Method Details

    • getTxnMgr

      TxnMgr getTxnMgr()
    • getId

      String getId()
      Get the id of this transaction
    • getResourceApi

      TxnResourceApi getResourceApi(org.aksw.commons.path.core.Path<String> resRelPath)
      Get access to a resource as seen from this txn
    • listVisibleFiles

      Stream<TxnResourceApi> listVisibleFiles(org.aksw.commons.path.core.Path<String> prefix)
    • streamAccessedResourcePaths

      Stream<org.aksw.commons.path.core.Path<String>> streamAccessedResourcePaths() throws IOException
      Throws:
      IOException
    • isStale

      boolean isStale() throws IOException
      Whether the transaction has become stale
      Throws:
      IOException
    • claim

      boolean claim() throws IOException
      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

      void addCommit() throws IOException
      Throws:
      IOException
    • addFinalize

      void addFinalize() throws IOException
      Throws:
      IOException
    • addRollback

      void addRollback() throws IOException
      Throws:
      IOException
    • isCommit

      boolean isCommit() throws IOException
      Throws:
      IOException
    • isRollback

      boolean isRollback() throws IOException
      Throws:
      IOException
    • isFinalize

      boolean isFinalize() throws IOException
      Throws:
      IOException
    • cleanUpTxn

      void cleanUpTxn() throws IOException
      Throws:
      IOException
    • promote

      void promote()
      Promote a read transaction to write.
    • getCreationDate

      Instant getCreationDate()
    • updateHeartbeat

      void updateHeartbeat() throws IOException
      Throws:
      IOException
    • getMostRecentHeartbeat

      Instant getMostRecentHeartbeat() throws IOException
      Throws:
      IOException
    • getDurationToNextHeartbeat

      TemporalAmount getDurationToNextHeartbeat() throws IOException
      Throws:
      IOException
    • setActivityDate

      void setActivityDate(Instant instant) throws IOException
      Update the transaction's most recent activity timestamp to given timestamp; Used to prevent other processes from considering the transaction stale.
      Throws:
      IOException
    • getActivityDate

      Instant getActivityDate() throws IOException
      Throws:
      IOException
    • updateActivityDate

      default Instant updateActivityDate() throws IOException
      Update the transaction's most recent activity timestamp to the current time; Used to prevent other processes from considering the transaction stale.
      Throws:
      IOException