Record Class Lease
java.lang.Object
java.lang.Record
io.krabka.streams.coordination.Lease
- Record Components:
member- the member that holds the roletoken- the quorum-minted proof of the claim of the holdergrantedAt- the time the holder took the lease, in milliseconds since the Unix epoch; a renewal moves it forwarddeadline- the time the lease expires, in milliseconds since the Unix epoch
- All Implemented Interfaces:
CoordinationValue
public record Lease(MemberId member, FencingToken token, long grantedAt, long deadline)
extends Record
implements CoordinationValue
The member that holds a role now, and the time its claim ends.
The token is the authority. The broker fences a write that carries an older token, and no clock takes part in that check. The deadline is an anti-flap device. A standby waits for the deadline to pass before it challenges the holder, so a short pause does not move the role. A wrong deadline makes a failover early or late. A wrong deadline never makes two members authoritative.
The holder writes the record inside a transaction under the epoch of the role, so
a lease record that reached the log is proof that its author held the epoch. A reader
uses read_committed, so an aborted lease write stays invisible.
Example
Lease lease = config.grant(me, token, clock.nowMillis());
transport.writeLease(role, token, lease);
boolean live = config.timing(lease).liveAt(clock.nowMillis());
-
Constructor Summary
ConstructorsConstructorDescriptionLease(MemberId member, FencingToken token, long grantedAt, long deadline) Rejects a null member and a null token. -
Method Summary
Modifier and TypeMethodDescriptionlongdeadline()Returns the value of thedeadlinerecord component.final booleanIndicates whether some other object is "equal to" this one.longReturns the value of thegrantedAtrecord component.final inthashCode()Returns a hash code value for this object.kind()Returns the kind of the key that a lease sits under.member()Returns the value of thememberrecord component.token()Returns the value of thetokenrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Lease
Rejects a null member and a null token.- Parameters:
member- the member that holds the roletoken- the quorum-minted proof of the claim of the holdergrantedAt- the time the holder took the lease, in milliseconds since the Unix epochdeadline- the time the lease expires, in milliseconds since the Unix epoch
-
-
Method Details
-
kind
Returns the kind of the key that a lease sits under.- Specified by:
kindin interfaceCoordinationValue- Returns:
RecordKind.LEASE
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
member
Returns the value of thememberrecord component.- Specified by:
memberin interfaceCoordinationValue- Returns:
- the value of the
memberrecord component
-
token
-
grantedAt
-
deadline
-