|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.transaction.locking.GenericLockManager
org.apache.commons.transaction.locking.ReadWriteLockManager
org.apache.commons.transaction.locking.ReadWriteUpgradeLockManager
public class ReadWriteUpgradeLockManager
Manager for
ReadWriteUpgradeLock
s on
resources.
The idea (as explained by Jim LoVerde) is that only one owner can hold an upgrade lock, but while that is held, it is possible for read locks to exist and/or be obtained, and when the request is made to upgrade to a write lock by the same owner, the lock manager prevents additional read locks until the write lock can be aquired.
In this sense the write lock becomes preferred over all other locks when it gets upgraded from a upgrate lock. Preferred means that if it has to wait and others wait as well it will be served before all other none preferred locking requests.
ReadWriteUpgradeLock
Field Summary |
---|
Fields inherited from class org.apache.commons.transaction.locking.GenericLockManager |
---|
checkThreshhold, DEFAULT_CHECK_THRESHHOLD, DEFAULT_TIMEOUT, effectiveGlobalTimeouts, globalLocks, globalOwners, globalTimeoutMSecs, logger, maxLockLevel, timedOutOwners |
Constructor Summary | |
---|---|
ReadWriteUpgradeLockManager(LoggerFacade logger,
long timeoutMSecs)
Creates a new read/write/upgrade lock manager. |
Method Summary | |
---|---|
protected GenericLock |
createLock(Object resourceId)
|
boolean |
tryUpgradeLock(Object ownerId,
Object resourceId)
Tries to acquire a reentrant upgrade lock on a resource. |
boolean |
tryWriteLock(Object ownerId,
Object resourceId)
Tries to acquire an exclusive, reentrant write lock on a resource. |
void |
upgradeLock(Object ownerId,
Object resourceId)
Tries to acquire a reentrant upgrade lock on a resource. |
void |
writeLock(Object ownerId,
Object resourceId)
Tries to acquire an exclusive, reentrant write lock on a resource. |
Methods inherited from class org.apache.commons.transaction.locking.ReadWriteLockManager |
---|
checkReadLock, checkWriteLock, hasReadLock, hasWriteLock, readLock, tryReadLock |
Methods inherited from class org.apache.commons.transaction.locking.GenericLockManager |
---|
addOwner, atomicGetOrCreateLock, checkLock, doLock, getAll, getLevel, getLock, getLocks, getNextGlobalConflictTimeout, hasLock, lock, lock, lock, release, releaseAll, releaseAllNoTimeOutReset, releaseTimedOutOwners, removeLock, removeOwner, removeOwnerWithoutLocks, startGlobalTimeout, timeOut, timeoutCheck, toString, tryLock, wouldDeadlock |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ReadWriteUpgradeLockManager(LoggerFacade logger, long timeoutMSecs)
logger
- generic logger used for all kind of debug loggingtimeoutMSecs
- specifies the maximum time to wait for a lock in millisecondsMethod Detail |
---|
public boolean tryUpgradeLock(Object ownerId, Object resourceId)
false
will be returned.
ownerId
- a unique id identifying the entity that wants to acquire this
lockresourceId
- the resource to get the lock for
true
if the lock has been acquired, false
otherwisepublic boolean tryWriteLock(Object ownerId, Object resourceId)
false
will be returned.
tryWriteLock
in class ReadWriteLockManager
ownerId
- a unique id identifying the entity that wants to acquire this
lockresourceId
- the resource to get the lock for
true
if the lock has been acquired, false
otherwisepublic void upgradeLock(Object ownerId, Object resourceId) throws LockException
ownerId
- a unique id identifying the entity that wants to acquire this
lockresourceId
- the resource to get the level for
LockException
- will be thrown when the lock can not be acquiredpublic void writeLock(Object ownerId, Object resourceId) throws LockException
writeLock
in class ReadWriteLockManager
ownerId
- a unique id identifying the entity that wants to acquire this
lockresourceId
- the resource to get the level for
LockException
- will be thrown when the lock can not be acquiredprotected GenericLock createLock(Object resourceId)
createLock
in class ReadWriteLockManager
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |