Github user tdas commented on a diff in the pull request:

    https://github.com/apache/spark/pull/6632#discussion_r32854351
  
    --- Diff: 
external/kafka/src/main/scala/org/apache/spark/streaming/kafka/KafkaUtils.scala 
---
    @@ -158,15 +158,30 @@ object KafkaUtils {
     
       /** get leaders for the given offset ranges, or throw an exception */
       private def leadersForRanges(
    -      kafkaParams: Map[String, String],
    +      kc: KafkaCluster,
           offsetRanges: Array[OffsetRange]): Map[TopicAndPartition, (String, 
Int)] = {
    -    val kc = new KafkaCluster(kafkaParams)
         val topics = offsetRanges.map(o => TopicAndPartition(o.topic, 
o.partition)).toSet
    -    val leaders = kc.findLeaders(topics).fold(
    -      errs => throw new SparkException(errs.mkString("\n")),
    -      ok => ok
    -    )
    -    leaders
    +    val leaders = kc.findLeaders(topics)
    +    KafkaCluster.checkErrors(leaders)
    +  }
    +
    +  /** Make sure offsets are available in kafka, or throw an exception */
    +  private def checkOffsets(
    +      kc: KafkaCluster,
    +      offsetRanges: Array[OffsetRange]): Unit = {
    +    val topics = offsetRanges.map(_.topicAndPartition).toSet
    +    val badRanges = KafkaCluster.checkErrors(for {
    --- End diff --
    
    @koeninger I know this is probably a good scala way, but this is kinda hard 
to read for the nesting. Could you take a the for-yield and put it in a 
separate variable? And then check for errors?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to