Class DBFencedLock
- java.lang.Object
-
- dk.cloudcreate.essentials.components.foundation.fencedlock.DBFencedLock
-
- All Implemented Interfaces:
FencedLock,AutoCloseable
public class DBFencedLock extends Object implements FencedLock
-
-
Constructor Summary
Constructors Constructor Description DBFencedLock(DBFencedLockManager<? extends UnitOfWork,DBFencedLock> fencedLockManager, LockName lockName, Long currentToken, String lockedByBusInstanceId, OffsetDateTime lockAcquiredTimestamp, OffsetDateTime lockLastConfirmedTimestamp)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)LonggetCurrentToken()The current token value as of theFencedLock.getLockLastConfirmedTimestamp()for this Lock across allFencedLockManagerinstances
Every time a lock is acquired or confirmed a new token is issued (i.e.DurationgetDurationSinceLastConfirmation()OffsetDateTimegetLockAcquiredTimestamp()At what time did the JVM/FencedLockManager.getLockManagerInstanceId()that currently has acquired the lock acquire it (at first acquiring theFencedLock.getLockLastConfirmedTimestamp()is set toFencedLock.getLockAcquiredTimestamp())StringgetLockedByLockManagerInstanceId()Which JVM/FencedLockManager.getLockManagerInstanceId()that has acquired this lockOffsetDateTimegetLockLastConfirmedTimestamp()At what time did the JVM/FencedLockManager.getLockManagerInstanceId(), that currently has acquired the lock, last confirm that it still has access to the lockLockNamegetName()The name of the LockinthashCode()booleanisLocked()Is this lock locked?booleanisLockedByThisLockManagerInstance()Is this Lock locked by this JVM nodeDBFencedLockmarkAsLocked(OffsetDateTime lockTime, String lockedByLockManagerInstanceId, long currentToken)voidmarkAsReleased()voidregisterCallback(LockCallback lockCallback)voidrelease()Release/Unlock the lock.StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface dk.cloudcreate.essentials.components.foundation.fencedlock.FencedLock
close
-
-
-
-
Constructor Detail
-
DBFencedLock
public DBFencedLock(DBFencedLockManager<? extends UnitOfWork,DBFencedLock> fencedLockManager, LockName lockName, Long currentToken, String lockedByBusInstanceId, OffsetDateTime lockAcquiredTimestamp, OffsetDateTime lockLastConfirmedTimestamp)
-
-
Method Detail
-
getName
public LockName getName()
Description copied from interface:FencedLockThe name of the Lock- Specified by:
getNamein interfaceFencedLock- Returns:
- the lock name
-
getCurrentToken
public Long getCurrentToken()
Description copied from interface:FencedLockThe current token value as of theFencedLock.getLockLastConfirmedTimestamp()for this Lock across allFencedLockManagerinstances
Every time a lock is acquired or confirmed a new token is issued (i.e. it's ever-growing value)- Specified by:
getCurrentTokenin interfaceFencedLock
-
getLockedByLockManagerInstanceId
public String getLockedByLockManagerInstanceId()
Description copied from interface:FencedLockWhich JVM/FencedLockManager.getLockManagerInstanceId()that has acquired this lock- Specified by:
getLockedByLockManagerInstanceIdin interfaceFencedLock
-
getLockAcquiredTimestamp
public OffsetDateTime getLockAcquiredTimestamp()
Description copied from interface:FencedLockAt what time did the JVM/FencedLockManager.getLockManagerInstanceId()that currently has acquired the lock acquire it (at first acquiring theFencedLock.getLockLastConfirmedTimestamp()is set toFencedLock.getLockAcquiredTimestamp())- Specified by:
getLockAcquiredTimestampin interfaceFencedLock
-
getLockLastConfirmedTimestamp
public OffsetDateTime getLockLastConfirmedTimestamp()
Description copied from interface:FencedLockAt what time did the JVM/FencedLockManager.getLockManagerInstanceId(), that currently has acquired the lock, last confirm that it still has access to the lock- Specified by:
getLockLastConfirmedTimestampin interfaceFencedLock
-
isLocked
public boolean isLocked()
Description copied from interface:FencedLockIs this lock locked?- Specified by:
isLockedin interfaceFencedLock
-
isLockedByThisLockManagerInstance
public boolean isLockedByThisLockManagerInstance()
Description copied from interface:FencedLockIs this Lock locked by this JVM node- Specified by:
isLockedByThisLockManagerInstancein interfaceFencedLock
-
release
public void release()
Description copied from interface:FencedLockRelease/Unlock the lock. Only works ifFencedLock.isLockedByThisLockManagerInstance()is true- Specified by:
releasein interfaceFencedLock
-
registerCallback
public void registerCallback(LockCallback lockCallback)
- Specified by:
registerCallbackin interfaceFencedLock
-
getDurationSinceLastConfirmation
public Duration getDurationSinceLastConfirmation()
-
markAsReleased
public void markAsReleased()
-
markAsLocked
public DBFencedLock markAsLocked(OffsetDateTime lockTime, String lockedByLockManagerInstanceId, long currentToken)
-
-