Record Class Decision
java.lang.Object
java.lang.Record
io.krabka.streams.coordination.Decision
- Record Components:
action- the step the member takes nowwaitUntilMillis- the instant of the next evaluation, in milliseconds since the Unix epoch, forDecision.Action.WAITonly
What one member does about a role right now.
Succession.evaluate(RoleState, MemberId, long, LeaseConfig) returns one.
The wait instant carries a value for Decision.Action.WAIT only, and it is zero for
every other action.
A decision never makes a member authoritative. It decides when a member calls
InitProducerId, and the transaction coordinator decides who wins. A wrong
decision makes a failover early or late, and it costs epoch churn.
Example
Decision decision = Succession.evaluate(state, me, clock.nowMillis(), config);
switch (decision.action()) {
case NOT_REGISTERED -> transport.register(role, me);
case CHALLENGE -> transport.acquireEpoch(role);
case HOLD -> leadership.renew();
case WAIT -> parkUntil(decision.waitUntilMillis());
}
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe step that one member takes about a role. -
Constructor Summary
ConstructorsConstructorDescriptionDecision(Decision.Action action, long waitUntilMillis) Rejects a null action. -
Method Summary
Modifier and TypeMethodDescriptionaction()Returns the value of theactionrecord component.static DecisionReturns the decision to callInitProducerIdnow.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static Decisionhold()Returns the decision to keep the role.static DecisionReturns the decision to register first.final StringtoString()Returns a string representation of this record class.static DecisionwaitUntil(long untilMillis) Returns the decision to wait until one instant.longReturns the value of thewaitUntilMillisrecord component.
-
Constructor Details
-
Decision
Rejects a null action.- Parameters:
action- the step the member takes nowwaitUntilMillis- the instant of the next evaluation, in milliseconds since the Unix epoch, forDecision.Action.WAITonly
-
-
Method Details
-
notRegistered
Returns the decision to register first.- Returns:
- a decision that carries
Decision.Action.NOT_REGISTERED
-
hold
Returns the decision to keep the role.- Returns:
- a decision that carries
Decision.Action.HOLD
-
challenge
Returns the decision to callInitProducerIdnow.- Returns:
- a decision that carries
Decision.Action.CHALLENGE
-
waitUntil
Returns the decision to wait until one instant.- Parameters:
untilMillis- the instant of the next evaluation, in milliseconds since the Unix epoch- Returns:
- a decision that carries
Decision.Action.WAIT
-
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. -
action
-
waitUntilMillis
public long waitUntilMillis()Returns the value of thewaitUntilMillisrecord component.- Returns:
- the value of the
waitUntilMillisrecord component
-