public interface LockService
Repository interface to manage lock in database, which will be used by LockManager
| Modifier and Type | Method and Description |
|---|---|
LockAcquisition |
extendLock(LockKey key,
io.flamingock.internal.util.id.RunnerId owner,
long leaseMillis)
The only goal of this method is to update(mainly to extend the expiry date) the lock in case is already owned.
|
LockAcquisition |
getLock(LockKey lockKey)
Retrieves a lock by key
|
void |
releaseLock(LockKey lockKey,
io.flamingock.internal.util.id.RunnerId owner)
Removes from database all the locks with the same key(only can be one) and owner
|
LockAcquisition extendLock(LockKey key, io.flamingock.internal.util.id.RunnerId owner, long leaseMillis) throws LockServiceException
(existingLock.key==newLock.key && existingLoc.owner==newLock.owner).
If there is no lock for the key, or it doesn't belong to newLock.owner(), a LockPersistenceException is thrown.
Take into account that if it's already expired, but still with the same owner, we are lucky, no one has taken it yet, so we can still extend the expiration time.
key - Specially important in cloud execution as it represents a serviceowner - It references the running instanceleaseMillis - How long(in millis) the lock will be acquired for.LockServiceException - if there is a lock in database with same key, but is expired and belong to
another owner or cannot insert/update the lock for any other reasonLockAcquisition getLock(LockKey lockKey)
lockKey - keyvoid releaseLock(LockKey lockKey, io.flamingock.internal.util.id.RunnerId owner)
lockKey - lock keyowner - lock owner