org.jboss.cache.lock
Interface NodeLock

All Known Implementing Classes:
IdentityLock

public interface NodeLock

Interface for a lock for nodes.


Method Summary
 boolean acquire(Object caller, long timeout, LockType lock_type)
           
 Set<NodeLock> acquireAll(Object caller, long timeout, LockType lock_type)
          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)
          Same as the overloaded 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)
          Acquires a read lock with a timeout period of timeout milliseconds.
 boolean acquireWriteLock(Object caller, long timeout)
          Acquires a write lock with a timeout of timeout milliseconds.
 Fqn getFqn()
           
 Collection<Object> getReaderOwners()
          Returns a copy of the reader lock owner in List.
 Object getWriterOwner()
          Returns the writer lock owner object.
 boolean isLocked()
          Check if there is a read or write lock
 boolean isOwner(Object o)
          Returns true if the object is the lock owner.
 boolean isReadLocked()
          Check if there is a read lock.
 boolean isWriteLocked()
          Check if there is a write lock.
 void printLockInfo(StringBuilder sb, int indent)
           
 void release(Object caller)
          Releases the lock held by the owner.
 void releaseAll()
          Releases all locks associated with this instance.
 void releaseAll(Object owner)
          Releases all locks with this owner.
 

Method Detail

getFqn

Fqn getFqn()

getReaderOwners

Collection<Object> getReaderOwners()
Returns a copy of the reader lock owner in List. Size is zero is not available. Note that this list is synchronized.

Returns:
Collection of readers

getWriterOwner

Object getWriterOwner()
Returns the writer lock owner object. Null if not available.

Returns:
Object owner

acquireWriteLock

boolean acquireWriteLock(Object caller,
                         long timeout)
                         throws LockingException,
                                TimeoutException,
                                InterruptedException
Acquires a write lock with a timeout of 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.

Parameters:
caller - Can't be null.
timeout -
Returns:
boolean True if lock was acquired and was not held before, false if lock was held
Throws:
LockingException
TimeoutException
InterruptedException

acquireReadLock

boolean acquireReadLock(Object caller,
                        long timeout)
                        throws LockingException,
                               TimeoutException,
                               InterruptedException
Acquires a read lock with a timeout period of timeout milliseconds.

Parameters:
caller - Can't be null.
timeout -
Returns:
boolean True if lock was acquired and was not held before, false if lock was held
Throws:
LockingException
TimeoutException
InterruptedException

release

void release(Object caller)
Releases the lock held by the owner.

Parameters:
caller - Can't be null.

releaseAll

void releaseAll()
Releases all locks associated with this instance.


releaseAll

void releaseAll(Object owner)
Releases all locks with this owner.


isReadLocked

boolean isReadLocked()
Check if there is a read lock.


isWriteLocked

boolean isWriteLocked()
Check if there is a write lock.


isLocked

boolean isLocked()
Check if there is a read or write lock


isOwner

boolean isOwner(Object o)
Returns true if the object is the lock owner.


acquire

boolean acquire(Object caller,
                long timeout,
                LockType lock_type)
                throws LockingException,
                       TimeoutException,
                       InterruptedException
Throws:
LockingException
TimeoutException
InterruptedException

acquireAll

Set<NodeLock> acquireAll(Object caller,
                         long timeout,
                         LockType lock_type)
                         throws LockingException,
                                TimeoutException,
                                InterruptedException
Recursively acquire locks for this node and all subnodes, including internal Fqns such as buddy backup subtrees.

Parameters:
caller - lock owner
timeout - time to wait
lock_type - type of lock
Returns:
locks acquired
Throws:
LockingException
TimeoutException
InterruptedException

acquireAll

Set<NodeLock> acquireAll(Object caller,
                         long timeout,
                         LockType lock_type,
                         boolean excludeInternalFqns)
                         throws LockingException,
                                TimeoutException,
                                InterruptedException
Same as the overloaded acquire(Object, long, LockType) except that you can optionally specify that internal Fqns - such as buddy backup subtrees - can be excluded when acquiring locks.

Parameters:
caller - lock owner
timeout - time to wait
lock_type - type of lock
excludeInternalFqns - if true, locks on internal fqns are not acquired.
Returns:
locks acquired
Throws:
LockingException
TimeoutException
InterruptedException

printLockInfo

void printLockInfo(StringBuilder sb,
                   int indent)


Copyright © 2009 JBoss, a division of Red Hat. All Rights Reserved.