public class LockManagerImpl extends Object implements LockManager
| Modifier and Type | Field and Description |
|---|---|
protected Configuration |
configuration |
protected LockContainer<?> |
lockContainer |
protected static boolean |
trace |
| Constructor and Description |
|---|
LockManagerImpl() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
acquireLock(InvocationContext ctx,
Object key)
Attempts to lock an entry if the lock isn't already held in the current scope, and records the lock in the
context.
|
boolean |
acquireLock(InvocationContext ctx,
Object key,
long timeoutMillis) |
boolean |
acquireLockNoCheck(InvocationContext ctx,
Object key)
Same as
LockManager.acquireLock(org.infinispan.context.InvocationContext, Object), but doesn't check whether the
lock is already acquired by the caller. |
int |
getConcurrencyLevel() |
protected long |
getLockAcquisitionTimeout(InvocationContext ctx) |
int |
getLockId(Object key)
Returns the 'id' of the lock that will be used to guard access to a given key in the cache.
|
int |
getNumberOfLocksAvailable() |
int |
getNumberOfLocksHeld()
Retrieves the number of locks currently held.
|
Object |
getOwner(Object key)
Retrieves the write lock owner, if any, for the specified cache entry.
|
void |
injectDependencies(Configuration configuration,
LockContainer<?> lockContainer) |
boolean |
isLocked(Object key)
Returns true if the cache entry is locked (either for reading or writing) by anyone, and false otherwise.
|
boolean |
lockAndRecord(Object key,
InvocationContext ctx,
long timeoutMillis)
Acquires a lock of type lockType, on a specific entry in the cache.
|
boolean |
ownsLock(Object key,
Object owner)
Tests whether a given owner owns a lock of lockType on a particular cache entry.
|
boolean |
possiblyLocked(CacheEntry entry)
Inspects the entry for signs that it is possibly locked, and hence would need to be unlocked.
|
String |
printLockInfo()
Prints lock information for all locks.
|
void |
unlock(Collection<Object> lockedKeys,
Object lockOwner)
Releases the lock passed in.
|
void |
unlockAll(InvocationContext ctx)
Releases locks present in an invocation context and transaction entry, if one is available.
|
protected Configuration configuration
protected volatile LockContainer<?> lockContainer
protected static final boolean trace
public void injectDependencies(Configuration configuration, LockContainer<?> lockContainer)
public boolean lockAndRecord(Object key, InvocationContext ctx, long timeoutMillis) throws InterruptedException
LockManagerConfiguration.getLockAcquisitionTimeout().
lockAndRecord in interface LockManagerkey - key to lockctx - invocation context associated with this invocationInterruptedException - if interruptedprotected long getLockAcquisitionTimeout(InvocationContext ctx)
public void unlock(Collection<Object> lockedKeys, Object lockOwner)
LockManagerunlock in interface LockManagerpublic void unlockAll(InvocationContext ctx)
LockManagerunlockAll in interface LockManagerctx - invocation context to inspectpublic boolean ownsLock(Object key, Object owner)
LockManagerownsLock in interface LockManagerowner - ownerpublic boolean isLocked(Object key)
LockManagerisLocked in interface LockManagerpublic Object getOwner(Object key)
LockManagergetOwner in interface LockManagerpublic String printLockInfo()
LockManagerprintLockInfo in interface LockManagerpublic final boolean possiblyLocked(CacheEntry entry)
LockManagerpossiblyLocked in interface LockManagerentry - entry to inspectpublic int getConcurrencyLevel()
public int getNumberOfLocksHeld()
LockManagergetNumberOfLocksHeld in interface LockManagerpublic int getNumberOfLocksAvailable()
public int getLockId(Object key)
LockManagergetLockId in interface LockManagerkey - key to test forpublic final boolean acquireLock(InvocationContext ctx, Object key) throws InterruptedException, TimeoutException
LockManageracquireLock in interface LockManagerctx - contextkey - Key to lockInterruptedException - if interruptedTimeoutException - if we are unable to acquire the lock after a specified timeout.public boolean acquireLock(InvocationContext ctx, Object key, long timeoutMillis) throws InterruptedException, TimeoutException
acquireLock in interface LockManagerInterruptedExceptionTimeoutExceptionpublic final boolean acquireLockNoCheck(InvocationContext ctx, Object key) throws InterruptedException, TimeoutException
LockManagerLockManager.acquireLock(org.infinispan.context.InvocationContext, Object), but doesn't check whether the
lock is already acquired by the caller. Useful in the case of transactions that use OwnableReentrantLocks
,as these locks already perform this check internally.acquireLockNoCheck in interface LockManagerInterruptedExceptionTimeoutExceptionCopyright © 2012 JBoss by Red Hat. All Rights Reserved.