Record Class LeadershipStatus
- Record Components:
role- the role the status describestoken- the token the transaction coordinator reports for the rolestate- the folded state of the coordination topic for the role
The status pairs the two independent answers about a role. The token is the pair
that Kafka's transaction coordinator reports for the transactional.id of the
role, and it is FencingToken.NO_EPOCH when no member has ever taken the role.
The state is the fold of the coordination topic, and it names the roster and the last
lease record.
current() joins the two. It reports whether the member that wrote the
lease still holds the epoch of the role. A checker needs no membership and no lease
clock to answer that question. It is the check the design promises: "a third party
verifies a writer's authority with one request and no membership".
The lease deadline says nothing about authority. A holder past its deadline still owns the newest epoch until a challenger mints a newer one.
Example
LeadershipStatus status = client.describe(Role.of("controller"));
System.out.println(status.holder().map(MemberId::id).orElse("none")
+ " holds " + status.token() + ", current=" + status.current());
-
Constructor Summary
ConstructorsConstructorDescriptionLeadershipStatus(Role role, FencingToken token, RoleState state) Rejects a null component. -
Method Summary
Modifier and TypeMethodDescriptionbooleancurrent()Reports whether the author of the lease still holds the epoch of the role.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanheld()Reports whether any member has ever taken the role.holder()Returns the member the last lease record names.lease()Returns the last lease record of the role.role()Returns the value of therolerecord component.state()Returns the value of thestaterecord component.token()Returns the value of thetokenrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
LeadershipStatus
Rejects a null component.- Parameters:
role- the role the status describestoken- the token the transaction coordinator reports for the rolestate- the folded state of the coordination topic for the role
-
-
Method Details
-
holder
-
lease
-
held
public boolean held()Reports whether any member has ever taken the role.- Returns:
- true when the coordinator reports a minted token
-
current
public boolean current()Reports whether the author of the lease still holds the epoch of the role.A false answer means one of two things. Either no member holds the role, or a challenger minted a newer epoch and has not written its own lease yet. In both cases the broker already rejects every write that the author of this lease makes.
- Returns:
- true when the lease token equals the token of the coordinator
-
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. All components in this record class are compared withObjects::equals(Object,Object). -
role
-
token
-
state
-