org.jboss.cache.lock
Class FqnLockManager

java.lang.Object
  extended by org.jboss.cache.lock.AbstractLockManager
      extended by org.jboss.cache.lock.FqnLockManager
All Implemented Interfaces:
LockManager
Direct Known Subclasses:
MVCCLockManager

public abstract class FqnLockManager
extends AbstractLockManager

An abstract lock manager that deals with Fqns rather than nodes.

Since:
3.0
Author:
Manik Surtani (manik AT jboss DOT org)

Field Summary
 
Fields inherited from class org.jboss.cache.lock.AbstractLockManager
configuration, lockAcquisitionTimeout
 
Constructor Summary
FqnLockManager()
           
 
Method Summary
 Collection<Object> getReadOwners(NodeSPI node)
          Retrieves the read lock owners, if any, for the current Fqn.
 Object getWriteOwner(NodeSPI node)
          Retrieves the write lock owner, if any, for the current Fqn.
 boolean isLocked(NodeSPI node)
          Returns true if the node is locked (either for reading or writing) by anyone, and false otherwise.
 boolean lock(NodeSPI node, LockType lockType, Object owner)
          As LockManager.lock(org.jboss.cache.Fqn, LockType, Object) except that a NodeSPI is passed in instead of an Fqn.
 boolean lock(NodeSPI node, LockType lockType, Object owner, long timeout)
          As LockManager.lock(org.jboss.cache.Fqn, LockType, Object, long) except that a NodeSPI is passed in instead of an Fqn.
 boolean lockAndRecord(NodeSPI node, LockType lockType, InvocationContext ctx)
          Acquires a lock of type lockType, on a specific Node in the cache, denoted by fqn.
 boolean ownsLock(NodeSPI node, Object owner)
          Tests whether a given owner owns any sort of lock on a particular Fqn.
 void unlock(NodeSPI node, Object owner)
          Releases the lock passed in, held by the specified owner
 
Methods inherited from class org.jboss.cache.lock.AbstractLockManager
getLockOwner, injectConfiguration, setLockAcquisitionTimeout
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.cache.lock.LockManager
getReadOwners, getWriteOwner, isLocked, isLocked, lock, lock, lockAll, lockAll, lockAll, lockAllAndRecord, lockAllAndRecord, lockAndRecord, ownsLock, ownsLock, printLockInfo, printLockInfo, unlock, unlock, unlockAll, unlockAll
 

Constructor Detail

FqnLockManager

public FqnLockManager()
Method Detail

lock

public boolean lock(NodeSPI node,
                    LockType lockType,
                    Object owner)
             throws InterruptedException
Description copied from interface: LockManager
As LockManager.lock(org.jboss.cache.Fqn, LockType, Object) except that a NodeSPI is passed in instead of an Fqn.

Parameters:
node - node to lock
lockType - type of lock to acquire
owner - owner to acquire the lock for
Returns:
true if the lock was acquired, false otherwise.
Throws:
InterruptedException

lock

public boolean lock(NodeSPI node,
                    LockType lockType,
                    Object owner,
                    long timeout)
             throws InterruptedException
Description copied from interface: LockManager
As LockManager.lock(org.jboss.cache.Fqn, LockType, Object, long) except that a NodeSPI is passed in instead of an Fqn.

Parameters:
node - node to lock
lockType - type of lock to acquire
owner - owner to acquire the lock for
timeout - maximum length of time to wait for (in millis)
Returns:
true if the lock was acquired, false otherwise.
Throws:
InterruptedException

lockAndRecord

public boolean lockAndRecord(NodeSPI node,
                             LockType lockType,
                             InvocationContext ctx)
                      throws InterruptedException
Description copied from interface: LockManager
Acquires a lock of type lockType, on a specific Node in the cache, denoted by fqn. This method will try for a period of time and give up if it is unable to acquire the required lock. The period of time is specified in Option.getLockAcquisitionTimeout() and, if this is unset, the default timeout set in Configuration.getLockAcquisitionTimeout() is used.

In addition, any locks acquired are added to the context OR transaction entry using InvocationContext.addLock(Object).

The owner for the lock is determined by passing the invocation context to LockManager.getLockOwner(org.jboss.cache.InvocationContext).

Parameters:
node - Fqn to lock
lockType - type of lock to acquire
ctx - invocation context associated with this invocation
Returns:
true if the lock was acquired, false otherwise.
Throws:
InterruptedException

unlock

public void unlock(NodeSPI node,
                   Object owner)
Description copied from interface: LockManager
Releases the lock passed in, held by the specified owner

Parameters:
node - Node to unlock
owner - lock owner

ownsLock

public boolean ownsLock(NodeSPI node,
                        Object owner)
Description copied from interface: LockManager
Tests whether a given owner owns any sort of lock on a particular Fqn.

Parameters:
node - to test
owner - owner
Returns:
true if the owner does own the specified lock type on the specified node, false otherwise.

getWriteOwner

public Object getWriteOwner(NodeSPI node)
Description copied from interface: LockManager
Retrieves the write lock owner, if any, for the current Fqn.

Parameters:
node - the node to inspect
Returns:
the owner of the lock, or null if not locked.

getReadOwners

public Collection<Object> getReadOwners(NodeSPI node)
Description copied from interface: LockManager
Retrieves the read lock owners, if any, for the current Fqn.

Parameters:
node - the node to inspect
Returns:
a collection of read lock owners, or an empty collection if not locked.

isLocked

public boolean isLocked(NodeSPI node)
Description copied from interface: LockManager
Returns true if the node is locked (either for reading or writing) by anyone, and false otherwise.

Parameters:
node - node to inspect
Returns:
true of locked; false if not.


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