Record Class WalkSegment
java.lang.Object
java.lang.Record
build.jenesis.repository.walk.WalkSegment
public record WalkSegment(long generation, int index, String root, String from, String to, WalkSegment.State state, String holder, Instant expiry, String cursor)
extends Record
One claimable slice of a walk pass: a half-open key range
[from, to) under one root in the total
lexicographic key order (null bounds run to the root's start / end), plus the claim embedded in the same
compare-and-set store object (walks/<consumer>/segments/<nn>) - state, the holder worker,
the claim's expiry, and the cursor high-water mark of the last committed checkpoint. Because claim
and cursor live in one object, a checkpoint commit is the lease renewal (one write extends the expiry),
and the two can never diverge: a worker whose commit loses the compare-and-set has provably lost the whole claim
and stops. A claim is taken only over a pending or expired segment - never a live holder's - and a taken-over
segment resumes from cursor, so node death costs at most one checkpoint stride of re-visits, never a
restart.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe claim lifecycle;PENDINGalso stands in for a stale object left by an earlier generation. -
Constructor Summary
ConstructorsConstructorDescriptionWalkSegment(long generation, int index, String root, String from, String to, WalkSegment.State state, String holder, Instant expiry, String cursor) Creates an instance of aWalkSegmentrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether a worker may claim this segment now: never started, or its holder's lease ran out.cursor()Returns the value of thecursorrecord component.final booleanIndicates whether some other object is "equal to" this one.expiry()Returns the value of theexpiryrecord component.from()Returns the value of thefromrecord component.longReturns the value of thegenerationrecord component.final inthashCode()Returns a hash code value for this object.holder()Returns the value of theholderrecord component.intindex()Returns the value of theindexrecord component.root()Returns the value of therootrecord component.state()Returns the value of thestaterecord component.to()Returns the value of thetorecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
WalkSegment
public WalkSegment(long generation, int index, String root, String from, String to, WalkSegment.State state, String holder, Instant expiry, String cursor) Creates an instance of aWalkSegmentrecord class.- Parameters:
generation- the value for thegenerationrecord componentindex- the value for theindexrecord componentroot- the value for therootrecord componentfrom- the value for thefromrecord componentto- the value for thetorecord componentstate- the value for thestaterecord componentholder- the value for theholderrecord componentexpiry- the value for theexpiryrecord componentcursor- the value for thecursorrecord component
-
-
Method Details
-
claimable
Whether a worker may claim this segment now: never started, or its holder's lease ran out. -
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. -
generation
public long generation()Returns the value of thegenerationrecord component.- Returns:
- the value of the
generationrecord component
-
index
public int index()Returns the value of theindexrecord component.- Returns:
- the value of the
indexrecord component
-
root
Returns the value of therootrecord component.- Returns:
- the value of the
rootrecord component
-
from
Returns the value of thefromrecord component.- Returns:
- the value of the
fromrecord component
-
to
Returns the value of thetorecord component.- Returns:
- the value of the
torecord component
-
state
Returns the value of thestaterecord component.- Returns:
- the value of the
staterecord component
-
holder
Returns the value of theholderrecord component.- Returns:
- the value of the
holderrecord component
-
expiry
Returns the value of theexpiryrecord component.- Returns:
- the value of the
expiryrecord component
-
cursor
Returns the value of thecursorrecord component.- Returns:
- the value of the
cursorrecord component
-