public interface LockService
This interface intentionally exposes only the post-acquisition operations needed by the runtime: extending an already-held lock, reading current lock state, and releasing. Acquisition is not part of this interface. Each implementation owns its own acquisition path:
CommunityLockService.upsert(...),
called from inside CommunityLock.acquire().| Modifier and Type | Method and Description |
|---|---|
LockAcquisition |
extendLock(LockKey key,
io.flamingock.internal.util.id.RunnerId owner,
long leaseMillis)
Refreshes (extends) a lock that the caller already owns.
|
LockAcquisition |
getLockInfo(LockKey lockKey)
Reads the current state of a lock.
|
void |
releaseLock(LockKey lockKey,
io.flamingock.internal.util.id.RunnerId owner)
Releases (deletes) the lock identified by
lockKey when the caller is the owner. |
LockAcquisition extendLock(LockKey key, io.flamingock.internal.util.id.RunnerId owner, long leaseMillis) throws LockServiceException
Asserts that (existingLock.key == newLock.key && existingLock.owner == newLock.owner)
and rotates internal lock state (e.g. on cloud, the acquisitionId). This method
does not grant ownership: a missing lock or a lock held by a different
owner causes LockServiceException. If the lock has already expired but is still
recorded against the same owner, extending succeeds (no other process has taken it yet).
key - lock key (typically the service id in cloud)owner - caller's runner id; must equal the existing lock's ownerleaseMillis - requested lease duration in milliseconds. Honored by community
implementations; ignored on cloud (the server keeps the duration set
at acquire time and echoes it back).LockAcquisition describing the lock after extensionLockServiceException - if no lock exists for key, the lock belongs to a
different owner, or the underlying store rejects the updateLockAcquisition getLockInfo(LockKey lockKey)
Pure read. This method has no side effects: it never creates, extends, takes over, or releases a lock. It exists for diagnostic / error-recovery paths that need to inspect who currently holds a contended lock.
Note: not every backend can support this operation. The cloud implementation
throws UnsupportedOperationException because the lock REST API exposes no
read-only endpoint.
lockKey - lock keynull if no lock is recorded for lockKeyvoid releaseLock(LockKey lockKey, io.flamingock.internal.util.id.RunnerId owner)
lockKey when the caller is the owner.
Best-effort: implementations should not throw on contention or transient errors,
because release is typically called from cleanup paths where rethrowing would mask
the original failure. A lock not owned by owner is left untouched.
lockKey - lock keyowner - caller's runner id