Record Class RosterEntry

java.lang.Object
java.lang.Record
io.krabka.streams.coordination.RosterEntry
Record Components:
member - the member that registered
offset - the offset of the registration record of the member
registeredAt - the time the member registered, in milliseconds since the Unix epoch

public record RosterEntry(MemberId member, long offset, long registeredAt) extends Record
One member of the roster of a role.

The offset is the offset of the registration record of the member in the partition of the role, and it is the join sequence of that member. Log compaction keeps the offset of every record it retains, so a reader that walks the partition in offset order sees the registrations in registration order.

Rank comes from this offset, and not from a configuration file. A recovered node registers again, takes a higher offset, and lands at the tail of the roster. That is the no-failback rule. A rank from a configuration file would put the recovered node at the front, and the node would then preempt the member that replaced it.

Example

for (RosterEntry entry : state.roster()) {
    System.out.println(entry.member() + " joined at offset " + entry.offset());
}
  • Constructor Details

    • RosterEntry

      public RosterEntry(MemberId member, long offset, long registeredAt)
      Rejects a null member.
      Parameters:
      member - the member that registered
      offset - the offset of the registration record of the member
      registeredAt - the time the member registered, in milliseconds since the Unix epoch
  • Method Details

    • 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.
    • member

      public MemberId member()
      Returns the value of the member record component.
      Returns:
      the value of the member record component
    • offset

      public long offset()
      Returns the value of the offset record component.
      Returns:
      the value of the offset record component
    • registeredAt

      public long registeredAt()
      Returns the value of the registeredAt record component.
      Returns:
      the value of the registeredAt record component