Class LockSpace
java.lang.Object
org.apache.derby.impl.services.locks.LockSpace
- All Implemented Interfaces:
CompatibilitySpace
A LockSpace represents the complete set of locks held within
a single compatibility space, broken into groups of locks.
A LockSpace contains a HashMap keyed by the group reference,
the data for each key is a HashMap of Lock's.
A LockSpace
can have an owner (for instance a
transaction). Currently, the owner is used by the virtual lock table to
find out which transaction a lock belongs to. Some parts of the code also
use the owner as a group object which guarantees that the lock is released
on a commit or an abort. The owner has no special meaning to the lock
manager and can be any object, including null
.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Limit
private Object
Map from group references to groups of locks.private boolean
private int
private static final int
The maximum number of elements to cache inspareGroups
.private int
private final LockOwner
Reference to the owner of this compatibility space.private final ArrayDeque
<HashMap<Lock, Lock>> Cached HashMaps for storing lock groups. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Add a lock to a group.(package private) boolean
Return true if locks are held in this compatibility space.(package private) boolean
areLocksHeld
(Object group) Return true if locks are held in a group(package private) void
clearLimit
(Object group) Clear a limit set by setLimit.(package private) int
deadlockCount
(int bail) Return a count of the number of locks held by this space.getGroupMap
(Object group) getOwner()
Get the object representing the owner of the compatibility space.(package private) boolean
isLockHeld
(Object group, Lockable ref, Object qualifier) private void
private void
(package private) void
(package private) void
(package private) void
unlockGroup
(LockTable lset, Object group) Unlock all the locks in a group and then remove the group.(package private) void
unlockGroup
(LockTable lset, Object group, Matchable key) Unlock all locks in the group that match the key(package private) int
unlockReference
(LockTable lset, Lockable ref, Object qualifier, Object group)
-
Field Details
-
groups
Map from group references to groups of locks. -
owner
Reference to the owner of this compatibility space. -
MAX_CACHED_GROUPS
private static final int MAX_CACHED_GROUPSThe maximum number of elements to cache inspareGroups
.- See Also:
-
spareGroups
Cached HashMaps for storing lock groups. -
callbackGroup
-
limit
private int limit -
nextLimitCall
private int nextLimitCall -
callback
-
inLimit
private boolean inLimit
-
-
Constructor Details
-
LockSpace
LockSpace(LockOwner owner) Creates a newLockSpace
instance.- Parameters:
owner
- an object representing the owner of the compatibility space
-
-
Method Details
-
getOwner
Get the object representing the owner of the compatibility space.- Specified by:
getOwner
in interfaceCompatibilitySpace
- Returns:
- the owner of the compatibility space
-
addLock
Add a lock to a group.- Throws:
StandardException
-
unlockGroup
Unlock all the locks in a group and then remove the group. -
getGroupMap
-
saveGroup
-
unlockGroup
Unlock all locks in the group that match the key -
transfer
-
mergeGroups
-
unlockReference
-
areLocksHeld
Return true if locks are held in a group -
areLocksHeld
boolean areLocksHeld()Return true if locks are held in this compatibility space.- Returns:
- true if locks are held, false otherwise
-
isLockHeld
-
setLimit
-
clearLimit
Clear a limit set by setLimit. -
deadlockCount
int deadlockCount(int bail) Return a count of the number of locks held by this space. The argument bail indicates at which point the counting should bail out and return the current count. This routine will bail if the count is greater than bail. Thus this routine is intended to for deadlock code to find the space with the fewest number of locks.
-