Class LockManager
- java.lang.Object
-
- lumis.portal.lock.LockManager
-
- All Implemented Interfaces:
ILockManager
,ILockManagerSPI
public class LockManager extends java.lang.Object implements ILockManagerSPI
Manager implementation for lock-related operations- Since:
- 4.2.0
- Version:
- $Revision$ $Date$
-
-
Constructor Summary
Constructors Constructor Description LockManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
forceSingleUnlock(java.lang.String id)
Force the unlock of a single lock with the specified identifier (database id).void
forceUnlock(java.lang.String resourceId)
Forces the unlock of the specified lock resource, independently of the current owner.java.util.concurrent.locks.Lock
getLock(java.lang.String resourceId)
Deprecated.java.util.concurrent.locks.Lock
getReadLock(java.lang.String resourceId)
Returns a non-exclusive read lock object for the specified resource.java.util.Collection<java.lang.String>
getRecentlyLock(long lastMilliseconds)
Return write locks for the last millisencondsjava.util.concurrent.locks.Lock
getWriteLock(java.lang.String resourceId)
Returns an exclusive write lock object for the specified resource.void
unlockExpiredLocks()
Deletes all the locks that have expired.
-
-
-
Method Detail
-
getLock
@Deprecated public java.util.concurrent.locks.Lock getLock(java.lang.String resourceId)
Deprecated.Description copied from interface:ILockManager
Returns a cluster-wide exclusive lock object for the specified resource.See
lumis.portal.lock
for details about the consequences of the lock scope being cluster-wide.The lock implementation returned does not support conditions. The
Lock.newCondition()
method throwsUnsupportedOperationException
.If this method is called multiple times with the same resourceId value, the lock objects returned use a common synchronizing resource. This way, calling
Lock.lock()
on any of these lock objects will generate a lock in the same resource (and these locks will block each other). But aLock.unlock()
must still be executed in the sameLock
instance on which the lock was acquired, since it is considered the owner of that lock.- Specified by:
getLock
in interfaceILockManager
- Parameters:
resourceId
- the identifier of the resource the lock refers to. It is recommended to name the identifier using Java class name style (e.g. com.company.module.etc.MyResource) to prevent naming conflicts on different implementations.- Returns:
- the lock object.
- See Also:
lumis.portal.lock
-
getReadLock
public java.util.concurrent.locks.Lock getReadLock(java.lang.String resourceId)
Description copied from interface:ILockManager
Returns a non-exclusive read lock object for the specified resource.See
lumis.portal.lock
for details about the consequences of the lock scope being cluster-wide.The lock implementation returned does not support conditions. The
Lock.newCondition()
method throwsUnsupportedOperationException
.This kind of lock requires that there's no write lock holding the lock of the same resource. In the other hand, multiple read locks may be holding the lock for the same resource at the same time.
This lock is indicated when some resource must be read but it will not be changed. This way, multiple processes that must read the same resource will not block each other.
- Specified by:
getReadLock
in interfaceILockManager
- Parameters:
resourceId
- the identifier of the resource the lock refers to. It is recommended to name the identifier using Java class name style (e.g. com.company.module.etc.MyResource) to prevent naming conflicts on different implementations.- Returns:
- the lock object.
- See Also:
lumis.portal.lock
-
getWriteLock
public java.util.concurrent.locks.Lock getWriteLock(java.lang.String resourceId)
Description copied from interface:ILockManager
Returns an exclusive write lock object for the specified resource.See
lumis.portal.lock
for details about the consequences of the lock scope being cluster-wide.The lock implementation returned does not support conditions. The
Lock.newCondition()
method throwsUnsupportedOperationException
.This kind of lock requires that there's no other lock holding the lock of the same resource. Once this lock has been locked, no other lock will be able to access the specified resource until this lock has been unlocked.
This lock is indicated when some resource must be changed. This way, the owner of this lock can change the resource exclusively, avoiding other processes to read or change the specified resource erroneously.
- Specified by:
getWriteLock
in interfaceILockManager
- Parameters:
resourceId
- the identifier of the resource the lock refers to. It is recommended to name the identifier using Java class name style (e.g. com.company.module.etc.MyResource) to prevent naming conflicts on different implementations.- Returns:
- the lock object.
- See Also:
lumis.portal.lock
-
unlockExpiredLocks
public void unlockExpiredLocks() throws PortalException
Description copied from interface:ILockManager
Deletes all the locks that have expired.- Specified by:
unlockExpiredLocks
in interfaceILockManager
- Throws:
PortalException
-
forceUnlock
public void forceUnlock(java.lang.String resourceId) throws PortalException
Forces the unlock of the specified lock resource, independently of the current owner.- Parameters:
resourceId
- the lock resource identifier.- Throws:
PortalException
- Since:
- 5.6.0
-
forceSingleUnlock
public void forceSingleUnlock(java.lang.String id) throws PortalException
Force the unlock of a single lock with the specified identifier (database id).- Parameters:
id
- the lock identifier.- Throws:
PortalException
- Since:
- 8.0.0
-
getRecentlyLock
public java.util.Collection<java.lang.String> getRecentlyLock(long lastMilliseconds) throws PortalException
Description copied from interface:ILockManagerSPI
Return write locks for the last millisenconds- Specified by:
getRecentlyLock
in interfaceILockManagerSPI
- Returns:
- Throws:
PortalException
-
-