hachikuji commented on code in PR #12206: URL: https://github.com/apache/kafka/pull/12206#discussion_r883057402
########## clients/src/main/java/org/apache/kafka/common/requests/DescribeQuorumResponse.java: ########## @@ -93,4 +94,57 @@ public static DescribeQuorumResponseData singletonResponse(TopicPartition topicP public static DescribeQuorumResponse parse(ByteBuffer buffer, short version) { return new DescribeQuorumResponse(new DescribeQuorumResponseData(new ByteBufferAccessor(buffer), version)); } + + public String getTopicNameByIndex(Integer index) { + return data.topics().get(index).topicName(); + } + + public Integer getPartitionLeaderId(String topicName, Integer partition) { + Integer leaderId = -1; + TopicData topic = data.topics().stream() + .filter(t -> t.topicName().equals(topicName)) + .findFirst() + .orElse(null); + if (topic != null) { + leaderId = Integer.valueOf(topic.partitions().get(partition).leaderId()); + } + return leaderId; + } + + /** + * Get the replica info for the given topic name and partition. + * @param topicName Name of the topic to fetch + * @param partition Index of the parition to fetch + * @param getVoterInfo Return the voter information if true, return observers otherwise + * @return List of {@link ReplicaState} + */ + private List<ReplicaState> getReplicaInfo(String topicName, Integer partition, boolean getVoterInfo) { + //List<QuorumInfo.ReplicaState> replicaInfo = new ArrayList<>(); + TopicData topic = data.topics().stream() + .filter(t -> t.topicName().equals(topicName)) + .findFirst() + .orElse(null); + if (topic != null) { + List<ReplicaState> replicaStates = getVoterInfo ? topic.partitions().get(partition).currentVoters() + : topic.partitions().get(partition).observers(); + //replicaStates.forEach( Review Comment: Left in by mistake? -- 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