public interface LockManager2
MultiLevelLock
,
MultiLevelLock2
,
LockManager
,
GenericLockManager
,
GenericLock
Modifier and Type | Method and Description |
---|---|
boolean |
checkLock(Object ownerId,
Object resourceId,
int targetLockLevel,
boolean reentrant)
Determines if a lock could be acquire without actually acquiring it.
|
Set |
getAll(Object ownerId)
Gets all locks (partially) held by an owner.
|
int |
getLevel(Object ownerId,
Object resourceId)
Gets the lock level held by certain owner on a certain resource.
|
MultiLevelLock |
getLock(Object resourceId)
Gets an existing lock on the specified resource.
|
boolean |
hasLock(Object ownerId,
Object resourceId,
int lockLevel)
Determines if a lock is owner by an owner.
|
void |
lock(Object ownerId,
Object resourceId,
int targetLockLevel,
boolean reentrant)
Tries to acquire a lock on a resource.
|
void |
lock(Object ownerId,
Object resourceId,
int targetLockLevel,
boolean reentrant,
long timeoutMSecs)
Tries to acquire a lock on a resource.
|
void |
lock(Object ownerId,
Object resourceId,
int targetLockLevel,
int compatibility,
boolean preferred,
long timeoutMSecs)
Most flexible way to acquire a lock on a resource.
|
boolean |
release(Object ownerId,
Object resourceId)
Releases all locks for a certain resource held by a certain owner.
|
void |
releaseAll(Object ownerId)
Releases all locks (partially) held by an owner.
|
void |
removeLock(MultiLevelLock lock)
Removes the specified lock from the associated resource.
|
void |
startGlobalTimeout(Object ownerId,
long timeoutMSecs)
Starts a global timeout for an owner.
|
boolean |
tryLock(Object ownerId,
Object resourceId,
int targetLockLevel,
boolean reentrant)
Tries to acquire a lock on a resource.
|
boolean hasLock(Object ownerId, Object resourceId, int lockLevel)
ownerId
- a unique id identifying the entity that wants to check this
lockresourceId
- the resource to get the level forlockLevel
- the lock level to checktrue
if the owner has the lock, false
otherwiseboolean checkLock(Object ownerId, Object resourceId, int targetLockLevel, boolean reentrant)
ownerId
- a unique id identifying the entity that wants to check this
lockresourceId
- the resource to get the level fortargetLockLevel
- the lock level to checkreentrant
- true
if this request shall not be influenced by
other locks held by the same ownertrue
if the lock could be acquired, false
otherwiseboolean tryLock(Object ownerId, Object resourceId, int targetLockLevel, boolean reentrant)
false
will be returned.ownerId
- a unique id identifying the entity that wants to acquire this
lockresourceId
- the resource to get the level fortargetLockLevel
- the lock level to acquirereentrant
- true
if this request shall not be influenced by
other locks held by the same ownertrue
if the lock has been acquired, false
otherwisevoid lock(Object ownerId, Object resourceId, int targetLockLevel, boolean reentrant) throws LockException
ownerId
- a unique id identifying the entity that wants to acquire this
lockresourceId
- the resource to get the level fortargetLockLevel
- the lock level to acquirereentrant
- true
if this request shall not be blocked by
other locks held by the same ownerLockException
- will be thrown when the lock can not be acquiredvoid lock(Object ownerId, Object resourceId, int targetLockLevel, boolean reentrant, long timeoutMSecs) throws LockException
ownerId
- a unique id identifying the entity that wants to acquire this
lockresourceId
- the resource to get the level fortargetLockLevel
- the lock level to acquirereentrant
- true
if this request shall not be blocked by
other locks held by the same ownertimeoutMSecs
- specifies the maximum wait time in millisecondsLockException
- will be thrown when the lock can not be acquiredvoid lock(Object ownerId, Object resourceId, int targetLockLevel, int compatibility, boolean preferred, long timeoutMSecs) throws LockException
ownerId
- a unique id identifying the entity that wants to acquire this
lockresourceId
- the resource to get the level fortargetLockLevel
- the lock level to acquirecompatibility
- MultiLevelLock2.COMPATIBILITY_NONE
if no additional compatibility is
desired (same as reentrant set to false) ,
MultiLevelLock2.COMPATIBILITY_REENTRANT
if lock level by the same
owner shall not affect compatibility (same as reentrant set to
true), or MultiLevelLock2.COMPATIBILITY_SUPPORT
if lock levels that
are the same as the desired shall not affect compatibility, or
finally MultiLevelLock2.COMPATIBILITY_REENTRANT_AND_SUPPORT
which is
a combination of reentrant and supportpreferred
- in case this lock request is incompatible with existing ones
and we wait, it shall be granted before other waiting requests
that are not preferredtimeoutMSecs
- specifies the maximum wait time in millisecondsLockException
- will be thrown when the lock can not be acquiredvoid startGlobalTimeout(Object ownerId, long timeoutMSecs)
releaseAll(Object)
.ownerId
- a unique id identifying the entity that wants to acquire this
locktimeoutMSecs
- specifies the global timeout in millisecondsint getLevel(Object ownerId, Object resourceId)
ownerId
- the id of the owner of the lockresourceId
- the resource to get the level forboolean release(Object ownerId, Object resourceId)
ownerId
- the id of the owner of the lockresourceId
- the resource to releases the lock fortrue
if the lock actually was released, false
in case
there was no lock held by the ownervoid releaseAll(Object ownerId)
ownerId
- the id of the ownerSet getAll(Object ownerId)
ownerId
- the id of the ownerMultiLevelLock getLock(Object resourceId)
null
.resourceId
- the resource to get the lock forvoid removeLock(MultiLevelLock lock)
release(Object, Object)
for that.lock
- the lock to be removedCopyright © 2004-2013 The Apache Software Foundation. All Rights Reserved.