public class ReadWriteLockManager extends GenericLockManager
ReadWriteLock
s on resources.checkThreshhold, DEFAULT_CHECK_THRESHHOLD, DEFAULT_TIMEOUT, effectiveGlobalTimeouts, globalLocks, globalOwners, globalTimeoutMSecs, logger, maxLockLevel, timedOutOwners
Modifier | Constructor and Description |
---|---|
protected |
ReadWriteLockManager(int maxLockLevel,
LoggerFacade logger,
long timeoutMSecs) |
|
ReadWriteLockManager(LoggerFacade logger,
long timeoutMSecs)
Creates a new read/write lock manager.
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkReadLock(java.lang.Object ownerId,
java.lang.Object resourceId)
Determines if a shared, reentrant read lock on a resource
could be acquired without actually acquiring it.
|
boolean |
checkWriteLock(java.lang.Object ownerId,
java.lang.Object resourceId)
Determines if an exclusive, reentrant write lock on a resource
could be acquired without actually acquiring it.
|
protected GenericLock |
createLock(java.lang.Object resourceId) |
boolean |
hasReadLock(java.lang.Object ownerId,
java.lang.Object resourceId)
Determines if a shared, reentrant read lock on a resource
is held by an owner.
|
boolean |
hasWriteLock(java.lang.Object ownerId,
java.lang.Object resourceId)
Determines if an exclusive, reentrant write lock on a resource
is held by an owner.
|
void |
readLock(java.lang.Object ownerId,
java.lang.Object resourceId)
Tries to acquire a shared, reentrant read lock on a resource.
|
boolean |
tryReadLock(java.lang.Object ownerId,
java.lang.Object resourceId)
Tries to acquire a shared, reentrant read lock on a resource.
|
boolean |
tryWriteLock(java.lang.Object ownerId,
java.lang.Object resourceId)
Tries to acquire an exclusive, reentrant write lock on a resource.
|
void |
writeLock(java.lang.Object ownerId,
java.lang.Object resourceId)
Tries to acquire an exclusive, reentrant write lock on a resource.
|
addOwner, atomicGetOrCreateLock, checkLock, doLock, getAll, getLevel, getLock, getLocks, getNextGlobalConflictTimeout, hasLock, lock, lock, lock, release, releaseAll, releaseAllNoTimeOutReset, releaseTimedOutOwners, removeLock, removeOwner, startGlobalTimeout, timeOut, timeoutCheck, toString, tryLock, wouldDeadlock
public ReadWriteLockManager(LoggerFacade logger, long timeoutMSecs)
logger
- generic logger used for all kind of debug loggingtimeoutMSecs
- specifies the maximum time to wait for a lock in millisecondsprotected ReadWriteLockManager(int maxLockLevel, LoggerFacade logger, long timeoutMSecs) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public boolean tryReadLock(java.lang.Object ownerId, java.lang.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 fortrue
if the lock has been acquired, false
otherwisepublic boolean tryWriteLock(java.lang.Object ownerId, java.lang.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 fortrue
if the lock has been acquired, false
otherwisepublic boolean checkReadLock(java.lang.Object ownerId, java.lang.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 fortrue
if the lock could be acquired, false
otherwisepublic boolean hasWriteLock(java.lang.Object ownerId, java.lang.Object resourceId)
ownerId
- a unique id identifying the entity that wants to check this
lockresourceId
- the resource to get the lock fortrue
if the lock is held by the owner, false
otherwisepublic boolean hasReadLock(java.lang.Object ownerId, java.lang.Object resourceId)
ownerId
- a unique id identifying the entity that wants to check this
lockresourceId
- the resource to get the lock fortrue
if the lock is held by the owner, false
otherwisepublic boolean checkWriteLock(java.lang.Object ownerId, java.lang.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 fortrue
if the lock could be acquired, false
otherwisepublic void readLock(java.lang.Object ownerId, java.lang.Object resourceId) throws LockException
ownerId
- a unique id identifying the entity that wants to acquire this
lockresourceId
- the resource to get the lock forLockException
- will be thrown when the lock can not be acquiredpublic void writeLock(java.lang.Object ownerId, java.lang.Object resourceId) throws LockException
ownerId
- a unique id identifying the entity that wants to acquire this
lockresourceId
- the resource to get the lock forLockException
- will be thrown when the lock can not be acquiredprotected GenericLock createLock(java.lang.Object resourceId)
createLock
in class GenericLockManager
Copyright ? 2004 The Apache Software Foundation. All Rights Reserved.