Package org.jgroups.blocks
Interface LockManager
-
- All Known Implementing Classes:
DistributedLockManager
public interface LockManagerLockManagerrepresents generic lock manager that allows obtaining and releasing locks on objects.- Version:
- $Id: LockManager.java,v 1.2 2005/06/08 15:56:54 publicnmi Exp $
- Author:
- Roman Rokytskyy (rrokytskyy@acm.org), Robert Schaffar-Taurok (robert@fusion.at)
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidlock(java.lang.Object obj, java.lang.Object owner, int timeout)Obtain lock onobjfor specifiedowner.voidunlock(java.lang.Object obj, java.lang.Object owner)Release lock onobjowned by specifiedowner.voidunlock(java.lang.Object obj, java.lang.Object owner, boolean releaseMultiLocked)Release lock onobjowned by specifiedowner.
-
-
-
Method Detail
-
lock
void lock(java.lang.Object obj, java.lang.Object owner, int timeout) throws LockNotGrantedException, java.lang.ClassCastException, ChannelExceptionObtain lock onobjfor specifiedowner. Implementation should try to obtain lock few times within the specified timeout.- Parameters:
obj- obj to lock, usually not full object but object's ID.owner- object identifying entity that will own the lock.timeout- maximum time that we grant to obtain a lock.- Throws:
LockNotGrantedException- if lock is not granted within specified period.java.lang.ClassCastException- ifobjand/orowneris not of type that implementation expects to get (for example, when distributed lock manager obtains non-serializableobjorowner).ChannelException- if something bad happened to communication channel.
-
unlock
void unlock(java.lang.Object obj, java.lang.Object owner) throws LockNotReleasedException, java.lang.ClassCastException, ChannelExceptionRelease lock onobjowned by specifiedowner. since 2.2.9 this method is only a wrapper for unlock(Object lockId, Object owner, boolean releaseMultiLocked). Use that with releaseMultiLocked set to true if you want to be able to release multiple locked locks (for example after a merge)- Parameters:
obj- obj to lock, usually not full object but object's ID.owner- object identifying entity that will own the lock.- Throws:
LockOwnerMismatchException- if lock is owned by another object.java.lang.ClassCastException- ifobjand/orowneris not of type that implementation expects to get (for example, when distributed lock manager obtains non-serializableobjorowner).ChannelException- if something bad happened to communication channel.LockNotReleasedException
-
unlock
void unlock(java.lang.Object obj, java.lang.Object owner, boolean releaseMultiLocked) throws LockNotReleasedException, java.lang.ClassCastException, ChannelException, LockMultiLockedExceptionRelease lock onobjowned by specifiedowner.- Parameters:
obj- obj to lock, usually not full object but object's ID.owner- object identifying entity that will own the lock.releaseMultiLocked- force unlocking of the lock if the local lockManager owns the lock even if another lockManager owns the same lock- Throws:
LockOwnerMismatchException- if lock is owned by another object.java.lang.ClassCastException- ifobjand/orowneris not of type that implementation expects to get (for example, when distributed lock manager obtains non-serializableobjorowner).ChannelException- if something bad happened to communication channel.LockMultiLockedException- if the lock was unlocked, but another node already held the lockLockNotReleasedException
-
-