KAFKA-18131: Improve logs for voters (#18028)

Currently, the log of LeaderState#timeUntilCheckQuorumExpires uses streams without a terminal operator, resulting in output like java.util.stream.ReferencePipeline$3@39660237.
This PR aims to fix this issue and improve the log message.

Reviewers: Luke Chen <showuon@gmail.com>
This commit is contained in:
TengYao Chi 2025-01-06 18:12:46 +08:00 committed by GitHub
parent b9354d6886
commit 2e4a378c27
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View File

@ -156,7 +156,10 @@ public class LeaderState<T> implements EpochState {
"Current fetched voters are {}, and voters are {}",
checkQuorumTimeoutMs,
fetchedVoters,
voterStates.values().stream().map(voter -> voter.replicaKey)
voterStates.values()
.stream()
.map(voter -> voter.replicaKey)
.collect(Collectors.toUnmodifiableSet())
);
}
return remainingMs;

View File

@ -70,7 +70,7 @@ public final class ReplicaKey implements Comparable<ReplicaKey> {
@Override
public String toString() {
return String.format("ReplicaKey(id=%d, directoryId=%s)", id, directoryId);
return String.format("ReplicaKey(id=%d, directoryId=%s)", id, directoryId.map(Uuid::toString).orElse("<undefined>"));
}
public static ReplicaKey of(int id, Uuid directoryId) {