| java.lang.Object org.apache.commons.transaction.locking.GenericLockManager
All known Subclasses: org.apache.commons.transaction.locking.ReadWriteLockManager,
GenericLockManager | public class GenericLockManager implements LockManager,LockManager2(Code) | | Manager for
GenericLock s on resources. This implementation includes
- deadlock detection, which is configurable to come into effect after an initial short waiting
lock request; this is useful as it is somewhat expensive
- global transaction timeouts that actively revoke granted rights from transactions
version: $Id: GenericLockManager.java 493628 2007-01-07 01:42:48Z joerg $ |
Method Summary | |
protected void | addOwner(Object ownerId, GenericLock lock) | public MultiLevelLock | atomicGetOrCreateLock(Object resourceId) | public boolean | checkLock(Object ownerId, Object resourceId, int targetLockLevel, boolean reentrant) | protected GenericLock | createLock(Object resourceId) | protected void | doLock(GenericLock lock, Object ownerId, Object resourceId, int targetLockLevel, int compatibility, boolean preferred, long timeoutMSecs) | public Set | getAll(Object ownerId) | public int | getLevel(Object ownerId, Object resourceId) | public MultiLevelLock | getLock(Object resourceId) | public Collection | getLocks() Gets all locks as orignials, no copies. | protected long | getNextGlobalConflictTimeout(Set conflicts) | public boolean | hasLock(Object ownerId, Object resourceId, int lockLevel) | public void | lock(Object ownerId, Object resourceId, int targetLockLevel, boolean reentrant) | public void | lock(Object ownerId, Object resourceId, int targetLockLevel, boolean reentrant, long timeoutMSecs) | public void | lock(Object ownerId, Object resourceId, int targetLockLevel, int compatibility, boolean preferred, long timeoutMSecs) | public boolean | release(Object ownerId, Object resourceId) | public void | releaseAll(Object ownerId) | protected void | releaseAllNoTimeOutReset(Object ownerId) | protected boolean | releaseTimedOutOwners() | public void | removeLock(MultiLevelLock lock) | protected void | removeOwner(Object ownerId, GenericLock lock) | public void | startGlobalTimeout(Object ownerId, long timeoutMSecs) | protected boolean | timeOut(Object ownerId) | protected void | timeoutCheck(Object ownerId) | public synchronized String | toString() | public boolean | tryLock(Object ownerId, Object resourceId, int targetLockLevel, boolean reentrant) | protected boolean | wouldDeadlock(Object ownerId, Set path) Checks if an owner is deadlocked. |
DEFAULT_CHECK_THRESHHOLD | final public static long DEFAULT_CHECK_THRESHHOLD(Code) | | |
DEFAULT_TIMEOUT | final public static long DEFAULT_TIMEOUT(Code) | | |
checkThreshhold | protected long checkThreshhold(Code) | | |
effectiveGlobalTimeouts | protected Map effectiveGlobalTimeouts(Code) | | Maps onwerId to global effective time outs (i.e. the time the lock will time out).
|
globalLocks | protected Map globalLocks(Code) | | Maps resourceId to lock.
|
globalOwners | protected Map globalOwners(Code) | | Maps onwerId to locks it (partially) owns.
|
globalTimeoutMSecs | protected long globalTimeoutMSecs(Code) | | |
maxLockLevel | protected int maxLockLevel(Code) | | |
timedOutOwners | protected Set timedOutOwners(Code) | | |
GenericLockManager | public GenericLockManager(int maxLockLevel, LoggerFacade logger, long timeoutMSecs, long checkThreshholdMSecs) throws IllegalArgumentException(Code) | | Creates a new generic lock manager.
Parameters: maxLockLevel - highest allowed lock level as described in GenericLock's class intro Parameters: logger - generic logger used for all kind of debug logging Parameters: timeoutMSecs - specifies the maximum time to wait for a lock in milliseconds Parameters: checkThreshholdMSecs - specifies a special wait threshhold before deadlock andtimeout detection come into play or -1 switchit off and check for directly throws: IllegalArgumentException - if maxLockLevel is less than 1 since: 1.1 |
doLock | protected void doLock(GenericLock lock, Object ownerId, Object resourceId, int targetLockLevel, int compatibility, boolean preferred, long timeoutMSecs)(Code) | | |
getLocks | public Collection getLocks()(Code) | | Gets all locks as orignials, no copies.
collection holding all locks. |
getNextGlobalConflictTimeout | protected long getNextGlobalConflictTimeout(Set conflicts)(Code) | | |
releaseAllNoTimeOutReset | protected void releaseAllNoTimeOutReset(Object ownerId)(Code) | | |
releaseTimedOutOwners | protected boolean releaseTimedOutOwners()(Code) | | |
wouldDeadlock | protected boolean wouldDeadlock(Object ownerId, Set path)(Code) | | Checks if an owner is deadlocked.
We traverse the tree recursively formed by owners, locks held by them and
then again owners waiting for the locks. If there is a cycle in one of
the paths from the root to a leaf we have a deadlock.
A more detailed discussion on deadlocks and definitions and how to detect
them can be found in this
nice article .
Caution: This computation can be very expensive with many
owners and locks. Worst (unlikely) case is exponential.
Parameters: ownerId - the owner to check for being deadlocked Parameters: path - initially should be called with an empty set true if the owner is deadlocked,false otherwise |
|
|