Created
January 25, 2019 15:59
-
-
Save rssanders3/22a55cf0d5fb22db2f5e581f15f130e0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val storedOffsets: Option[mutable.Map[TopicPartition, Long]] = loadOffsets(spark, kuduContext) | |
| val kafkaDStream = storedOffsets match { | |
| case None => | |
| LOGGER.info("storedOffsets was None") | |
| kafkaParams += ("auto.offset.reset" -> "latest") | |
| KafkaUtils.createDirectStream[String, Array[Byte]] | |
| (ssc, PreferConsistent, ConsumerStrategies.Subscribe[String, Array[Byte]] | |
| (topicsSet, kafkaParams) | |
| ) | |
| case Some(fromOffsets) => | |
| LOGGER.info("storedOffsets was Some(" + fromOffsets + ")") | |
| kafkaParams += ("auto.offset.reset" -> "none") | |
| KafkaUtils.createDirectStream[String, Array[Byte]] | |
| (ssc, PreferConsistent, ConsumerStrategies.Assign[String, Array[Byte]] | |
| (fromOffsets.keys.toList, kafkaParams, fromOffsets) | |
| ) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment