Class ModificationTally
java.lang.Object
org.tentackle.dbms.ModificationTally
Counter to track modifications for a class/table.
The ModificationTracker maintains a list of ModificationTally-objects, one for each tracked name.
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final ObjectTransaction property to rollback pending counts.
Set toBoolean.TRUEwhen the session performed a countPending within transaction and that pending count must be adjusted when the transaction is rolled back. -
Constructor Summary
ConstructorsConstructorDescriptionModificationTally(DbModificationTracker tracker, String trackedName) Creates a modification counter for a given tracked name. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDeletion(Session session, IdSerialTuple tuple) Adds a deletion.
A deletion is represented by anIdSerialTuplewhile the serial is the tableserial indicating the modification count of the whole table.
Deletions arevoidAdds this counter to the modification table.voidcountPending(Session session) Adds a pending modification count.Gets the modification PO.longgetId()Gets the ID of the counter.longGets the latest serial updated by this counter.longGet the current modification count by tablename.longGets the pending count.Gets the tracked name.voidPerforms 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.voidrollbackPending(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.voidsetLastSerial(long lastSerial) Sets the last serial.
-
Field Details
-
SESSION_COUNT_PENDING
Transaction property to rollback pending counts.
Set toBoolean.TRUEwhen the session performed a countPending within transaction and that pending count must be adjusted when the transaction is rolled back.
-
-
Constructor Details
-
ModificationTally
Creates a modification counter for a given tracked name.- Parameters:
tracker- the modification trackertrackedName- the tracked name
-
-
Method Details
-
getTrackedName
Gets the tracked name.- Returns:
- the symbolic name of the tracked entity
-
getDbModification
-
getId
public long getId()Gets the ID of the counter.- Returns:
- the unique id
-
countPending
Adds a pending modification count.- Parameters:
session- the session persisting the modification, null if thread-local session
-
addDeletion
Adds a deletion.
A deletion is represented by anIdSerialTuplewhile 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 contexttuple- the ID and negative(!) tableserial that represents the deletion to be added
-
rollbackPending
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 sessiontxNumber- 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
-