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 Details

    • acquireLock

      LockResult acquireLock(String lockName, long timeoutMs) throws LockException
      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 LockResult handle to pass to releaseLock(fr.paris.lutece.plugins.forms.service.lock.LockResult) or refreshLock(fr.paris.lutece.plugins.forms.service.lock.LockResult, long)
      Throws:
      LockException - if the lock is already held by someone else
    • releaseLock

      void releaseLock(LockResult lockResult) throws LockException
      Release a lock previously acquired via acquireLock(java.lang.String, long).
      Parameters:
      lockResult - the handle returned by acquireLock(java.lang.String, long)
      Throws:
      LockException - on release failure
    • refreshLock

      LockResult refreshLock(LockResult lockResult, long timeoutMs) throws LockException
      Extend the expiration date of a held lock (heartbeat pattern for long-running sections).
      Parameters:
      lockResult - the lock handle
      timeoutMs - 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 to releaseOwnInstanceLocks()). 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