vanzin commented on a change in pull request #25135: [SPARK-28367][SS] Use new
KafkaConsumer.poll API in Kafka connector
URL: https://github.com/apache/spark/pull/25135#discussion_r311300497
##########
File path:
external/kafka-0-10-sql/src/main/scala/org/apache/spark/sql/kafka010/KafkaOffsetReader.scala
##########
@@ -419,6 +416,21 @@ private[kafka010] class KafkaOffsetReader(
stopConsumer()
_consumer = null // will automatically get reinitialized again
}
+
+ private def getPartitions(): ju.Set[TopicPartition] = {
+ consumer.poll(jt.Duration.ZERO)
+ var partitions = consumer.assignment()
+ val startTimeMs = System.currentTimeMillis()
Review comment:
For this kind of logic it's better to use `System.nanoTime()` which is
monotonic. Also you can do a little less computation this way:
```
val deadline = System.nanoTime() + someTimeout;
while (... && System.nanoTime() < deadline) {
}
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]