|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jboss.cache.lock.NodeBasedLockManager
public class NodeBasedLockManager
Field Summary | |
---|---|
protected Configuration |
configuration
|
protected DataContainerImpl |
dataContainer
|
protected long |
lockAcquisitionTimeout
|
protected NodeSPI |
rootNode
|
Constructor Summary | |
---|---|
NodeBasedLockManager()
|
Method Summary | |
---|---|
Object |
getLockOwner(InvocationContext ctx)
Determines the owner to be used when obtaining locks, given an invocation context. |
Collection<Object> |
getReadOwners(Fqn f)
Retrieves the read lock owners, if any, for the current Fqn. |
Collection<Object> |
getReadOwners(NodeSPI node)
Retrieves the read lock owners, if any, for the current Fqn. |
Object |
getWriteOwner(Fqn f)
Retrieves the write lock owner, if any, for the current Fqn. |
Object |
getWriteOwner(NodeSPI node)
Retrieves the write lock owner, if any, for the current Fqn. |
void |
inject(Configuration configuration,
DataContainerImpl dataContainer)
|
boolean |
isLocked(NodeSPI n)
Returns true if the node is locked (either for reading or writing) by anyone, and false otherwise. |
boolean |
isLocked(NodeSPI n,
LockType type)
Returns true if the node is locked (either for reading or writing) by anyone, and false otherwise. |
boolean |
lock(Fqn fqn,
LockType lockType,
Object owner)
Acquires a lock of type lockType, for a given owner, on a specific Node in the cache, denoted by fqn. |
boolean |
lock(Fqn fqn,
LockType lockType,
Object owner,
long timeout)
Acquires a lock of type lockType, for a given owner, on a specific Node in the cache, denoted by fqn. |
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 |
lockAll(NodeSPI node,
LockType lockType,
Object owner)
Locks the node and all child nodes, acquiring lock of type specified for the owner specified. |
boolean |
lockAll(NodeSPI node,
LockType lockType,
Object owner,
long timeout)
Locks the node and all child nodes, acquiring lock of type specified for the owner specified. |
boolean |
lockAll(NodeSPI node,
LockType lockType,
Object owner,
long timeout,
boolean excludeInternalFqns)
Locks the node and all child nodes, acquiring lock of type specified for the owner specified. |
boolean |
lockAllAndRecord(Fqn fqn,
LockType lockType,
InvocationContext ctx)
Locks the node and all child nodes, acquiring lock of type specified for the owner specified. |
boolean |
lockAllAndRecord(NodeSPI node,
LockType lockType,
InvocationContext ctx)
Locks the node and all child nodes, acquiring lock of type specified for the owner specified. |
boolean |
lockAndRecord(Fqn fqn,
LockType lockType,
InvocationContext ctx)
Acquires a lock of type lockType, on a specific Node in the cache, denoted by 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(Fqn fqn,
LockType lockType,
Object owner)
Tests whether a given owner owns a lock of lockType on a particular Fqn. |
boolean |
ownsLock(Fqn fqn,
Object owner)
Tests whether a given owner owns any sort of lock on a particular Fqn. |
boolean |
ownsLock(NodeSPI node,
Object owner)
Tests whether a given owner owns any sort of lock on a particular Fqn. |
String |
printLockInfo(NodeSPI node)
Prints lock information about a node (and it's children) to a String. |
void |
setRootNode()
|
void |
unlock(Fqn fqn,
Object owner)
Releases the lock passed in, held by the specified owner |
void |
unlock(InvocationContext ctx)
Releases locks present in an invocation context and transaction entry, if one is available. |
void |
unlock(NodeSPI node,
Object owner)
Releases the lock passed in, held by the specified owner |
void |
unlockAll(NodeSPI node)
Releases locks on a given node and all children for all owners. |
void |
unlockAll(NodeSPI node,
Object owner)
Releases locks on a given node and all children for a given owner. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Configuration configuration
protected long lockAcquisitionTimeout
protected DataContainerImpl dataContainer
protected NodeSPI rootNode
Constructor Detail |
---|
public NodeBasedLockManager()
Method Detail |
---|
public void inject(Configuration configuration, DataContainerImpl dataContainer)
public void setRootNode()
public Object getLockOwner(InvocationContext ctx)
LockManager
GlobalTransaction
if one
is present in the context, or Thread.currentThread()
if one is not present.
getLockOwner
in interface LockManager
ctx
- invocation context
public boolean lock(Fqn fqn, LockType lockType, Object owner)
LockManager
Configuration.getLockAcquisitionTimeout()
milliseconds and give up if it is unable to acquire the required lock.
lock
in interface LockManager
fqn
- Fqn to locklockType
- type of lock to acquireowner
- owner to acquire the lock for
public boolean lock(Fqn fqn, LockType lockType, Object owner, long timeout)
LockManager
lock
in interface LockManager
fqn
- Fqn to locklockType
- type of lock to acquireowner
- owner to acquire the lock fortimeout
- maximum length of time to wait for (in millis)
public boolean lock(NodeSPI node, LockType lockType, Object owner)
LockManager
LockManager.lock(org.jboss.cache.Fqn, LockType, Object)
except that a NodeSPI is passed in instead of an Fqn.
lock
in interface LockManager
node
- node to locklockType
- type of lock to acquireowner
- owner to acquire the lock for
public boolean lock(NodeSPI node, LockType lockType, Object owner, long timeout)
LockManager
LockManager.lock(org.jboss.cache.Fqn, LockType, Object, long)
except that a NodeSPI is passed in instead of an Fqn.
lock
in interface LockManager
node
- node to locklockType
- type of lock to acquireowner
- owner to acquire the lock fortimeout
- maximum length of time to wait for (in millis)
public boolean lockAndRecord(Fqn fqn, LockType lockType, InvocationContext ctx)
LockManager
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 using InvocationContext.addInvocationLockAcquired(NodeLock)
if you are not running in a transaction, or using TransactionEntry.addLock(NodeLock)
if you are.
The owner for the lock is determined by passing the invocation context to LockManager.getLockOwner(org.jboss.cache.InvocationContext)
.
lockAndRecord
in interface LockManager
fqn
- Fqn to locklockType
- type of lock to acquirectx
- invocation context associated with this invocation
public boolean lockAndRecord(NodeSPI node, LockType lockType, InvocationContext ctx)
LockManager
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 using InvocationContext.addInvocationLockAcquired(NodeLock)
if you are not running in a transaction, or using TransactionEntry.addLock(NodeLock)
if you are.
The owner for the lock is determined by passing the invocation context to LockManager.getLockOwner(org.jboss.cache.InvocationContext)
.
lockAndRecord
in interface LockManager
node
- Fqn to locklockType
- type of lock to acquirectx
- invocation context associated with this invocation
public void unlock(InvocationContext ctx)
LockManager
LockManager.getLockOwner(org.jboss.cache.InvocationContext)
unlock
in interface LockManager
ctx
- invocation context to inspectpublic void unlock(Fqn fqn, Object owner)
LockManager
unlock
in interface LockManager
fqn
- Fqn of the node to unlockowner
- lock ownerpublic void unlock(NodeSPI node, Object owner)
LockManager
unlock
in interface LockManager
node
- Node to unlockowner
- lock ownerpublic boolean lockAll(NodeSPI node, LockType lockType, Object owner)
LockManager
Configuration.getLockAcquisitionTimeout()
milliseconds and give up if it is unable to acquire the required lock.
lockAll
in interface LockManager
node
- Node to locklockType
- type of lock to acquireowner
- owner to acquire the lock for
public boolean lockAll(NodeSPI node, LockType lockType, Object owner, long timeout)
LockManager
lockAll
in interface LockManager
node
- Node to locklockType
- type of lock to acquireowner
- owner to acquire the lock fortimeout
- maximum length of time to wait for (in millis)
public boolean lockAll(NodeSPI node, LockType lockType, Object owner, long timeout, boolean excludeInternalFqns)
LockManager
lockAll
in interface LockManager
node
- Node to locklockType
- type of lock to acquireowner
- owner to acquire the lock fortimeout
- maximum length of time to wait for (in millis)excludeInternalFqns
- if true, any Fqns that are internal are excluded.
public boolean lockAllAndRecord(Fqn fqn, LockType lockType, InvocationContext ctx)
LockManager
InvocationContext.addInvocationLockAcquired(NodeLock)
if you are not running in a transaction, or using TransactionEntry.addLock(NodeLock)
if you are.
The owner for the lock is determined by passing the invocation context to LockManager.getLockOwner(org.jboss.cache.InvocationContext)
.
lockAllAndRecord
in interface LockManager
fqn
- Node to locklockType
- type of lock to acquirectx
- invocation context associated with this invocation
public boolean lockAllAndRecord(NodeSPI node, LockType lockType, InvocationContext ctx)
LockManager
InvocationContext.addInvocationLockAcquired(NodeLock)
if you are not running in a transaction, or using TransactionEntry.addLock(NodeLock)
if you are.
The owner for the lock is determined by passing the invocation context to LockManager.getLockOwner(org.jboss.cache.InvocationContext)
.
lockAllAndRecord
in interface LockManager
node
- Node to locklockType
- type of lock to acquirectx
- invocation context associated with this invocation
public void unlockAll(NodeSPI node, Object owner)
LockManager
unlockAll
in interface LockManager
node
- node to unlockowner
- lock ownerpublic void unlockAll(NodeSPI node)
LockManager
unlockAll
in interface LockManager
node
- node to unlockpublic boolean ownsLock(Fqn fqn, LockType lockType, Object owner)
LockManager
ownsLock
in interface LockManager
fqn
- fqn to testlockType
- type of lock to test forowner
- owner
public boolean ownsLock(Fqn fqn, Object owner)
LockManager
ownsLock
in interface LockManager
fqn
- fqn to testowner
- owner
public boolean ownsLock(NodeSPI node, Object owner)
LockManager
ownsLock
in interface LockManager
node
- to testowner
- owner
public boolean isLocked(NodeSPI n)
LockManager
isLocked
in interface LockManager
n
- node to inspect
public boolean isLocked(NodeSPI n, LockType type)
LockManager
isLocked
in interface LockManager
n
- node to inspecttype
- lockType to test for
public Object getWriteOwner(Fqn f)
LockManager
getWriteOwner
in interface LockManager
f
- Fqn to inspect
public Collection<Object> getReadOwners(Fqn f)
LockManager
getReadOwners
in interface LockManager
f
- Fqn to inspect
public Object getWriteOwner(NodeSPI node)
LockManager
getWriteOwner
in interface LockManager
node
- the node to inspect
public Collection<Object> getReadOwners(NodeSPI node)
LockManager
getReadOwners
in interface LockManager
node
- the node to inspect
public String printLockInfo(NodeSPI node)
LockManager
printLockInfo
in interface LockManager
node
- node to inspect
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |