|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.ojb.broker.locking.LockManagerInMemoryImpl
public class LockManagerInMemoryImpl
This implementation of the LockManager
interface supports a simple, fast, non-blocking
pessimistic locking for single JVM applications.
Nested Class Summary | |
---|---|
(package private) class |
LockManagerInMemoryImpl.LockEntry
A lock entry encapsulates locking information. |
(package private) static class |
LockManagerInMemoryImpl.ObjectLocks
|
Field Summary | |
---|---|
private static long |
CLEANUP_FREQUENCY
|
private LockIsolationManager |
lockStrategyManager
|
private HashMap |
locktable
MBAIRD: a LinkedHashMap returns objects in the order you put them in, while still maintaining an O(1) lookup like a normal hashmap. |
private long |
lockTimeout
|
private Logger |
log
|
private long |
m_lastCleanupAt
|
private static int |
MAX_LOCKS_TO_CLEAN
|
private long |
timeoutCounterRead
|
private long |
timeoutCounterWrite
|
Fields inherited from interface org.apache.ojb.broker.locking.LockManager |
---|
DEFAULT_BLOCK_TIMEOUT, DEFAULT_LOCK_TIMEOUT |
Fields inherited from interface org.apache.ojb.broker.locking.IsolationLevels |
---|
IL_DEFAULT, IL_NONE, IL_OPTIMISTIC, IL_READ_COMMITTED, IL_READ_UNCOMMITTED, IL_REPEATABLE_READ, IL_SERIALIZABLE, LITERAL_IL_NONE, LITERAL_IL_OPTIMISTIC, LITERAL_IL_READ_COMMITTED, LITERAL_IL_READ_UNCOMMITTED, LITERAL_IL_REPEATABLE_READ, LITERAL_IL_SERIALIZABLE |
Constructor Summary | |
---|---|
LockManagerInMemoryImpl()
|
Method Summary | |
---|---|
private boolean |
addReaderIfPossibleInternal(LockManagerInMemoryImpl.LockEntry reader,
boolean allowMultipleReader,
boolean allowReaderWhenWriteLock)
|
private void |
checkTimedOutLocks()
|
long |
getBlockTimeout()
NOOP |
String |
getLockInfo()
Returns info about the used lock manager implementation and the state of the lock manager. |
long |
getLockTimeout()
Get the current used lock timeout value in milliseconds. |
boolean |
hasRead(Object key,
Object resourceId)
Checks if there is a read lock for owner key on resource object. |
private boolean |
hasReadLockInternal(Object resourceId,
Object key)
|
boolean |
hasUpgrade(Object key,
Object resourceId)
Checks if there is a upgrade lock for lock key on resource object. |
boolean |
hasWrite(Object key,
Object resourceId)
Checks if there is a write lock for lock key on resource object. |
private boolean |
hasWriteLockInternal(Object resourceId,
Object key)
|
int |
lockedObjects()
|
boolean |
readLock(Object key,
Object resourceId,
int isolationLevel)
Acquires a readlock for lock key on resource object. |
boolean |
releaseLock(Object key,
Object resourceId)
Releases a lock for lock key on resource object. |
void |
releaseLocks(Object key)
Release all resource locks hold by the specified owner key. |
private void |
releaseLocksInternal(Object key)
|
boolean |
removeReader(Object key,
Object resourceId)
Remove an read lock. |
private void |
removeTimedOutLocks(long timeout)
removes all timed out lock entries from the persistent storage. |
boolean |
removeWriter(Object key,
Object resourceId)
Remove an write lock. |
void |
setBlockTimeout(long timeout)
NOOP |
void |
setLockTimeout(long timeout)
Set the lock timeout value in milliseconds. |
private boolean |
setWriterIfPossibleInternal(LockManagerInMemoryImpl.LockEntry writer,
boolean allowReaders)
|
boolean |
upgradeLock(Object key,
Object resourceId,
int isolationLevel)
Acquire an upgrade lock. |
boolean |
writeLock(Object key,
Object resourceId,
int isolationLevel)
Acquires a write lock for lock key on resource object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private Logger log
private static long CLEANUP_FREQUENCY
private static int MAX_LOCKS_TO_CLEAN
private HashMap locktable
private LockIsolationManager lockStrategyManager
private long m_lastCleanupAt
private long lockTimeout
private long timeoutCounterRead
private long timeoutCounterWrite
Constructor Detail |
---|
public LockManagerInMemoryImpl()
Method Detail |
---|
public long getLockTimeout()
LockManager
getLockTimeout
in interface LockManager
public void setLockTimeout(long timeout)
LockManager
setLockTimeout
in interface LockManager
timeout
- The lock timeout in ms of acquired read/write/upgrade locks.public long getBlockTimeout()
getBlockTimeout
in interface LockManager
public void setBlockTimeout(long timeout)
setBlockTimeout
in interface LockManager
timeout
- The time to wait for acquire a lock.public String getLockInfo()
LockManager
getLockInfo
in interface LockManager
public boolean readLock(Object key, Object resourceId, int isolationLevel)
LockManager
readLock
in interface LockManager
key
- The owner key of the lock.resourceId
- The resource to lock.isolationLevel
- The isolation level of the lock.
private boolean addReaderIfPossibleInternal(LockManagerInMemoryImpl.LockEntry reader, boolean allowMultipleReader, boolean allowReaderWhenWriteLock)
public boolean removeReader(Object key, Object resourceId)
public boolean removeWriter(Object key, Object resourceId)
public boolean releaseLock(Object key, Object resourceId)
LockManager
releaseLock
in interface LockManager
key
- The owner key of the lock.resourceId
- The resource to release.
public void releaseLocks(Object key)
LockManager
releaseLocks
in interface LockManager
key
- The owner key to release all associated locks.LockManager.releaseLocks(Object)
private void releaseLocksInternal(Object key)
public boolean writeLock(Object key, Object resourceId, int isolationLevel)
LockManager
writeLock
in interface LockManager
key
- The owner key of the lock.resourceId
- The resource to lock.isolationLevel
- The isolation level of the lock.
private boolean setWriterIfPossibleInternal(LockManagerInMemoryImpl.LockEntry writer, boolean allowReaders)
public boolean upgradeLock(Object key, Object resourceId, int isolationLevel)
LockManager
upgradeLock
in interface LockManager
key
- The owner key of the lock.resourceId
- The resource to lock.isolationLevel
- The isolation level of the lock.
public boolean hasWrite(Object key, Object resourceId)
LockManager
hasWrite
in interface LockManager
key
- The owner key of the lock.resourceId
- The resource to check.
LockManager.hasWrite(Object, Object)
private boolean hasWriteLockInternal(Object resourceId, Object key)
public boolean hasUpgrade(Object key, Object resourceId)
LockManager
hasUpgrade
in interface LockManager
key
- The owner key of the lock.resourceId
- The resource to check.
public boolean hasRead(Object key, Object resourceId)
LockManager
hasRead
in interface LockManager
key
- The owner key of the lock.resourceId
- The resource to check.
LockManager.hasRead(Object, Object)
private boolean hasReadLockInternal(Object resourceId, Object key)
public int lockedObjects()
private void checkTimedOutLocks()
private void removeTimedOutLocks(long timeout)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |