All Known Implementing Classes:
LockDAO

public interface ILockDAO
Low-level DB operations on the forms_lucene_lock table. All timestamp arithmetic is computed DB-side (CURRENT_TIMESTAMP), so JVM clock skew between instances of a cluster cannot cause a valid lock to appear expired (or vice versa).
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    acquire(String indexName, String instanceName, String uuid, long ttlSeconds, fr.paris.lutece.portal.service.plugin.Plugin plugin)
    Try to acquire the row for indexName.
    boolean
    refresh(String uuid, long ttlSeconds, fr.paris.lutece.portal.service.plugin.Plugin plugin)
    Extend the expiration of the row owned by uuid, but ONLY if it still belongs to us (row not stolen after TTL expiration).
    void
    release(String uuid, fr.paris.lutece.portal.service.plugin.Plugin plugin)
    Release the row owned by uuid.
    int
    releaseByInstance(String instanceName, fr.paris.lutece.portal.service.plugin.Plugin plugin)
    Release every row currently owned by the given instance.
  • Method Details

    • acquire

      boolean acquire(String indexName, String instanceName, String uuid, long ttlSeconds, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Try to acquire the row for indexName. Succeeds if the row is currently unlocked or if its expired_date is in the past (reclaim after crash).
      Parameters:
      indexName - lock key
      instanceName - runtime-unique identifier of THIS JVM (see FormsInstanceId)
      uuid - handle tying the caller to the row, used by refresh(java.lang.String, long, fr.paris.lutece.portal.service.plugin.Plugin)/release(java.lang.String, fr.paris.lutece.portal.service.plugin.Plugin)
      ttlSeconds - how long the lock stays valid from now, in seconds
      plugin - plugin handle for the DB pool
      Returns:
      true if the row was taken, false if another instance already holds it
    • release

      void release(String uuid, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Release the row owned by uuid. No-op if the handle is unknown.
    • refresh

      boolean refresh(String uuid, long ttlSeconds, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Extend the expiration of the row owned by uuid, but ONLY if it still belongs to us (row not stolen after TTL expiration). Returns false if the lock has been lost — the caller must abort its critical section.
      Returns:
      true if still ours and extended, false if lost
    • releaseByInstance

      int releaseByInstance(String instanceName, fr.paris.lutece.portal.service.plugin.Plugin plugin)
      Release every row currently owned by the given instance. Safe in cluster: rows owned by other instances are never touched.
      Returns:
      the number of rows released