Class LuceneLockManagerDB
java.lang.Object
fr.paris.lutece.plugins.forms.service.lock.LuceneLockManagerDB
- All Implemented Interfaces:
FormsDistributedLockManager,LuceneLockManager
@ApplicationScoped
@Named("forms.luceneLockManager")
public class LuceneLockManagerDB
extends Object
implements LuceneLockManager
-
Method Summary
Modifier and TypeMethodDescriptionacquireLock(String indexName, long timeoutMs) Try to acquire a named lock.voidclose()Release every lock currently held by THIS JVM.refreshLock(LockResult lockResult, long timeoutMs) Extend the expiration date of a held lock (heartbeat pattern for long-running sections).voidreleaseLock(LockResult lockResult) Release a lock previously acquired viaFormsDistributedLockManager.acquireLock(java.lang.String, long).intRelease every lock currently owned by the current instance — safe recovery from a previous crash of this very JVM.
-
Method Details
-
acquireLock
Description copied from interface:FormsDistributedLockManagerTry to acquire a named lock. Non-blocking: returns immediately on contention.- Specified by:
acquireLockin interfaceFormsDistributedLockManager- Parameters:
indexName- unique lock identifier (e.g."forms.quota.form.42")timeoutMs- how long the lock remains valid before it auto-expires, in milliseconds- Returns:
- a
LockResulthandle to pass toFormsDistributedLockManager.releaseLock(fr.paris.lutece.plugins.forms.service.lock.LockResult)orFormsDistributedLockManager.refreshLock(fr.paris.lutece.plugins.forms.service.lock.LockResult, long) - Throws:
LockException- if the lock is already held by someone else
-
releaseLock
Description copied from interface:FormsDistributedLockManagerRelease a lock previously acquired viaFormsDistributedLockManager.acquireLock(java.lang.String, long).- Specified by:
releaseLockin interfaceFormsDistributedLockManager- Parameters:
lockResult- the handle returned byFormsDistributedLockManager.acquireLock(java.lang.String, long)- Throws:
LockException- on release failure
-
refreshLock
Description copied from interface:FormsDistributedLockManagerExtend the expiration date of a held lock (heartbeat pattern for long-running sections).- Specified by:
refreshLockin interfaceFormsDistributedLockManager- Parameters:
lockResult- the lock handletimeoutMs- new expiration delay from now, in milliseconds- Returns:
- a refreshed
LockResult - Throws:
LockException- if the lock was lost (e.g. already expired and reclaimed)
-
close
public void close()Release every lock currently held by THIS JVM. Kept to honour the interface contract; it is deliberately scoped to the current instance — blanket-releasing every row in the cluster would let this node cancel indexing runs owned by peers.- Specified by:
closein interfaceFormsDistributedLockManager
-
releaseOwnInstanceLocks
public int releaseOwnInstanceLocks()Description copied from interface:FormsDistributedLockManagerRelease every lock currently owned by the current instance — safe recovery from a previous crash of this very JVM. Typically called once at plugin startup. Implementations MUST NOT release locks owned by other instances: that would let this node reclaim a lock still actively held by another live node and corrupt the shared resource. Default implementation is a no-op so alternative implementations remain source-compatible.- Specified by:
releaseOwnInstanceLocksin interfaceFormsDistributedLockManager- Returns:
- the number of locks released
-