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 Classes
    Modifier and Type
    Class
    Description
    static enum 
    The claim lifecycle; PENDING also stands in for a stale object left by an earlier generation.
  • Constructor Summary

    Constructors
    Constructor
    Description
    WalkSegment(long generation, int index, String root, String from, String to, WalkSegment.State state, String holder, Instant expiry, String cursor)
    Creates an instance of a WalkSegment record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Whether a worker may claim this segment now: never started, or its holder's lease ran out.
    Returns the value of the cursor record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    Returns the value of the expiry record component.
    Returns the value of the from record component.
    long
    Returns the value of the generation record component.
    final int
    Returns a hash code value for this object.
    Returns the value of the holder record component.
    int
    Returns the value of the index record component.
    Returns the value of the root record component.
    Returns the value of the state record component.
    to()
    Returns the value of the to record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • 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 a WalkSegment record class.
      Parameters:
      generation - the value for the generation record component
      index - the value for the index record component
      root - the value for the root record component
      from - the value for the from record component
      to - the value for the to record component
      state - the value for the state record component
      holder - the value for the holder record component
      expiry - the value for the expiry record component
      cursor - the value for the cursor record component
  • Method Details

    • claimable

      public boolean claimable(Instant now)
      Whether a worker may claim this segment now: never started, or its holder's lease ran out.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • generation

      public long generation()
      Returns the value of the generation record component.
      Returns:
      the value of the generation record component
    • index

      public int index()
      Returns the value of the index record component.
      Returns:
      the value of the index record component
    • root

      public String root()
      Returns the value of the root record component.
      Returns:
      the value of the root record component
    • from

      public String from()
      Returns the value of the from record component.
      Returns:
      the value of the from record component
    • to

      public String to()
      Returns the value of the to record component.
      Returns:
      the value of the to record component
    • state

      public WalkSegment.State state()
      Returns the value of the state record component.
      Returns:
      the value of the state record component
    • holder

      public String holder()
      Returns the value of the holder record component.
      Returns:
      the value of the holder record component
    • expiry

      public Instant expiry()
      Returns the value of the expiry record component.
      Returns:
      the value of the expiry record component
    • cursor

      public String cursor()
      Returns the value of the cursor record component.
      Returns:
      the value of the cursor record component