rajinisivaram commented on code in PR #13474:
URL: https://github.com/apache/kafka/pull/13474#discussion_r1154285495
##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerCoordinator.java:
##########
@@ -1635,6 +1641,38 @@ public String toString() {
return "(version" + version + ": " + partitionsPerTopic + ")";
}
}
+ private static class RackInfo {
+ private final Set<String> racks;
+ RackInfo(Optional<String> clientRack, PartitionInfo partition) {
+ if (clientRack.isPresent() && partition.replicas() != null) {
+ racks =
Arrays.stream(partition.replicas()).map(Node::rack).collect(Collectors.toSet());
+ } else {
+ racks = Collections.emptySet();
+ }
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof RackInfo)) {
+ return false;
+ }
+ RackInfo rackInfo = (RackInfo) o;
+ return Objects.equals(racks, rackInfo.racks);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(racks);
+ }
+
+ @Override
+ public String toString() {
+ return racks.isEmpty() ? "NO_RACKS" : "racks=" + racks;
Review Comment:
This appears in MetadataSnapshot as an ordered list by partition, so that
may be sufficient? To add partition index here, we would need to store
partition index in RackInfo as well, which seemed too much just for toString.
What do you think?
--
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]