See: Description
Interface | Description |
---|---|
ILockManager |
Manager interface for lock-related operations.
|
ILockManagerSPI |
Class | Description |
---|---|
LockManager |
Manager implementation for lock-related operations
|
SimpleReadWriteLock |
A simple mutual shared and exclusive lock implementation.
|
Enum | Description |
---|---|
LockType |
Types of lock supported by LumisPortal.
|
The locking scope of this method is the whole LumisXP cluster. For example, the lock for the same resourceId may be obtained in different servers and used as a mutex to synchronize executions in them. If it is desired that the locking does not occur in the LumisXP cluster scope, but only in a single JVM, consider using standard Java locking mechanisms.
The distributed lock performance is much lower than of a non-distributed lock
(as ReentrantLock
for example), and as such,
it may be not suitable for intense locking operations. The distributed
implementation is based on the database, and as such, has the minimal cost of a
database statement execution for each acquisition or release of a lock.
The locks are not associated to the thread that obtained them. Any thread may manipulate the lock objects. If a lock object was used to acquire a lock, this same object must be used to release it.
The entry point for this framework is ILockManager
,
and it may be obtained by
ManagerFactory.getLockManager()
.
Example usage:
Lock lock = ManagerFactory.getLockManager().getLock("com.example.my.resource.id");
lock.lock();
try
{
// this block will be executed only by a single thread simultaneously in
// the whole LumisXP Cluster.
}
finally
{
lock.unlock();
}
Note that the locks have a timeout as configured in lumisportalconfig.xml. This is to prevent the locks from being permanently acquired on a server crash event. But as a consequence, the user of this framework should guarantee that the lock is not held longer than the timeout configured, otherwise the lock semantics will not be obeyed (it may be automatically unlocked after the timeout).
ILockManager
,
Lock
LumisXP 12.3.0.200408 - Copyright © 2006–2020 Lumis EIP Tecnologia da Informação LTDA. All Rights Reserved.