|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.manifoldcf.core.lockmanager.LockManager
public class LockManager
The lock manager manages locks across all threads and JVMs and cluster members. There should be no more than ONE instance of this class per thread!!! The factory should enforce this.
| Nested Class Summary | |
|---|---|
protected static class |
LockManager.ByteArrayBuffer
|
protected class |
LockManager.LocalLock
|
protected class |
LockManager.LockDescription
|
| Field Summary | |
|---|---|
static java.lang.String |
_rcsid
|
protected static int |
BASE_SIZE
|
protected static java.util.HashMap |
globalData
Global resource data. |
protected static java.util.HashMap |
globalFlags
Global flag information. |
protected java.util.HashMap |
localLocks
|
protected java.util.HashMap |
localSections
|
protected static LockPool |
myLocks
|
protected static LockPool |
mySections
|
protected java.io.File |
synchDirectory
|
static java.lang.String |
synchDirectoryProperty
Synchronization directory property - local to this implementation of ILockManager |
protected static int |
TYPE_READ
|
protected static int |
TYPE_WRITE
|
protected static int |
TYPE_WRITENONEX
|
| Constructor Summary | |
|---|---|
LockManager()
|
|
| Method Summary | |
|---|---|
boolean |
checkGlobalFlag(java.lang.String flagName)
Check the condition of a specified flag. |
void |
clearGlobalFlag(java.lang.String flagName)
Clear a flag. |
void |
clearLocks()
Clear all outstanding locks in the system. |
void |
enterCriticalSections(java.lang.String[] readSectionKeys,
java.lang.String[] nonExSectionKeys,
java.lang.String[] writeSectionKeys)
Enter multiple critical sections simultaneously. |
void |
enterLocks(java.lang.String[] readLocks,
java.lang.String[] nonExWriteLocks,
java.lang.String[] writeLocks)
Enter multiple locks |
void |
enterLocksNoWait(java.lang.String[] readLocks,
java.lang.String[] nonExWriteLocks,
java.lang.String[] writeLocks)
Enter multiple locks simultaneously. |
void |
enterNonExWriteCriticalSection(java.lang.String sectionKey)
Enter a named, non-exclusive write critical section (NOT a lock). |
void |
enterNonExWriteLock(java.lang.String lockKey)
Enter a non-exclusive write-locked area (blocking out all readers, but letting in other "writers"). |
void |
enterNonExWriteLockNoWait(java.lang.String lockKey)
Enter a non-exclusive write-locked area (blocking out all readers, but letting in other "writers"). |
void |
enterReadCriticalSection(java.lang.String sectionKey)
Enter a named, read critical section (NOT a lock). |
void |
enterReadLock(java.lang.String lockKey)
Enter a read-only locked area (i.e., block ONLY if there's a writer) |
void |
enterReadLockNoWait(java.lang.String lockKey)
Enter a read-only locked area (i.e., block ONLY if there's a writer). |
void |
enterWriteCriticalSection(java.lang.String sectionKey)
Enter a named, exclusive critical section (NOT a lock). |
void |
enterWriteLock(java.lang.String lockKey)
Enter a write locked area (i.e., block out both readers and other writers) NOTE: Can't enter until all readers have left. |
void |
enterWriteLockNoWait(java.lang.String lockKey)
Enter a write locked code area (i.e., block out both readers and other writers), but do not wait if the lock cannot be obtained. |
protected static java.lang.String |
getFlagResourceName(java.lang.String flagName)
Calculate the name of a flag resource. |
protected LockManager.LocalLock |
getLocalLock(java.lang.String lockKey)
|
protected LockManager.LocalLock |
getLocalSection(java.lang.String sectionKey)
|
protected LockManager.LockDescription[] |
getSortedUniqueLocks(java.lang.String[] readLocks,
java.lang.String[] writeNonExLocks,
java.lang.String[] writeLocks)
Process inbound locks into a sorted vector of most-restrictive unique locks |
void |
leaveCriticalSections(java.lang.String[] readSectionKeys,
java.lang.String[] nonExSectionKeys,
java.lang.String[] writeSectionKeys)
Leave multiple critical sections simultaneously. |
void |
leaveLocks(java.lang.String[] readLocks,
java.lang.String[] writeNonExLocks,
java.lang.String[] writeLocks)
Leave multiple locks |
void |
leaveNonExWriteCriticalSection(java.lang.String sectionKey)
Leave a named, non-exclusive write critical section (NOT a lock). |
void |
leaveNonExWriteLock(java.lang.String lockKey)
Leave a non-exclusive write lock. |
void |
leaveReadCriticalSection(java.lang.String sectionKey)
Leave a named, read critical section (NOT a lock). |
void |
leaveReadLock(java.lang.String lockKey)
Leave a read-locked code area. |
void |
leaveWriteCriticalSection(java.lang.String sectionKey)
Leave a named, exclusive critical section (NOT a lock). |
void |
leaveWriteLock(java.lang.String lockKey)
Leave a write locked code area. |
protected java.lang.String |
makeFilePath(java.lang.String key)
Create a file path given a key name. |
byte[] |
readData(java.lang.String resourceName)
Read data from a shared data resource. |
protected void |
releaseLocalLock(java.lang.String lockKey)
|
protected void |
releaseLocalSection(java.lang.String sectionKey)
|
void |
setGlobalFlag(java.lang.String flagName)
Raise a flag. |
void |
timedWait(int time)
Wait for a time before retrying a lock. |
void |
writeData(java.lang.String resourceName,
byte[] data)
Write data to a shared data resource. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String _rcsid
public static final java.lang.String synchDirectoryProperty
protected static final int TYPE_READ
protected static final int TYPE_WRITENONEX
protected static final int TYPE_WRITE
protected java.util.HashMap localLocks
protected static LockPool myLocks
protected java.util.HashMap localSections
protected static LockPool mySections
protected java.io.File synchDirectory
protected static java.util.HashMap globalFlags
protected static java.util.HashMap globalData
protected static final int BASE_SIZE
| Constructor Detail |
|---|
public LockManager()
throws ManifoldCFException
ManifoldCFException| Method Detail |
|---|
protected static java.lang.String getFlagResourceName(java.lang.String flagName)
flagName - is the name of the flag.
public void setGlobalFlag(java.lang.String flagName)
throws ManifoldCFException
setGlobalFlag in interface ILockManagerflagName - is the name of the flag to set.
ManifoldCFException
public void clearGlobalFlag(java.lang.String flagName)
throws ManifoldCFException
clearGlobalFlag in interface ILockManagerflagName - is the name of the flag to clear.
ManifoldCFException
public boolean checkGlobalFlag(java.lang.String flagName)
throws ManifoldCFException
checkGlobalFlag in interface ILockManagerflagName - is the name of the flag to check.
ManifoldCFException
public byte[] readData(java.lang.String resourceName)
throws ManifoldCFException
readData in interface ILockManagerresourceName - is the global name of the resource.
ManifoldCFException
public void writeData(java.lang.String resourceName,
byte[] data)
throws ManifoldCFException
writeData in interface ILockManagerresourceName - is the global name of the resource.data - is the byte array containing the data. Pass null if you want to delete the resource completely.
ManifoldCFException
public void timedWait(int time)
throws ManifoldCFException
timedWait in interface ILockManagertime - is the amount of time to wait, in milliseconds. Zero is a legal
value, and will wait no time, but will give up the current timeslice to another
thread.
ManifoldCFException
public void enterNonExWriteLock(java.lang.String lockKey)
throws ManifoldCFException
enterNonExWriteLock in interface ILockManagerlockKey - is the name of the lock.
ManifoldCFException
public void enterNonExWriteLockNoWait(java.lang.String lockKey)
throws ManifoldCFException,
LockException
ILockManager
enterNonExWriteLockNoWait in interface ILockManagerlockKey - is the name of the lock.
ManifoldCFException
LockException
public void leaveNonExWriteLock(java.lang.String lockKey)
throws ManifoldCFException
leaveNonExWriteLock in interface ILockManagerlockKey - is the name of the lock.
ManifoldCFException
public void enterWriteLock(java.lang.String lockKey)
throws ManifoldCFException
enterWriteLock in interface ILockManagerlockKey - is the name of the lock.
ManifoldCFException
public void enterWriteLockNoWait(java.lang.String lockKey)
throws ManifoldCFException,
LockException
ILockManager
enterWriteLockNoWait in interface ILockManagerlockKey - is the name of the lock.
ManifoldCFException
LockException
public void leaveWriteLock(java.lang.String lockKey)
throws ManifoldCFException
ILockManager
leaveWriteLock in interface ILockManagerlockKey - is the name of the lock.
ManifoldCFException
public void enterReadLock(java.lang.String lockKey)
throws ManifoldCFException
enterReadLock in interface ILockManagerlockKey - is the name of the lock.
ManifoldCFException
public void enterReadLockNoWait(java.lang.String lockKey)
throws ManifoldCFException,
LockException
ILockManager
enterReadLockNoWait in interface ILockManagerlockKey - is the name of the lock.
ManifoldCFException
LockException
public void leaveReadLock(java.lang.String lockKey)
throws ManifoldCFException
ILockManager
leaveReadLock in interface ILockManagerlockKey - is the name of the lock.
ManifoldCFException
public void clearLocks()
throws ManifoldCFException
ILockManager
clearLocks in interface ILockManagerManifoldCFException
public void enterLocks(java.lang.String[] readLocks,
java.lang.String[] nonExWriteLocks,
java.lang.String[] writeLocks)
throws ManifoldCFException
enterLocks in interface ILockManagerreadLocks - is an array of read lock names, or null if there are no read locks desired.nonExWriteLocks - is an array of non-ex write lock names, or null if none desired.writeLocks - is an array of write lock names, or null if there are none desired.
ManifoldCFException
public void enterLocksNoWait(java.lang.String[] readLocks,
java.lang.String[] nonExWriteLocks,
java.lang.String[] writeLocks)
throws ManifoldCFException,
LockException
ILockManager
enterLocksNoWait in interface ILockManagerreadLocks - is an array of read lock names, or null if there are no read locks desired.nonExWriteLocks - is an array of non-ex write lock names, or null if none desired.writeLocks - is an array of write lock names, or null if there are none desired.
ManifoldCFException
LockException
public void leaveLocks(java.lang.String[] readLocks,
java.lang.String[] writeNonExLocks,
java.lang.String[] writeLocks)
throws ManifoldCFException
leaveLocks in interface ILockManagerreadLocks - is an array of read lock names, or null if there are no read locks desired.writeNonExLocks - is an array of non-ex write lock names, or null if none desired.writeLocks - is an array of write lock names, or null if there are none desired.
ManifoldCFException
public void enterReadCriticalSection(java.lang.String sectionKey)
throws ManifoldCFException
enterReadCriticalSection in interface ILockManagersectionKey - is the name of the section to enter. Only one thread can be in any given named
section at a time.
ManifoldCFException
public void leaveReadCriticalSection(java.lang.String sectionKey)
throws ManifoldCFException
leaveReadCriticalSection in interface ILockManagersectionKey - is the name of the section to leave. Only one thread can be in any given named
section at a time.
ManifoldCFException
public void enterNonExWriteCriticalSection(java.lang.String sectionKey)
throws ManifoldCFException
enterNonExWriteCriticalSection in interface ILockManagersectionKey - is the name of the section to enter. Only one thread can be in any given named
section at a time.
ManifoldCFException
public void leaveNonExWriteCriticalSection(java.lang.String sectionKey)
throws ManifoldCFException
leaveNonExWriteCriticalSection in interface ILockManagersectionKey - is the name of the section to leave. Only one thread can be in any given named
section at a time.
ManifoldCFException
public void enterWriteCriticalSection(java.lang.String sectionKey)
throws ManifoldCFException
enterWriteCriticalSection in interface ILockManagersectionKey - is the name of the section to enter. Only one thread can be in any given named
section at a time.
ManifoldCFException
public void leaveWriteCriticalSection(java.lang.String sectionKey)
throws ManifoldCFException
leaveWriteCriticalSection in interface ILockManagersectionKey - is the name of the section to leave. Only one thread can be in any given named
section at a time.
ManifoldCFException
public void enterCriticalSections(java.lang.String[] readSectionKeys,
java.lang.String[] nonExSectionKeys,
java.lang.String[] writeSectionKeys)
throws ManifoldCFException
enterCriticalSections in interface ILockManagerreadSectionKeys - is an array of read section descriptors, or null if there are no read sections desired.nonExSectionKeys - is an array of non-ex write section descriptors, or null if none desired.writeSectionKeys - is an array of write section descriptors, or null if there are none desired.
ManifoldCFException
public void leaveCriticalSections(java.lang.String[] readSectionKeys,
java.lang.String[] nonExSectionKeys,
java.lang.String[] writeSectionKeys)
throws ManifoldCFException
leaveCriticalSections in interface ILockManagerreadSectionKeys - is an array of read section descriptors, or null if there are no read sections desired.nonExSectionKeys - is an array of non-ex write section descriptors, or null if none desired.writeSectionKeys - is an array of write section descriptors, or null if there are none desired.
ManifoldCFExceptionprotected LockManager.LocalLock getLocalLock(java.lang.String lockKey)
protected void releaseLocalLock(java.lang.String lockKey)
protected LockManager.LocalLock getLocalSection(java.lang.String sectionKey)
protected void releaseLocalSection(java.lang.String sectionKey)
protected LockManager.LockDescription[] getSortedUniqueLocks(java.lang.String[] readLocks,
java.lang.String[] writeNonExLocks,
java.lang.String[] writeLocks)
protected java.lang.String makeFilePath(java.lang.String key)
key - is the key name.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||