Top Description Fields Constructors Methods
org.apache.derby.impl.services.locks

pack-priv final Class LockSpace

Additional top-level class in compilation unit: LockList.

extends Object
implements CompatibilitySpace
Class Inheritance
All Implemented Interfaces
org.apache.derby.iapi.services.locks.CompatibilitySpace
Imports
org.apache.derby.iapi.services.locks.CompatibilitySpace, .Lockable, .Limit, .LockOwner, org.apache.derby.iapi.util.Matchable, org.apache.derby.shared.common.sanity.SanityManager, org.apache.derby.shared.common.error.StandardException, java.util.ArrayDeque, .Enumeration, .HashMap, .Iterator

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

Modifier and TypeField and Description
private Limit
private Object
private final HashMap<Object, HashMap<Lock, Lock>>
groups

Map from group references to groups of locks.

private boolean
private int
private static final int
MAX_CACHED_GROUPS

The maximum number of elements to cache in spareGroups.

private int
private final LockOwner
owner

Reference to the owner of this compatibility space.

private final ArrayDeque<HashMap<Lock, Lock>>
spareGroups

Cached HashMaps for storing lock groups.

Constructor Summary

AccessConstructor and Description
pack-priv
LockSpace(LockOwner
an object representing the owner of the compatibility space
owner
)

Creates a new LockSpace instance.

Method Summary

Modifier and TypeMethod and Description
protected synchronized void
addLock(Object group, Lock lock)

Add a lock to a group.

pack-priv synchronized boolean
areLocksHeld(Object group)

Return true if locks are held in a group

pack-priv synchronized boolean

Returns:

true if locks are held, false otherwise
areLocksHeld
()

Return true if locks are held in this compatibility space.

pack-priv synchronized void
clearLimit(Object group)

Clear a limit set by setLimit.

pack-priv synchronized int
deadlockCount(int bail)

Return a count of the number of locks held by this space.

private HashMap<Lock, Lock>
public LockOwner

Returns:

the owner of the compatibility space
getOwner
()

Implements org.apache.derby.iapi.services.locks.CompatibilitySpace.getOwner.

Get the object representing the owner of the compatibility space.

pack-priv synchronized boolean
isLockHeld(Object group, Lockable ref, Object qualifier)

private void
private void
pack-priv synchronized void
setLimit(Object group, int limit, Limit callback)

pack-priv synchronized void
transfer(Object oldGroup, Object newGroup)

pack-priv synchronized void
unlockGroup(LockTable lset, Object group)

Unlock all the locks in a group and then remove the group.

pack-priv synchronized void
unlockGroup(LockTable lset, Object group, Matchable key)

Unlock all locks in the group that match the key

pack-priv synchronized int
unlockReference(LockTable lset, Lockable ref, Object qualifier, Object group)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

callbackback to summary
private Limit callback
callbackGroupback to summary
private Object callbackGroup
groupsback to summary
private final HashMap<Object, HashMap<Lock, Lock>> groups

Map from group references to groups of locks.

inLimitback to summary
private boolean inLimit
limitback to summary
private int limit
MAX_CACHED_GROUPSback to summary
private static final int MAX_CACHED_GROUPS

The maximum number of elements to cache in spareGroups.

nextLimitCallback to summary
private int nextLimitCall
ownerback to summary
private final LockOwner owner

Reference to the owner of this compatibility space.

spareGroupsback to summary
private final ArrayDeque<HashMap<Lock, Lock>> spareGroups

Cached HashMaps for storing lock groups.

Constructor Detail

LockSpaceback to summary
pack-priv LockSpace(LockOwner owner)

Creates a new LockSpace instance.

Parameters
owner:LockOwner

an object representing the owner of the compatibility space

Method Detail

addLockback to summary
protected synchronized void addLock(Object group, Lock lock) throws StandardException

Add a lock to a group.

areLocksHeldback to summary
pack-priv synchronized boolean areLocksHeld(Object group)

Return true if locks are held in a group

areLocksHeldback to summary
pack-priv synchronized boolean areLocksHeld()

Return true if locks are held in this compatibility space.

Returns:boolean

true if locks are held, false otherwise

clearLimitback to summary
pack-priv synchronized void clearLimit(Object group)

Clear a limit set by setLimit.

deadlockCountback to summary
pack-priv synchronized 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.

getGroupMapback to summary
private HashMap<Lock, Lock> getGroupMap(Object group)
getOwnerback to summary
public LockOwner getOwner()

Implements org.apache.derby.iapi.services.locks.CompatibilitySpace.getOwner.

Get the object representing the owner of the compatibility space.

Returns:LockOwner

the owner of the compatibility space

isLockHeldback to summary
pack-priv synchronized boolean isLockHeld(Object group, Lockable ref, Object qualifier)
mergeGroupsback to summary
private void mergeGroups(HashMap<Lock, Lock> from, HashMap<Lock, Lock> into)
saveGroupback to summary
private void saveGroup(HashMap<Lock, Lock> dl)
setLimitback to summary
pack-priv synchronized void setLimit(Object group, int limit, Limit callback)
transferback to summary
pack-priv synchronized void transfer(Object oldGroup, Object newGroup)
unlockGroupback to summary
pack-priv synchronized void unlockGroup(LockTable lset, Object group)

Unlock all the locks in a group and then remove the group.

unlockGroupback to summary
pack-priv synchronized void unlockGroup(LockTable lset, Object group, Matchable key)

Unlock all locks in the group that match the key

unlockReferenceback to summary
pack-priv synchronized int unlockReference(LockTable lset, Lockable ref, Object qualifier, Object group)