@Deprecated public class IdentityLock extends Object implements NodeLock
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 and Description |
|---|
IdentityLock(LockStrategyFactory factory,
NodeSPI node)
Deprecated.
Creates a new IdentityLock using the LockFactory passed in.
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
public IdentityLock(LockStrategyFactory factory, NodeSPI node)
factory - to create lock strategiesnode - to lockpublic Node getNode()
null.public Fqn getFqn()
null.public 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 - LockingExceptionTimeoutExceptionInterruptedExceptionpublic boolean acquireReadLock(Object caller, long timeout) throws LockingException, TimeoutException, InterruptedException
timeout milliseconds.acquireReadLock in interface NodeLockcaller - Can't be null.timeout - LockingExceptionTimeoutExceptionInterruptedExceptionpublic void release(Object caller)
public void releaseAll()
releaseAll in interface NodeLockpublic void releaseForce()
public boolean isReadLocked()
isReadLocked in interface NodeLockpublic boolean isWriteLocked()
isWriteLocked in interface NodeLockpublic boolean isLocked()
public boolean isOwner(Object o)
public 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 NodeLockLockingExceptionTimeoutExceptionInterruptedExceptionpublic Set<NodeLock> acquireAll(Object caller, long timeout, LockType lock_type) throws LockingException, TimeoutException, InterruptedException
NodeLockacquireAll in interface NodeLockcaller - lock ownertimeout - time to waitlock_type - type of lockLockingExceptionTimeoutExceptionInterruptedExceptionpublic 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.LockingExceptionTimeoutExceptionInterruptedExceptionpublic void releaseAll(Object owner)
NodeLockreleaseAll in interface NodeLockpublic void printLockInfo(StringBuilder sb, int indent)
printLockInfo in interface NodeLockCopyright © 2012 JBoss, a division of Red Hat. All Rights Reserved.