Record Class RosterEntry
java.lang.Object
java.lang.Record
io.krabka.streams.coordination.RosterEntry
- Record Components:
member- the member that registeredoffset- the offset of the registration record of the memberregisteredAt- the time the member registered, in milliseconds since the Unix epoch
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 Summary
ConstructorsConstructorDescriptionRosterEntry(MemberId member, long offset, long registeredAt) Rejects a null member. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.member()Returns the value of thememberrecord component.longoffset()Returns the value of theoffsetrecord component.longReturns the value of theregisteredAtrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
RosterEntry
Rejects a null member.- Parameters:
member- the member that registeredoffset- the offset of the registration record of the memberregisteredAt- the time the member registered, in milliseconds since the Unix epoch
-
-
Method Details
-
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
-
offset
-
registeredAt
public long registeredAt()Returns the value of theregisteredAtrecord component.- Returns:
- the value of the
registeredAtrecord component
-