|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Dictionary
java.util.Hashtable
org.apache.derby.impl.services.locks.SinglePool
An implementation of LockFactory that uses a single pool for the locks, i.e. all lock requests go through a single point of synchronisation.
The default concrete class "SinglePool.java", prints nothing and thus
incurs no overhead associated with the code to dump lock information. An
alternate concrete class "LockDebug/TracingSinglePool.java", attempts to
output only lock information that "makes sense" to a user - for instance it
doesn't print latch locks.
MT - Mutable - Container Object : Thread Aware
Nested Class Summary |
Nested classes inherited from class java.util.Hashtable |
|
Field Summary | |
(package private) int |
deadlockMonitor
True if all deadlocks errors should be logged. |
protected LockSet |
lockTable
The complete set of locks in the system MT - immutable - content dynamic : LockSet is ThreadSafe |
Fields inherited from class java.util.Hashtable |
|
Constructor Summary | |
SinglePool()
|
Method Summary | |
boolean |
anyoneBlocked()
Returns true if locks by anyone are blocking anyone else |
Serviceable |
apply(java.lang.String key,
java.io.Serializable value,
java.util.Dictionary p)
Apply a property change. |
boolean |
areLocksHeld(java.lang.Object compatabilitySpace)
Return true if locks are held in this space MT - thread safe |
boolean |
areLocksHeld(java.lang.Object compatabilitySpace,
java.lang.Object group)
Return true if locks are held in this group and this space. |
void |
clearLimit(java.lang.Object compatabilitySpace,
java.lang.Object group)
Clear a limit set by setLimit. |
private void |
getAndApply(boolean dbOnly,
java.util.Dictionary p,
java.lang.String key)
|
private static int |
getWaitValue(java.lang.String value,
int defaultValue)
|
void |
init(boolean dbOnly,
java.util.Dictionary p)
Initialize the properties for this callback. |
boolean |
isLockHeld(java.lang.Object compatabilitySpace,
java.lang.Object group,
Lockable ref,
java.lang.Object qualifier)
Check to see if a specific lock is held. |
boolean |
latchObject(java.lang.Object compatabilitySpace,
Lockable ref,
java.lang.Object qualifier,
int timeout)
Latch a specific object with a timeout. |
protected Lock |
lockAnObject(java.lang.Object compatabilitySpace,
java.lang.Object group,
Lockable ref,
java.lang.Object qualifier,
int timeout,
Latch heldLatch)
Lock a specific object with a timeout. |
boolean |
lockObject(java.lang.Object group,
Lockable ref,
java.lang.Object qualifier,
int timeout,
Latch latch)
Lock a specific object while holding a latch MT - thread safe |
boolean |
lockObject(java.lang.Object compatabilitySpace,
java.lang.Object group,
Lockable ref,
java.lang.Object qualifier,
int timeout)
Lock a specific object MT - thread safe |
java.util.Enumeration |
makeVirtualLockTable()
Routines to support lock diagnostics VTIs for the benefit of VirtualLockTable |
java.io.Serializable |
map(java.lang.String key,
java.io.Serializable value,
java.util.Dictionary p)
Map a proposed new value for a property to an official value. |
void |
setLimit(java.lang.Object compatabilitySpace,
java.lang.Object group,
int limit,
Limit callback)
Install a limit that is called when the size of the group exceeds the required limit. |
java.lang.String |
toDebugString()
|
void |
transfer(java.lang.Object compatabilitySpace,
java.lang.Object oldGroup,
java.lang.Object newGroup)
Transfer a set of locks from one group to another. |
void |
unlatch(Latch heldLatch)
Unlatch an object. |
int |
unlock(java.lang.Object compatabilitySpace,
java.lang.Object group,
Lockable ref,
java.lang.Object qualifier)
Unlock a specific object MT - thread safe |
void |
unlockGroup(java.lang.Object compatabilitySpace,
java.lang.Object group)
Unlock a group of objects. |
void |
unlockGroup(java.lang.Object compatabilitySpace,
java.lang.Object group,
Matchable key)
Unlock all locks on a group that match the passed in value. |
boolean |
validate(java.lang.String key,
java.io.Serializable value,
java.util.Dictionary p)
Validate a property change. |
boolean |
zeroDurationlockObject(java.lang.Object compatabilitySpace,
Lockable ref,
java.lang.Object qualifier,
int timeout)
Lock an object with zero duration within a compatability space, waits up to timeout milli-seconds for the object to become unlocked. |
Methods inherited from class java.util.Hashtable |
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, put, putAll, rehash, remove, size, toString, values |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
protected final LockSet lockTable
int deadlockMonitor
Constructor Detail |
public SinglePool()
Method Detail |
public boolean latchObject(java.lang.Object compatabilitySpace, Lockable ref, java.lang.Object qualifier, int timeout) throws StandardException
latchObject
in interface LockFactory
StandardException
- Standard Cloudscape error policyLockFactory.latchObject(java.lang.Object, org.apache.derby.iapi.services.locks.Lockable, java.lang.Object, int)
public void unlatch(Latch heldLatch)
unlatch
in interface LockFactory
LockFactory.unlatch(org.apache.derby.iapi.services.locks.Latch)
protected Lock lockAnObject(java.lang.Object compatabilitySpace, java.lang.Object group, Lockable ref, java.lang.Object qualifier, int timeout, Latch heldLatch) throws StandardException
StandardException
- Standard Cloudscape error policyLockFactory.lockObject(java.lang.Object, java.lang.Object, org.apache.derby.iapi.services.locks.Lockable, java.lang.Object, int)
public boolean lockObject(java.lang.Object compatabilitySpace, java.lang.Object group, Lockable ref, java.lang.Object qualifier, int timeout) throws StandardException
lockObject
in interface LockFactory
compatabilitySpace
- object defining compatability space (by value)group
- handle of group, must be private to a thread.ref
- reference to object to be lockedqualifier
- A qualification of the request.timeout
- the maximum time to wait in milliseconds, LockFactory.NO_WAIT means don't wait.
StandardException
- Standard Cloudscape error policyLockFactory.lockObject(java.lang.Object, java.lang.Object, org.apache.derby.iapi.services.locks.Lockable, java.lang.Object, int)
public boolean lockObject(java.lang.Object group, Lockable ref, java.lang.Object qualifier, int timeout, Latch latch) throws StandardException
lockObject
in interface LockFactory
group
- handle of group, must be private to a compatability space.ref
- reference to object to be lockedqualifier
- A qualification of the request.timeout
- amount of time to wait, NO_WAIT is not supportedlatch
- latch to be atomically released/re-latched in a wait.
StandardException
- Standard Cloudscape error policyLockFactory.lockObject(java.lang.Object, java.lang.Object, org.apache.derby.iapi.services.locks.Lockable, java.lang.Object, int)
public int unlock(java.lang.Object compatabilitySpace, java.lang.Object group, Lockable ref, java.lang.Object qualifier)
unlock
in interface LockFactory
compatabilitySpace
- object defining compatability space (by value)group
- handle of group.ref
- Reference to object to be unlocked.qualifier
- qualifier of lock to be unlocked
LockFactory.unlock(java.lang.Object, java.lang.Object, org.apache.derby.iapi.services.locks.Lockable, java.lang.Object)
public void unlockGroup(java.lang.Object compatabilitySpace, java.lang.Object group)
unlockGroup
in interface LockFactory
group
- handle of group that objects were locked with.
If group is null then this call is equivilent to unlockAll().LockFactory.unlockGroup(java.lang.Object, java.lang.Object)
public void unlockGroup(java.lang.Object compatabilitySpace, java.lang.Object group, Matchable key)
LockFactory
unlockGroup
in interface LockFactory
public void transfer(java.lang.Object compatabilitySpace, java.lang.Object oldGroup, java.lang.Object newGroup)
transfer
in interface LockFactory
LockFactory.transfer(java.lang.Object, java.lang.Object, java.lang.Object)
public boolean anyoneBlocked()
anyoneBlocked
in interface LockFactory
public boolean areLocksHeld(java.lang.Object compatabilitySpace, java.lang.Object group)
areLocksHeld
in interface LockFactory
group
- handle of group that objects were locked with.LockFactory.areLocksHeld(java.lang.Object, java.lang.Object)
public boolean areLocksHeld(java.lang.Object compatabilitySpace)
areLocksHeld
in interface LockFactory
LockFactory.areLocksHeld(java.lang.Object, java.lang.Object)
public boolean zeroDurationlockObject(java.lang.Object compatabilitySpace, Lockable ref, java.lang.Object qualifier, int timeout) throws StandardException
LockFactory
Zero duration means the lock is released as soon as it is obtained.
A compatibility space in an space where lock requests are assumed to be
compatabile and granted by the lock manager if the trio
{compatabilitySpace, ref, qualifier} are equal (i.e. reference equality
for qualifier, equals() method
for compatabilitySpace and ref ). A typical reference to use for the compatability
space is a reference to an object representing a transaction.
Granted by the lock manager means that the Lockable object may or may
not be queried to see if the request is compatible.
A compatability space is not assumed to be owned by a single thread.
zeroDurationlockObject
in interface LockFactory
compatabilitySpace
- object defining compatability space (by value)ref
- reference to object to be lockedqualifier
- A qualification of the request.timeout
- the maximum time to wait in milliseconds, LockFactory.NO_WAIT means don't wait.
StandardException
- Another thread interupted this thread while
it was waiting for the lock. This will be a StandardException with a nested java.lang.InterruptedException exception,
(message id will be LockFactory.InterruptedExceptionId)public boolean isLockHeld(java.lang.Object compatabilitySpace, java.lang.Object group, Lockable ref, java.lang.Object qualifier)
LockFactory
isLockHeld
in interface LockFactory
public void setLimit(java.lang.Object compatabilitySpace, java.lang.Object group, int limit, Limit callback)
LockFactory
setLimit
in interface LockFactory
Limit
public void clearLimit(java.lang.Object compatabilitySpace, java.lang.Object group)
clearLimit
in interface LockFactory
public java.util.Enumeration makeVirtualLockTable()
makeVirtualLockTable
in interface LockFactory
public java.lang.String toDebugString()
public void init(boolean dbOnly, java.util.Dictionary p)
PropertySetCallback
Code within an init() method should use the 3 argument PropertyUtil method getPropertyFromSet() to obtain a property's value.
init
in interface PropertySetCallback
dbOnly
- true if only per-database properties are to be looked atp
- the complete set of per-database properties.private void getAndApply(boolean dbOnly, java.util.Dictionary p, java.lang.String key)
public boolean validate(java.lang.String key, java.io.Serializable value, java.util.Dictionary p) throws StandardException
PropertySetCallback
validate
in interface PropertySetCallback
key
- Property key for the property being setvalue
- proposed new value for the property being set or null if
the property is being dropped.p
- Property set before the change. SettingProperty may read but
must never change p.
StandardException
- Oh well.public Serviceable apply(java.lang.String key, java.io.Serializable value, java.util.Dictionary p) throws StandardException
PropertySetCallback
apply
in interface PropertySetCallback
key
- Property key for the property being setvalue
- proposed new value for the property being set or null if
the property is being dropped.p
- Property set before the change. SettingProperty may read but
must never change p.
StandardException
- Oh well.public java.io.Serializable map(java.lang.String key, java.io.Serializable value, java.util.Dictionary p)
PropertySetCallback
map
in interface PropertySetCallback
key
- Property key for the property being setvalue
- proposed new value for the property being set or null if
the property is being dropped.p
- Property set before the change. SettingProperty may read but
must never change p.
private static int getWaitValue(java.lang.String value, int defaultValue)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |