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(Object ownerId,
Object resourceId)
Determines if a shared, reentrant read lock on a resource
could be acquired without actually acquiring it.
|
boolean |
checkWriteLock(Object ownerId,
Object resourceId)
Determines if an exclusive, reentrant write lock on a resource
could be acquired without actually acquiring it.
|
protected GenericLock |
createLock(Object resourceId) |
boolean |
hasReadLock(Object ownerId,
Object resourceId)
Determines if a shared, reentrant read lock on a resource
is held by an owner.
|
boolean |
hasWriteLock(Object ownerId,
Object resourceId)
Determines if an exclusive, reentrant write lock on a resource
is held by an owner.
|
void |
readLock(Object ownerId,
Object resourceId)
Tries to acquire a shared, reentrant read lock on a resource.
|
boolean |
tryReadLock(Object ownerId,
Object resourceId)
Tries to acquire a shared, reentrant read lock on a resource.
|
boolean |
tryWriteLock(Object ownerId,
Object resourceId)
Tries to acquire an exclusive, reentrant write lock on a resource.
|
void |
writeLock(Object ownerId,
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, removeOwnerWithoutLocks, 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 IllegalArgumentException
IllegalArgumentException
public boolean tryReadLock(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 fortrue
if the lock has been acquired, false
otherwisepublic boolean tryWriteLock(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 fortrue
if the lock has been acquired, false
otherwisepublic boolean checkReadLock(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 fortrue
if the lock could be acquired, false
otherwisepublic boolean hasWriteLock(Object ownerId, 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(Object ownerId, 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(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 fortrue
if the lock could be acquired, false
otherwisepublic void readLock(Object ownerId, 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(Object ownerId, 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(Object resourceId)
createLock
in class GenericLockManager
Copyright © 2004-2013 The Apache Software Foundation. All Rights Reserved.