MINOR: Adding a constant to denote UNKNOWN leader in LeaderAndEpoch (#11477)

Reviewers: José Armando García Sancio <jsancio@gmail.com>, Jason Gustafson <jason@confluent.io>
This commit is contained in:
Niket 2021-11-09 09:07:05 -08:00 committed by GitHub
parent 807c5b4d28
commit feee65a2cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 1 deletions

View File

@ -2448,7 +2448,7 @@ public class KafkaRaftClient<T> implements RaftClient<T> {
private final class ListenerContext implements CloseListener<BatchReader<T>> {
private final RaftClient.Listener<T> listener;
// This field is used only by the Raft IO thread
private LeaderAndEpoch lastFiredLeaderChange = new LeaderAndEpoch(OptionalInt.empty(), 0);
private LeaderAndEpoch lastFiredLeaderChange = LeaderAndEpoch.UNKNOWN;
// These fields are visible to both the Raft IO thread and the listener
// and are protected through synchronization on this ListenerContext instance

View File

@ -22,6 +22,7 @@ import java.util.OptionalInt;
public class LeaderAndEpoch {
private final OptionalInt leaderId;
private final int epoch;
public static final LeaderAndEpoch UNKNOWN = new LeaderAndEpoch(OptionalInt.empty(), 0);
public LeaderAndEpoch(OptionalInt leaderId, int epoch) {
this.leaderId = Objects.requireNonNull(leaderId);