Interface FormsDistributedLockManager
- All Known Subinterfaces:
LuceneLockManager
- All Known Implementing Classes:
LuceneLockManagerDB
public interface FormsDistributedLockManager
Cluster-wide named lock for the forms plugin. Backed by the
forms_lucene_lock
table so it works on any deployment (no Hazelcast requirement) and survives
JVM restarts via the lock expiration timestamp.
Intended for short critical sections that must be serialised across instances
(response-quota enforcement, index writer acquisition, daemon runs, etc.).-
Method Summary
Modifier and TypeMethodDescriptionacquireLock(String lockName, long timeoutMs) Try to acquire a named lock.voidclose()Release every lock currently owned by THIS JVM (equivalent toreleaseOwnInstanceLocks()).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 viaacquireLock(java.lang.String, long).default intRelease every lock currently owned by the current instance — safe recovery from a previous crash of this very JVM.
-
Method Details
-
acquireLock
Try to acquire a named lock. Non-blocking: returns immediately on contention.- Parameters:
lockName- 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 toreleaseLock(fr.paris.lutece.plugins.forms.service.lock.LockResult)orrefreshLock(fr.paris.lutece.plugins.forms.service.lock.LockResult, long) - Throws:
LockException- if the lock is already held by someone else
-
releaseLock
Release a lock previously acquired viaacquireLock(java.lang.String, long).- Parameters:
lockResult- the handle returned byacquireLock(java.lang.String, long)- Throws:
LockException- on release failure
-
refreshLock
Extend the expiration date of a held lock (heartbeat pattern for long-running sections).- 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
void close()Release every lock currently owned by THIS JVM (equivalent toreleaseOwnInstanceLocks()). Previous contract was "release ALL locks in the table" — removed because in a cluster it let any single node cancel indexing runs held by its peers. Blanket-release must never be exposed through this interface; use a DB admin script if an operator truly needs it. -
releaseOwnInstanceLocks
default int releaseOwnInstanceLocks()Release 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.- Returns:
- the number of locks released
-