Class LockDAO
java.lang.Object
fr.paris.lutece.plugins.forms.business.form.lock.LockDAO
- All Implemented Interfaces:
ILockDAO
JDBC-escape
{fn TIMESTAMPADD(SQL_TSI_SECOND, ?, CURRENT_TIMESTAMP)} is portable
across HSQLDB, MySQL, PostgreSQL and Oracle; all timestamp comparisons use the DB clock
so JVM clock skew between cluster members cannot steal a still-valid lock or extend a
stale one beyond its real TTL.-
Constructor Summary
Constructors -
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.
-
Constructor Details
-
LockDAO
public LockDAO()
-
-
Method Details
-
acquire
public boolean acquire(String indexName, String instanceName, String uuid, long ttlSeconds, fr.paris.lutece.portal.service.plugin.Plugin plugin) Description copied from interface:ILockDAOTry to acquire the row forindexName. Succeeds if the row is currently unlocked or if itsexpired_dateis in the past (reclaim after crash).- Specified by:
acquirein interfaceILockDAO- Parameters:
indexName- lock keyinstanceName- runtime-unique identifier of THIS JVM (seeFormsInstanceId)uuid- handle tying the caller to the row, used byILockDAO.refresh(java.lang.String, long, fr.paris.lutece.portal.service.plugin.Plugin)/ILockDAO.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
Description copied from interface:ILockDAORelease the row owned byuuid. No-op if the handle is unknown. -
refresh
public boolean refresh(String uuid, long ttlSeconds, fr.paris.lutece.portal.service.plugin.Plugin plugin) Description copied from interface:ILockDAOExtend 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. -
releaseByInstance
public int releaseByInstance(String instanceName, fr.paris.lutece.portal.service.plugin.Plugin plugin) Description copied from interface:ILockDAORelease every row currently owned by the given instance. Safe in cluster: rows owned by other instances are never touched.- Specified by:
releaseByInstancein interfaceILockDAO- Returns:
- the number of rows released
-