|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.jboss.cache.lock.IdentityLock
@Deprecated public class IdentityLock
Lock object which grants and releases locks, and associates locks with owners. The methods to acquire and release a lock require an owner (Object). When a lock is acquired, we store the current owner with the lock. When the same owner (but possibly running in a different thread) wants to acquire the lock, it is immediately granted. When an owner different from the one currently owning the lock wants to release the lock, we do nothing (no-op).
Consider the following example:FIFOSemaphore lock=new FIFOSemaphore(1); lock.acquire(); lock.acquire(); lock.release();This would block on the second acquire() (although we currently already hold the lock) because the lock only has 1 permit. So IdentityLock will allow the following code to work properly:
IdentityLock lock=new IdentityLock(); lock.readLock().acquire(this, timeout); lock.writeLock().acquire(this, timeout); lock.release(this);If the owner is null, then the current thread is taken by default. This allow the following code to work:
IdentityLock lock=new IdentityLock(); lock.readLock().attempt(null, timeout); lock.writeLock().attempt(null, timeout); lock.release(null);
Object.equals(java.lang.Object). For
a use case see the examples in the testsuite.
| Constructor Summary | |
|---|---|
IdentityLock(LockStrategyFactory factory,
NodeSPI node)
Deprecated. Creates a new IdentityLock using the LockFactory passed in. |
|
| Method Summary | |
|---|---|
boolean |
acquire(Object caller,
long timeout,
LockType lock_type)
Deprecated. |
Set<NodeLock> |
acquireAll(Object caller,
long timeout,
LockType lock_type)
Deprecated. Recursively acquire locks for this node and all subnodes, including internal Fqns such as buddy backup subtrees. |
Set<NodeLock> |
acquireAll(Object caller,
long timeout,
LockType lock_type,
boolean excludeInternalFqns)
Deprecated. Same as the overloaded NodeLock.acquire(Object, long, LockType) except that you can
optionally specify that internal Fqns - such as buddy backup subtrees - can be excluded when acquiring locks. |
boolean |
acquireReadLock(Object caller,
long timeout)
Deprecated. Acquire a read lock with a timeout period of timeout milliseconds. |
boolean |
acquireWriteLock(Object caller,
long timeout)
Deprecated. Acquire a write lock with a timeout of timeout milliseconds. |
Fqn |
getFqn()
Deprecated. Returns the FQN this lock, may be null. |
LockMap |
getLockMap()
Deprecated. |
Node |
getNode()
Deprecated. Returns the node for this lock, may be null. |
Collection<Object> |
getReaderOwners()
Deprecated. Return a copy of the reader lock owner in List. |
Object |
getWriterOwner()
Deprecated. Return the writer lock owner object. |
boolean |
isLocked()
Deprecated. Check if there is a read or write lock |
boolean |
isOwner(Object o)
Deprecated. Am I a lock owner? |
boolean |
isReadLocked()
Deprecated. Check if there is a read lock. |
boolean |
isWriteLocked()
Deprecated. Check if there is a write lock. |
void |
printLockInfo(StringBuilder sb,
int indent)
Deprecated. |
void |
release(Object caller)
Deprecated. Release the lock held by the owner. |
void |
releaseAll()
Deprecated. Release all locks associated with this instance. |
void |
releaseAll(Object owner)
Deprecated. Releases all locks with this owner. |
void |
releaseForce()
Deprecated. Same as releaseAll now. |
String |
toString()
Deprecated. |
String |
toString(boolean print_lock_details)
Deprecated. |
void |
toString(StringBuilder sb)
Deprecated. |
void |
toString(StringBuilder sb,
boolean print_lock_details)
Deprecated. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public IdentityLock(LockStrategyFactory factory,
NodeSPI node)
factory - to create lock strategiesnode - to lock| Method Detail |
|---|
public Node getNode()
null.
public Fqn getFqn()
null.
getFqn in interface NodeLockpublic Collection<Object> getReaderOwners()
getReaderOwners in interface NodeLockpublic Object getWriterOwner()
getWriterOwner in interface NodeLockpublic LockMap getLockMap()
public boolean acquireWriteLock(Object caller,
long timeout)
throws LockingException,
TimeoutException,
InterruptedException
timeout milliseconds.
Note that if the current owner owns a read lock, it will be upgraded
automatically. However, if upgrade fails, i.e., timeout, the read lock will
be released automatically.
acquireWriteLock in interface NodeLockcaller - Can't be null.timeout -
LockingException
TimeoutException
InterruptedException
public boolean acquireReadLock(Object caller,
long timeout)
throws LockingException,
TimeoutException,
InterruptedException
timeout milliseconds.
acquireReadLock in interface NodeLockcaller - Can't be null.timeout -
LockingException
TimeoutException
InterruptedExceptionpublic void release(Object caller)
release in interface NodeLockcaller - Can't be null.public void releaseAll()
releaseAll in interface NodeLockpublic void releaseForce()
public boolean isReadLocked()
isReadLocked in interface NodeLockpublic boolean isWriteLocked()
isWriteLocked in interface NodeLockpublic boolean isLocked()
isLocked in interface NodeLockpublic boolean isOwner(Object o)
isOwner in interface NodeLocko - public String toString()
toString in class Objectpublic String toString(boolean print_lock_details)
public void toString(StringBuilder sb)
public void toString(StringBuilder sb,
boolean print_lock_details)
public boolean acquire(Object caller,
long timeout,
LockType lock_type)
throws LockingException,
TimeoutException,
InterruptedException
acquire in interface NodeLockLockingException
TimeoutException
InterruptedException
public Set<NodeLock> acquireAll(Object caller,
long timeout,
LockType lock_type)
throws LockingException,
TimeoutException,
InterruptedException
NodeLock
acquireAll in interface NodeLockcaller - lock ownertimeout - time to waitlock_type - type of lock
LockingException
TimeoutException
InterruptedException
public Set<NodeLock> acquireAll(Object caller,
long timeout,
LockType lock_type,
boolean excludeInternalFqns)
throws LockingException,
TimeoutException,
InterruptedException
NodeLockNodeLock.acquire(Object, long, LockType) except that you can
optionally specify that internal Fqns - such as buddy backup subtrees - can be excluded when acquiring locks.
acquireAll in interface NodeLockcaller - lock ownertimeout - time to waitlock_type - type of lockexcludeInternalFqns - if true, locks on internal fqns are not acquired.
LockingException
TimeoutException
InterruptedExceptionpublic void releaseAll(Object owner)
NodeLock
releaseAll in interface NodeLock
public void printLockInfo(StringBuilder sb,
int indent)
printLockInfo in interface NodeLock
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||