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

    https://github.com/apache/spark/pull/18143#discussion_r119636878
  
    --- Diff: 
external/kafka-0-10/src/main/scala/org/apache/spark/streaming/kafka010/CachedKafkaConsumer.scala
 ---
    @@ -109,34 +113,42 @@ object CachedKafkaConsumer extends Logging {
     
       private case class CacheKey(groupId: String, topic: String, partition: 
Int)
     
    -  // Don't want to depend on guava, don't want a cleanup thread, use a 
simple LinkedHashMap
    -  private var cache: ju.LinkedHashMap[CacheKey, CachedKafkaConsumer[_, _]] 
= null
    +  private var cache: Cache[CacheKey, CachedKafkaConsumer[_, _]] = null
     
       /** Must be called before get, once per JVM, to configure the cache. 
Further calls are ignored */
       def init(
           initialCapacity: Int,
           maxCapacity: Int,
           loadFactor: Float): Unit = CachedKafkaConsumer.synchronized {
    -    if (null == cache) {
    -      logInfo(s"Initializing cache $initialCapacity $maxCapacity 
$loadFactor")
    -      cache = new ju.LinkedHashMap[CacheKey, CachedKafkaConsumer[_, _]](
    -        initialCapacity, loadFactor, true) {
    -        override def removeEldestEntry(
    -          entry: ju.Map.Entry[CacheKey, CachedKafkaConsumer[_, _]]): 
Boolean = {
    -          if (this.size > maxCapacity) {
    -            try {
    -              entry.getValue.consumer.close()
    -            } catch {
    -              case x: KafkaException =>
    -                logError("Error closing oldest Kafka consumer", x)
    -            }
    -            true
    -          } else {
    -            false
    +    if (cache == null) {
    +      val duration =
    +        
SparkEnv.get.conf.getTimeAsMs("spark.streaming.kafkaConsumerCache.timeout", 
"30m")
    --- End diff --
    
    All of the other configs in the dstream are of the form 
"spark.streaming.kafka.consumer.cache.something", not sure whether it's better 
to be consistent with the sql config, or with the dstream config


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to