junrao commented on code in PR #15859:
URL: https://github.com/apache/kafka/pull/15859#discussion_r1599148400
##########
raft/src/main/java/org/apache/kafka/raft/internals/KafkaRaftMetrics.java:
##########
@@ -87,17 +89,34 @@ public KafkaRaftMetrics(Metrics metrics, String
metricGrpPrefix, QuorumState sta
this.currentLeaderIdMetricName = metrics.metricName("current-leader",
metricGroupName, "The current quorum leader's id; -1 indicates unknown");
metrics.addMetric(this.currentLeaderIdMetricName, (mConfig,
currentTimeMs) -> state.leaderId().orElse(-1));
- this.currentVotedIdMetricName = metrics.metricName("current-vote",
metricGroupName, "The current voted leader's id; -1 indicates not voted for
anyone");
+ this.currentVotedIdMetricName = metrics.metricName("current-vote",
metricGroupName, "The current voted id; -1 indicates not voted for anyone");
metrics.addMetric(this.currentVotedIdMetricName, (mConfig,
currentTimeMs) -> {
if (state.isLeader() || state.isCandidate()) {
return state.localIdOrThrow();
- } else if (state.isVoted()) {
- return state.votedStateOrThrow().votedId();
} else {
- return -1;
+ return (double) state.maybeVotedState()
Review Comment:
What don't we need the casting before?
--
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]