Cyrill commented on code in PR #7507:
URL: https://github.com/apache/ignite-3/pull/7507#discussion_r2873778713
##########
modules/raft/src/main/java/org/apache/ignite/internal/raft/client/LeaderAvailabilityState.java:
##########
@@ -112,34 +126,95 @@ void onLeaderElected(InternalClusterNode leader, long
term) {
synchronized (mutex) {
if (stopped) {
- LOG.debug("Ignoring leader election after stop [leader={},
term={}]", leader, term);
- return;
+ LOG.debug("Ignoring leader update after stop [leader={},
term={}]", leader, term);
+ return false;
}
// Ignore stale term notifications.
if (term <= currentTerm) {
LOG.debug("Ignoring stale leader [newTerm={},
currentTerm={}]", term, currentTerm);
- return;
+ return false;
}
long previousTerm = currentTerm;
State previousState = currentState;
currentTerm = term;
+ this.leader = leader;
- if (currentState == State.WAITING_FOR_LEADER) {
+ if (leader != null && currentState == State.WAITING_FOR_LEADER) {
currentState = State.LEADER_AVAILABLE;
futureToComplete = waiters;
}
- LOG.debug("Leader elected [leader={}, term={}, previousTerm={},
stateChange={}->{}]",
+ LOG.debug("Leader updated [leader={}, term={}, previousTerm={},
stateChange={}->{}]",
leader, term, previousTerm, previousState, currentState);
}
// Complete outside the lock to avoid potential deadlocks with future
callbacks.
if (futureToComplete != null) {
futureToComplete.complete(term);
}
+
+ return true;
+ }
+
+ /**
+ * Updates the cached leader without changing the term or availability
state.
+ *
+ * <p>This is an optimistic cache update used when a response or redirect
provides leader information
+ * without a term change. Has no effect after stop.
+ *
+ * @param leader The leader peer hint (may be {@code null} to clear).
+ */
+ void setLeaderHint(@Nullable Peer leader) {
Review Comment:
done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]