|
||||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
See:
Description
Interface Summary | |
---|---|
ILockManager | Manager interface for lock-related operations. |
Class Summary | |
---|---|
LockManager | Manager implementation for lock-related operations |
A framework for lock functionality in a Lumis Portal environment.
The locking scope of this method is the whole Lumis Portal 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 Lumis Portal 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 Lumis Portal 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
|
||||||||||
PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |