public class LockManager extends Object implements ILockManager
Modifier and Type | Field and Description |
---|---|
static String |
_rcsid |
protected ILockManager |
lockManager
Backing lock manager
|
Constructor and Description |
---|
LockManager() |
Modifier and Type | Method and Description |
---|---|
boolean |
checkGlobalFlag(String flagName)
Check the condition of a specified flag.
|
boolean |
checkServiceActive(String serviceType,
String serviceName)
Check whether a service is active or not.
|
boolean |
cleanupInactiveService(String serviceType,
IServiceCleanup cleanup)
Clean up any inactive services found.
|
void |
clearGlobalFlag(String flagName)
Clear a flag.
|
void |
clearLocks()
Clear all outstanding locks in the system.
|
int |
countActiveServices(String serviceType)
Count all active services of a given type.
|
void |
endServiceActivity(String serviceType,
String serviceName)
End service activity.
|
void |
enterCriticalSections(String[] readSectionKeys,
String[] nonExSectionKeys,
String[] writeSectionKeys)
Enter multiple critical sections simultaneously.
|
void |
enterLocks(String[] readLocks,
String[] nonExWriteLocks,
String[] writeLocks)
Enter multiple locks
|
void |
enterLocksNoWait(String[] readLocks,
String[] nonExWriteLocks,
String[] writeLocks)
Enter multiple locks simultaneously.
|
void |
enterNonExWriteCriticalSection(String sectionKey)
Enter a named, non-exclusive write critical section (NOT a lock).
|
void |
enterNonExWriteLock(String lockKey)
Enter a non-exclusive write-locked area (blocking out all readers, but letting in other "writers").
|
void |
enterNonExWriteLockNoWait(String lockKey)
Enter a non-exclusive write-locked area (blocking out all readers, but letting in other "writers").
|
void |
enterReadCriticalSection(String sectionKey)
Enter a named, read critical section (NOT a lock).
|
void |
enterReadLock(String lockKey)
Enter a read-only locked area (i.e., block ONLY if there's a writer)
|
void |
enterReadLockNoWait(String lockKey)
Enter a read-only locked area (i.e., block ONLY if there's a writer).
|
void |
enterWriteCriticalSection(String sectionKey)
Enter a named, exclusive critical section (NOT a lock).
|
void |
enterWriteLock(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(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.
|
ManifoldCFConfiguration |
getSharedConfiguration()
Get the current shared configuration.
|
void |
leaveCriticalSections(String[] readSectionKeys,
String[] nonExSectionKeys,
String[] writeSectionKeys)
Leave multiple critical sections simultaneously.
|
void |
leaveLocks(String[] readLocks,
String[] writeNonExLocks,
String[] writeLocks)
Leave multiple locks
|
void |
leaveNonExWriteCriticalSection(String sectionKey)
Leave a named, non-exclusive write critical section (NOT a lock).
|
void |
leaveNonExWriteLock(String lockKey)
Leave a non-exclusive write lock.
|
void |
leaveReadCriticalSection(String sectionKey)
Leave a named, read critical section (NOT a lock).
|
void |
leaveReadLock(String lockKey)
Leave a read-locked code area.
|
void |
leaveWriteCriticalSection(String sectionKey)
Leave a named, exclusive critical section (NOT a lock).
|
void |
leaveWriteLock(String lockKey)
Leave a write locked code area.
|
byte[] |
readData(String resourceName)
Read data from a shared data resource.
|
String |
registerServiceBeginServiceActivity(String serviceType,
String serviceName,
byte[] initialData,
IServiceCleanup cleanup)
Register a service and begin service activity.
|
String |
registerServiceBeginServiceActivity(String serviceType,
String serviceName,
IServiceCleanup cleanup)
Register a service and begin service activity.
|
byte[] |
retrieveServiceData(String serviceType,
String serviceName)
Retrieve service data for a service.
|
void |
scanServiceData(String serviceType,
IServiceDataAcceptor dataAcceptor)
Scan service data for a service type.
|
void |
setGlobalFlag(String flagName)
Raise a flag.
|
void |
timedWait(int time)
Wait for a time before retrying a lock.
|
void |
updateServiceData(String serviceType,
String serviceName,
byte[] serviceData)
Set service data for a service.
|
void |
writeData(String resourceName,
byte[] data)
Write data to a shared data resource.
|
public static final String _rcsid
protected final ILockManager lockManager
public LockManager() throws ManifoldCFException
ManifoldCFException
public String registerServiceBeginServiceActivity(String serviceType, String serviceName, IServiceCleanup cleanup) throws ManifoldCFException
registerServiceBeginServiceActivity
in interface ILockManager
serviceType
- is the type of service.serviceName
- is the name of the service to register. If null is passed, a transient unique service name will be
created, and will be returned to the caller.cleanup
- is called to clean up either the current service, or all services of this type, if no other active service exists.
May be null. Local service cleanup is never called if the serviceName argument is null.ManifoldCFException
public String registerServiceBeginServiceActivity(String serviceType, String serviceName, byte[] initialData, IServiceCleanup cleanup) throws ManifoldCFException
registerServiceBeginServiceActivity
in interface ILockManager
serviceType
- is the type of service.serviceName
- is the name of the service to register. If null is passed, a transient unique service name will be
created, and will be returned to the caller.initialData
- is the initial service data for this service.cleanup
- is called to clean up either the current service, or all services of this type, if no other active service exists.
May be null. Local service cleanup is never called if the serviceName argument is null.ManifoldCFException
public void updateServiceData(String serviceType, String serviceName, byte[] serviceData) throws ManifoldCFException
updateServiceData
in interface ILockManager
serviceType
- is the type of service.serviceName
- is the name of the service.serviceData
- is the data to update to (may be null).
This updates the service's transient data (or deletes it). If the service is not active, an exception is thrown.ManifoldCFException
public byte[] retrieveServiceData(String serviceType, String serviceName) throws ManifoldCFException
retrieveServiceData
in interface ILockManager
serviceType
- is the type of service.serviceName
- is the name of the service.ManifoldCFException
public void scanServiceData(String serviceType, IServiceDataAcceptor dataAcceptor) throws ManifoldCFException
scanServiceData
in interface ILockManager
serviceType
- is the type of service.dataAcceptor
- is the object that will be notified of each item of data for each service name found.ManifoldCFException
public boolean cleanupInactiveService(String serviceType, IServiceCleanup cleanup) throws ManifoldCFException
cleanupInactiveService
in interface ILockManager
serviceType
- is the service type.cleanup
- is the object to call to clean up an inactive service.ManifoldCFException
public int countActiveServices(String serviceType) throws ManifoldCFException
countActiveServices
in interface ILockManager
serviceType
- is the service type.ManifoldCFException
public void endServiceActivity(String serviceType, String serviceName) throws ManifoldCFException
endServiceActivity
in interface ILockManager
serviceType
- is the type of service.serviceName
- is the name of the service to exit.ManifoldCFException
public boolean checkServiceActive(String serviceType, String serviceName) throws ManifoldCFException
checkServiceActive
in interface ILockManager
serviceType
- is the type of service.serviceName
- is the name of the service to check on.ManifoldCFException
public ManifoldCFConfiguration getSharedConfiguration() throws ManifoldCFException
getSharedConfiguration
in interface ILockManager
configurationData
- is the globally-shared configuration information.ManifoldCFException
public void setGlobalFlag(String flagName) throws ManifoldCFException
setGlobalFlag
in interface ILockManager
flagName
- is the name of the flag to set.ManifoldCFException
public void clearGlobalFlag(String flagName) throws ManifoldCFException
clearGlobalFlag
in interface ILockManager
flagName
- is the name of the flag to clear.ManifoldCFException
public boolean checkGlobalFlag(String flagName) throws ManifoldCFException
checkGlobalFlag
in interface ILockManager
flagName
- is the name of the flag to check.ManifoldCFException
public byte[] readData(String resourceName) throws ManifoldCFException
readData
in interface ILockManager
resourceName
- is the global name of the resource.ManifoldCFException
public void writeData(String resourceName, byte[] data) throws ManifoldCFException
writeData
in interface ILockManager
resourceName
- 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 ILockManager
time
- 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(String lockKey) throws ManifoldCFException
enterNonExWriteLock
in interface ILockManager
lockKey
- is the name of the lock.ManifoldCFException
public void enterNonExWriteLockNoWait(String lockKey) throws ManifoldCFException, LockException
ILockManager
enterNonExWriteLockNoWait
in interface ILockManager
lockKey
- is the name of the lock.ManifoldCFException
LockException
public void leaveNonExWriteLock(String lockKey) throws ManifoldCFException
leaveNonExWriteLock
in interface ILockManager
lockKey
- is the name of the lock.ManifoldCFException
public void enterWriteLock(String lockKey) throws ManifoldCFException
enterWriteLock
in interface ILockManager
lockKey
- is the name of the lock.ManifoldCFException
public void enterWriteLockNoWait(String lockKey) throws ManifoldCFException, LockException
ILockManager
enterWriteLockNoWait
in interface ILockManager
lockKey
- is the name of the lock.ManifoldCFException
LockException
public void leaveWriteLock(String lockKey) throws ManifoldCFException
ILockManager
leaveWriteLock
in interface ILockManager
lockKey
- is the name of the lock.ManifoldCFException
public void enterReadLock(String lockKey) throws ManifoldCFException
enterReadLock
in interface ILockManager
lockKey
- is the name of the lock.ManifoldCFException
public void enterReadLockNoWait(String lockKey) throws ManifoldCFException, LockException
ILockManager
enterReadLockNoWait
in interface ILockManager
lockKey
- is the name of the lock.ManifoldCFException
LockException
public void leaveReadLock(String lockKey) throws ManifoldCFException
ILockManager
leaveReadLock
in interface ILockManager
lockKey
- is the name of the lock.ManifoldCFException
public void clearLocks() throws ManifoldCFException
ILockManager
clearLocks
in interface ILockManager
ManifoldCFException
public void enterLocks(String[] readLocks, String[] nonExWriteLocks, String[] writeLocks) throws ManifoldCFException
enterLocks
in interface ILockManager
readLocks
- 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(String[] readLocks, String[] nonExWriteLocks, String[] writeLocks) throws ManifoldCFException, LockException
ILockManager
enterLocksNoWait
in interface ILockManager
readLocks
- 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(String[] readLocks, String[] writeNonExLocks, String[] writeLocks) throws ManifoldCFException
leaveLocks
in interface ILockManager
readLocks
- 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(String sectionKey) throws ManifoldCFException
enterReadCriticalSection
in interface ILockManager
sectionKey
- 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(String sectionKey) throws ManifoldCFException
leaveReadCriticalSection
in interface ILockManager
sectionKey
- 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(String sectionKey) throws ManifoldCFException
enterNonExWriteCriticalSection
in interface ILockManager
sectionKey
- 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(String sectionKey) throws ManifoldCFException
leaveNonExWriteCriticalSection
in interface ILockManager
sectionKey
- 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(String sectionKey) throws ManifoldCFException
enterWriteCriticalSection
in interface ILockManager
sectionKey
- 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(String sectionKey) throws ManifoldCFException
leaveWriteCriticalSection
in interface ILockManager
sectionKey
- 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(String[] readSectionKeys, String[] nonExSectionKeys, String[] writeSectionKeys) throws ManifoldCFException
enterCriticalSections
in interface ILockManager
readSectionKeys
- 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(String[] readSectionKeys, String[] nonExSectionKeys, String[] writeSectionKeys) throws ManifoldCFException
leaveCriticalSections
in interface ILockManager
readSectionKeys
- 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