Class ModificationTally

java.lang.Object
org.tentackle.dbms.ModificationTally

public class ModificationTally extends Object
Counter to track modifications for a class/table.
The ModificationTracker maintains a list of ModificationTally-objects, one for each tracked name.

ModificationTallies are only used in local sessions, never remote.

Author:
harald
  • Field Details

    • SESSION_COUNT_PENDING

      public static final Object SESSION_COUNT_PENDING
      Transaction property to rollback pending counts.
      Set to Boolean.TRUE when the session performed a countPending within transaction and that pending count must be adjusted when the transaction is rolled back.
  • Constructor Details

    • ModificationTally

      public ModificationTally(DbModificationTracker tracker, String trackedName)
      Creates a modification counter for a given tracked name.
      Parameters:
      tracker - the modification tracker
      trackedName - the tracked name
  • Method Details

    • getTrackedName

      public String getTrackedName()
      Gets the tracked name.
      Returns:
      the symbolic name of the tracked entity
    • getDbModification

      public DbModification getDbModification()
      Gets the modification PO.
      Returns:
      the modification PO
    • getId

      public long getId()
      Gets the ID of the counter.
      Returns:
      the unique id
    • countPending

      public void countPending(Session session)
      Adds a pending modification count.
      Parameters:
      session - the session persisting the modification, null if thread-local session
    • addDeletion

      public void addDeletion(Session session, IdSerialTuple tuple)
      Adds a deletion.
      A deletion is represented by an IdSerialTuple while the serial is the tableserial indicating the modification count of the whole table.
      Deletions are
      Parameters:
      session - the session associated with the deletion; it determines the transaction context
      tuple - the ID and negative(!) tableserial that represents the deletion to be added
    • rollbackPending

      public void rollbackPending(Session session, long txNumber)
      Rolls back the pending count and deletions for a given session.
      Avoids invalidation of the associated caches when a transaction is rolled back that caused all the modifications.
      Parameters:
      session - the session
      txNumber - the transaction number
    • getPendingCount

      public long getPendingCount()
      Gets the pending count.
      Returns:
      the pending count, 0 for none
    • setLastSerial

      public void setLastSerial(long lastSerial)
      Sets the last serial.
      Parameters:
      lastSerial - the serial
    • getLatestSerial

      public long getLatestSerial()
      Gets the latest serial updated by this counter.
      Returns:
      the latest serial from the last update plus pending count
    • performPendingCount

      public void performPendingCount()
      Performs the physical pending count if pending count > 0.
      This is only done if no transactions related to the data monitored by this ModificationTally are currently running. This also implies that all modifications have been committed to the database.
    • addToModificationTable

      public void addToModificationTable()
      Adds this counter to the modification table.
    • getModificationCount

      public long getModificationCount()
      Get the current modification count by tablename.
      Returns:
      the modification count