pprovenzano commented on code in PR #14737: URL: https://github.com/apache/kafka/pull/14737#discussion_r1397547750
########## core/src/main/scala/kafka/server/metadata/KRaftMetadataCache.scala: ########## @@ -143,21 +143,30 @@ class KRaftMetadataCache(val brokerId: Int) extends MetadataCache with Logging w private def getOfflineReplicas(image: MetadataImage, partition: PartitionRegistration, listenerName: ListenerName): util.List[Integer] = { - // TODO: in order to really implement this correctly, we would need JBOD support. - // That would require us to track which replicas were offline on a per-replica basis. - // See KAFKA-13005. val offlineReplicas = new util.ArrayList[Integer](0) for (brokerId <- partition.replicas) { Option(image.cluster().broker(brokerId)) match { case None => offlineReplicas.add(brokerId) - case Some(broker) => if (broker.fenced() || !broker.listeners().containsKey(listenerName.value())) { + case Some(broker) => if (isReplicaOffline(partition, listenerName, broker)) { offlineReplicas.add(brokerId) } } } offlineReplicas } + private def isReplicaOffline(partition: PartitionRegistration, listenerName: ListenerName, broker: BrokerRegistration) = { + broker.fenced() || !broker.listeners().containsKey(listenerName.value()) || isInOfflineDir(broker, partition) + } + + private def isInOfflineDir(broker: BrokerRegistration, partition: PartitionRegistration): Boolean = { Review Comment: Do we have to handle UNASSIGNED here? It would return false. -- 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