- All Superinterfaces:
AutoCloseable
Leases time windows on machine slots, the lease primitive of a store (05-machine-lease.md §2). Every state change is
an atomic conditional update of one slot; the store clock stamps it.
Failures (R1-spi-03): an operation that fails for another reason than its outcome throws a
RuntimeException of the backend's choosing (a driver exception, or the store's own wrapper of one). A timeout
is recognised with StoreTimeoutException.isTimeout(Throwable), whether the backend
throws a StoreTimeoutException or one as the cause; the runtime counts those as store timeouts. No common
base class is promised beyond RuntimeException.
-
Method Summary
Modifier and TypeMethodDescriptionacquire(String namespace, Owner owner, int limit, Duration ttl, Duration tolerance, int slotOffset, OptionalInt preferredSlot) Acquires a slot, trying in order (§2.1): one this owner already holds,preferredSlot, the slot this owner key held last, the lowest free slot.default voidclose()booleanReleases a lease; the next holder's floor becomesmax(floor, min(lastIssued, ceiling)).Renews a lease; idempotent, the fence stays.
-
Method Details
-
acquire
AcquireResult acquire(String namespace, Owner owner, int limit, Duration ttl, Duration tolerance, int slotOffset, OptionalInt preferredSlot) Acquires a slot, trying in order (§2.1): one this owner already holds,preferredSlot, the slot this owner key held last, the lowest free slot.- Parameters:
namespace- the namespaceowner- the ownerlimit- the slots are[0, limit)ttl- the lease expires this long after the writetolerance- the ceiling lies this far beyond the expiry (D20)slotOffset- the offset the clients add to the slot to get the node of their ids (api-freeze.md §2.1.1); it is recorded with the limit and the tolerance and does not change which slot is chosenpreferredSlot- the slot to try before the others- Returns:
- the lease, or
AcquireResult.Exhausted - Throws:
NamespaceMismatchException- if the namespace was first used with another limit, tolerance or slot offset (metadata written before the slot offset existed reads as offset 0)
-
renew
Renews a lease; idempotent, the fence stays.- Parameters:
lease- the lease, as last returnedttl- the lease expires this long after the write, never earlier than beforetolerance- the ceiling lies this far beyond the expiry- Returns:
- the renewed lease, or empty if the owner or fence no longer match
-
release
Releases a lease; the next holder's floor becomesmax(floor, min(lastIssued, ceiling)).- Parameters:
lease- the lease, as last returnedlastIssued- the largest timestamp issued under the lease, in milliseconds- Returns:
- whether the lease was released; false if the owner or fence no longer match
-
close
default void close()- Specified by:
closein interfaceAutoCloseable
-