Class DBFencedLock
java.lang.Object
dk.cloudcreate.essentials.components.foundation.fencedlock.DBFencedLock
- All Implemented Interfaces:
FencedLock,AutoCloseable
-
Constructor Summary
ConstructorsConstructorDescriptionDBFencedLock(DBFencedLockManager<? extends UnitOfWork, DBFencedLock> fencedLockManager, LockName lockName, Long currentToken, String lockedByBusInstanceId, OffsetDateTime lockAcquiredTimestamp, OffsetDateTime lockLastConfirmedTimestamp) -
Method Summary
Modifier and TypeMethodDescriptionbooleanThe 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.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())Which JVM/FencedLockManager.getLockManagerInstanceId()that has acquired this lockAt what time did the JVM/FencedLockManager.getLockManagerInstanceId(), that currently has acquired the lock, last confirm that it still has access to the lockgetName()The name of the LockinthashCode()booleanisLocked()Is this lock locked?booleanIs this Lock locked by this JVM nodemarkAsLocked(OffsetDateTime lockTime, String lockedByLockManagerInstanceId, long currentToken) voidvoidregisterCallback(LockCallback lockCallback) voidrelease()Release/Unlock the lock.toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface dk.cloudcreate.essentials.components.foundation.fencedlock.FencedLock
close
-
Constructor Details
-
DBFencedLock
public DBFencedLock(DBFencedLockManager<? extends UnitOfWork, DBFencedLock> fencedLockManager, LockName lockName, Long currentToken, String lockedByBusInstanceId, OffsetDateTime lockAcquiredTimestamp, OffsetDateTime lockLastConfirmedTimestamp)
-
-
Method Details
-
getName
Description copied from interface:FencedLockThe name of the Lock- Specified by:
getNamein interfaceFencedLock- Returns:
- the lock name
-
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
Description copied from interface:FencedLockWhich JVM/FencedLockManager.getLockManagerInstanceId()that has acquired this lock- Specified by:
getLockedByLockManagerInstanceIdin interfaceFencedLock
-
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
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
- Specified by:
registerCallbackin interfaceFencedLock
-
equals
-
hashCode
public int hashCode() -
getDurationSinceLastConfirmation
-
markAsReleased
public void markAsReleased() -
markAsLocked
public DBFencedLock markAsLocked(OffsetDateTime lockTime, String lockedByLockManagerInstanceId, long currentToken) -
toString
-