Set<String> topicsInBroker = new HashSet<>(); AtomicInteger missingPartitions = new AtomicInteger(0); List<PartitionInfo> leaderPartitionsInNode = cluster.partitionsForNode(brokerId); if (leaderPartitionsInNode.isEmpty()) { && ((double) missingPartitions.get() / cluster.partitionsForNode(brokerId).size() <= MAX_ALLOWED_MISSING_PARTITION_METRIC_PERCENT); if (!result) { LOG.warn("Broker {} is missing {}/{} topics metrics and {}/{} leader partition metrics. Missing leader topics: {}.", brokerId, missingTopics.size(), topicsInBroker.size(), missingPartitions.get(), cluster.partitionsForNode(brokerId).size(), missingTopics);
/** * A helper function to get the number of leader partitions for each topic on each broker. It is useful to * derive the partition level IO from the topic level IO on a broker. * TODO: create open source KIP to provide per partition IO metrics. */ private Map<Integer, Map<String, Integer>> leaderDistributionStats(Cluster cluster) { Map<Integer, Map<String, Integer>> stats = new HashMap<>(); for (Node node : cluster.nodes()) { Map<String, Integer> numLeadersByTopic = new HashMap<>(); stats.put(node.id(), numLeadersByTopic); for (PartitionInfo partitionInfo : cluster.partitionsForNode(node.id())) { numLeadersByTopic.merge(partitionInfo.topic(), 1, (v0, v1) -> v0 + v1); } } return stats; }
private List<ProducerBatch> drainBatchesForOneNode(Cluster cluster, Node node, int maxSize, long now) { int size = 0; List<PartitionInfo> parts = cluster.partitionsForNode(node.id()); List<ProducerBatch> ready = new ArrayList<>();
switch (rawMetricType) { case BROKER_FOLLOWER_FETCH_REQUEST_RATE: for (PartitionInfo partitionInfo : cluster.partitionsForNode(brokerId)) {
for (Node node : nodes) { int size = 0; List<PartitionInfo> parts = cluster.partitionsForNode(node.id()); List<RecordBatch> ready = new ArrayList<RecordBatch>();