Interface ILockDAO
- 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 TypeMethodDescriptionbooleanacquire(String indexName, String instanceName, String uuid, long ttlSeconds, fr.paris.lutece.portal.service.plugin.Plugin plugin) Try to acquire the row forindexName.booleanExtend the expiration of the row owned byuuid, but ONLY if it still belongs to us (row not stolen after TTL expiration).voidRelease the row owned byuuid.intreleaseByInstance(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 forindexName. Succeeds if the row is currently unlocked or if itsexpired_dateis in the past (reclaim after crash).- Parameters:
indexName- lock keyinstanceName- runtime-unique identifier of THIS JVM (seeFormsInstanceId)uuid- handle tying the caller to the row, used byrefresh(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 secondsplugin- plugin handle for the DB pool- Returns:
trueif the row was taken,falseif another instance already holds it
-
release
Release the row owned byuuid. No-op if the handle is unknown. -
refresh
Extend the expiration of the row owned byuuid, but ONLY if it still belongs to us (row not stolen after TTL expiration). Returnsfalseif the lock has been lost — the caller must abort its critical section.- Returns:
trueif still ours and extended,falseif lost
-
releaseByInstance
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
-