jsancio commented on code in PR #15859: URL: https://github.com/apache/kafka/pull/15859#discussion_r1595568006
########## raft/src/main/java/org/apache/kafka/raft/internals/VoterSet.java: ########## @@ -64,6 +64,43 @@ public Optional<InetSocketAddress> voterAddress(int voter, String listener) { .flatMap(voterNode -> voterNode.address(listener)); } + /** + * Returns if the node is a voter in the set of voters. + * + * If the voter set includes the directory id, the {@code nodeKey} directory id must match the + * directory id specified by the voter set. + * + * If the voter set doesn't include the directory id ({@code Optional.empty()}), a node is in + * the voter set as long as the node id matches. The directory id is not checked. + * + * @param nodeKey the node's id and directory id + * @return true if the node is a voter in the voter set, otherwise false + */ + public boolean isVoter(ReplicaKey nodeKey) { + VoterNode node = voters.get(nodeKey.id()); + if (node != null) { + if (node.voterKey().directoryId().isPresent()) { + return node.voterKey().directoryId().equals(nodeKey.directoryId()); + } else { + // configured voter set doesn't an uuid so it is a voter as long as the node id Review Comment: Fixed. -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org