public final class DBDeletionManager
extends java.lang.Object
The DBDeletionManager class is used to handle deletion locking
in the Ganymede DBStore.
This class was designed to remove the necessity of having all
Invid link relationships be
symmetrical. Previously, establishing a one-way link from object
'A' to object 'B' involved editing both A and B, and placing a
reverse link in B that pointed to A.
This worked, but it meant that it was impossible for multiple users to be concurrently editing objects to establish or remove links to object B. This was especially troublesome for Owner Group objects, as it meant that only one user at a time could be creating or deleting objects in a given Owner Group.
With the introduction of the DBDeletionManager, we eliminate the need to be constantly editing targets of asymmetric links.
Instead, when an object 'A' is checked out for editing that contains asymmetric link to other objects, those objects are locked (using the DBDeletionManager addSessionInvids() method) so that they cannot be deleted. The session editing object A can remove the links to any of the linked objects if it wants, but if it doesn't, it can be confident that the targeted objects will still be there at the time the transaction commits.
Similarly, if object 'A' does not initially contain a link to 'B', the act of creating an asymmetric link from A to B will cause object B to be deletion locked at that time. See the source of the arlut.csd.ganymede.server.InvidDBField bind() method for details.
In either of the above scenarios, deletion locks established by
a given DBSession are released
when the session's transactions are committed or aborted in the
session's DBEditSet.
| Modifier and Type | Field and Description |
|---|---|
private static java.util.Map<Invid,java.util.Set<DBSession>> |
invids
Invids will appear as keys in this Map when the DBObjects
corresponding to those Invids have been delete locked by
DBSessions in the server.
|
private static java.util.Map<DBSession,java.util.Set<Invid>> |
sessions
DBSession objects will appear as keys in this Map when those
sessions have locked Invids in the database against deletion.
|
| Constructor and Description |
|---|
DBDeletionManager() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
addSessionInvids(DBSession session,
java.util.Set<Invid> invidSet)
This method deletion-locks a vector of invids, returning false
without changes if the deletion-locks could not all be performed.
|
static boolean |
deleteLockObject(DBObject obj,
DBSession session)
This method is used by the Invid binding logic to attempt to
block an object from being deleted.
|
static java.util.Set<Invid> |
getSessionCheckpoint(DBSession session)
This method returns a snapshot of what Invids are locked by a
given session at the time the method is called.
|
static void |
releaseSession(DBSession session)
When a DBSession releases or commits a transaction, this method
is called to clear any deletion locks asserted by it.
|
static void |
revertSessionCheckpoint(DBSession session,
java.util.Set<Invid> invidSet)
This method rolls back the invids delete-locked by a session to
an earlier state.
|
static boolean |
setDeleteStatus(DBEditObject obj,
DBSession session)
This method is used by the DBSession deleteDBObject() method to
safely convert a DBEditObject's status to a deletion state.
|
private static java.util.Map<DBSession,java.util.Set<Invid>> sessions
DBSession objects will appear as keys in this Map when those sessions have locked Invids in the database against deletion.
The Set of Invids mapped from the DBSession is the set of Invids that that DBSession has locked.
public static boolean deleteLockObject(DBObject obj, DBSession session)
public static boolean setDeleteStatus(DBEditObject obj, DBSession session)
public static void releaseSession(DBSession session)
public static boolean addSessionInvids(DBSession session, java.util.Set<Invid> invidSet)
public static java.util.Set<Invid> getSessionCheckpoint(DBSession session)
public static void revertSessionCheckpoint(DBSession session, java.util.Set<Invid> invidSet)