GlobalObjects
|
Objects of this class monitor the lock state of persistent objects. More...
#include <GloLockManager.h>
Classes | |
class | LockedObject |
Objects can be locked. Objects of this class represent an object locked by the communicator, with possibly also locked objects like embedded objects. More... | |
Public Member Functions | |
LockManager (Manager *pDBManager) | |
virtual | ~LockManager () |
void | deleteAllLocks (Communicator *pCommunicator, const std::string &rsSchemaName) |
void | getNotAllowedReadObjects (std::list< ObjID > &rReadLockObjList, const TransactionOwner &rCommunicatorWithTreadID) const |
LockPossibleSpecification | getProcessingPossibilities (const ObjID &rObjID, std::map< ObjID, Record *, std::less< ObjID > > &rDependObjects, const TransactionOwner &rCommunicatorWithTreadID) |
bool | isPossible (const ObjID &rObjID, std::map< ObjID, Record *, std::less< ObjID > > &rDependObjects, const TransactionOwner &rCommunicatorWithTreadID, bool bRead, bool bWrite, bool bDelete) |
int | lockObject (const ObjID &rObjID, std::map< ObjID, Record *, std::less< ObjID > > &rDependObjects, const TransactionOwner &rCommunicatorWithTreadID, const std::string &rsSchemaName, EnLockMode eLockMode, EnDeepMode eDeepMode, bool bSimulate=false) |
int | unlockObject (const ObjID &rObjID, const TransactionOwner &rCommunicatorWithTreadID, const std::string &rsSchemaName, EnLockMode eLockMode, EnDeepMode eDeepMode, bool bSimulate=false) |
Protected Member Functions | |
LockManager () | |
Private Member Functions | |
LockManager (const LockManager &) | |
LockManager & | operator= (const LockManager &) |
void | sendNotify (TdWatchNotifyMode nWatchNotifyMode, const ObjID &rObjID, Communicator *pCommunicator, const std::string &rsSchemaName) |
Private Attributes | |
std::unordered_map< unsigned long, LockedObject * > | m_LockedObjectMap |
Manager * | m_pDBManager |
Objects of this class monitor the lock state of persistent objects.
No lock states are stored in the tables. The Manager must register objects for locking (with the locking or releasing communicator) and always ask before actions whether they are allowed. Lock states of single objects can be requested.
Since an object should be able to be locked e.g. with its dependent objects, objects are passed with their dependent objects to lock. The lock possibility of each object is checked and if possible all objects are locked with passed lock mode or none.
For each lock mode there is a list in which the list of dependent objects with the lock depth mode is stored.
When an object is released with a specific lock mode and lock depth mode, the list is removed from the lock mode list and any objects contained are also released with the same lock mode.
This is necessary because, for example, an object 'A' can be locked with a referenced object 'B'. The application can now dereference the referenced object 'B' into object 'A'. When object 'A' is released, the previously referenced object 'B' is no longer linked to object 'A' and would therefore not be released.
The following table lists the individual lock modes and their effects.
The following abbreviations apply to the lock modes:
The following abbreviations apply to actions:
Locking instance | Other instances | ||||
---|---|---|---|---|---|
Lock mode | Guarantee to do... | Protect from... | Allowed lock modes | Possibilities | Restrictions |
NN | none | none | all | all | none |
RD | R | D | RD, RW, WW, TW | R, W | D |
RW | R | D, W | RD, RW | R | D, W |
WW | R, W | D, W | RD | R | D, W |
DW | R, W, D | D, W | none | R | D, W |
DR | R, W, D | D, W, R | none | none | D, R, W |
EX | R, W, D | D, W, R | none | none | D, R, W |
TW | R, W | D, W | RD | R | D, W |
TD | R, W, D | D, W | none | R | D, W |
The structure of the LockManager looks like this:
|
protected |
The default constructor is not available.
glo::LockManager::LockManager | ( | Manager * | pDBManager | ) |
Constructor with parameter passing.
[in] | pDBManager | Backreference to the owning Manager, must not be removed from memory during the lifetime of this object. |
|
virtual |
Destructor, cleaning up.
|
private |
The copy constructor is not available.
void glo::LockManager::deleteAllLocks | ( | Communicator * | pCommunicator, |
const std::string & | rsSchemaName ) |
All locks of the passed communicator are removed.
[in] | pCommunicator | The communicator. |
[in] | rsSchemaName | The schema name is used for notification. |
void glo::LockManager::getNotAllowedReadObjects | ( | std::list< ObjID > & | rReadLockObjList, |
const TransactionOwner & | rCommunicatorWithTreadID ) const |
Returns all object IDs of the read-only objects for the passed communicator.
[in,out] | rReadLockObjList | The object IDs of the read locked objects. |
[in] | rCommunicatorWithTreadID | The communicator with thread-id. |
LockPossibleSpecification glo::LockManager::getProcessingPossibilities | ( | const ObjID & | rObjID, |
std::map< ObjID, Record *, std::less< ObjID > > & | rDependObjects, | ||
const TransactionOwner & | rCommunicatorWithTreadID ) |
Returns the possible action with an object for a communicator.
[in] | rObjID | The object ID to be checked. |
[in] | rDependObjects | The map of data sets of the objects to be checked. |
[in] | rCommunicatorWithTreadID | The communicator with thread-id. |
bool glo::LockManager::isPossible | ( | const ObjID & | rObjID, |
std::map< ObjID, Record *, std::less< ObjID > > & | rDependObjects, | ||
const TransactionOwner & | rCommunicatorWithTreadID, | ||
bool | bRead, | ||
bool | bWrite, | ||
bool | bDelete ) |
Checks whether the transferred communicator is allowed to read, write and/or delete the object with transferred object ID.
[in] | rObjID | The object ID to be checked. |
[in] | rDependObjects | The map of data sets of the objects to be checked. |
[in] | rCommunicatorWithTreadID | The communicator with thread-id. |
[in] | bRead | If true, a 'read' check is performed. |
[in] | bWrite | If true, a 'write' check is performed. |
[in] | bDelete | If true, checks for 'delete'. |
int glo::LockManager::lockObject | ( | const ObjID & | rObjID, |
std::map< ObjID, Record *, std::less< ObjID > > & | rDependObjects, | ||
const TransactionOwner & | rCommunicatorWithTreadID, | ||
const std::string & | rsSchemaName, | ||
EnLockMode | eLockMode, | ||
EnDeepMode | eDeepMode, | ||
bool | bSimulate = false ) |
Locks an object with passed object ID for a communicator.
[in] | rObjID | The object ID of the object to be locked. |
[in] | rDependObjects | The map of records of the objects to be locked. |
[in] | rCommunicatorWithTreadID | The locking communicator with thread-id. |
[in] | rsSchemaName | The schema name is used for notification. |
[in] | eLockMode | The locking mode. |
[in] | eDeepMode | The lock depth mode. |
[in] | bSimulate | If true, only simulation is used, no value is set, but a valid result or error is returned. |
|
private |
The assignment operator is not available.
|
private |
Initiates a Notify via its m_pDBManager.
[in] | nWatchNotifyMode | The watch mode. |
[in] | rObjID | The Object-ID of the affected object. |
[in] | pCommunicator | The communicator. |
[in] | rsSchemaName | The schema name is used for notification. |
int glo::LockManager::unlockObject | ( | const ObjID & | rObjID, |
const TransactionOwner & | rCommunicatorWithTreadID, | ||
const std::string & | rsSchemaName, | ||
EnLockMode | eLockMode, | ||
EnDeepMode | eDeepMode, | ||
bool | bSimulate = false ) |
Releases the object locked by a communicator with passed object ID.
[in] | rObjID | The object ID of the object to be released. |
[in] | rCommunicatorWithTreadID | The releasing communicator with thread-id. |
[in] | rsSchemaName | The schema name is used for notification. |
[in] | eLockMode | The locking mode. |
[in] | eDeepMode | The lock depth mode. |
[in] | bSimulate | If true, only simulation is used, no value is set, but a valid result or error is returned. |
|
private |
List of the locked objects.