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

    https://github.com/apache/spark/pull/7471#discussion_r34965753
  
    --- Diff: 
streaming/src/main/scala/org/apache/spark/streaming/receiver/RateLimiter.scala 
---
    @@ -34,12 +36,28 @@ import org.apache.spark.{Logging, SparkConf}
       */
     private[receiver] abstract class RateLimiter(conf: SparkConf) extends 
Logging {
     
    -  private val desiredRate = 
conf.getInt("spark.streaming.receiver.maxRate", 0)
    -  private lazy val rateLimiter = GuavaRateLimiter.create(desiredRate)
    +  // treated as an upper limit
    +  private val maxRateLimit = 
conf.getInt("spark.streaming.receiver.maxRate", 0)
    +  private[receiver] var currentRateLimit = new AtomicInteger(maxRateLimit)
    --- End diff --
    
    What is this variable for? Seems like the only place its value is 
referenced outside this class is RateLimiterSuite. Rather than storing the 
current rate in the guava RateLimiter as well as this atomicInt, isnt it easier 
to just keep it one location, that is, the guava rate limiter? If you want to 
access the rate limit externally, then just have a def that returns, guava 
rateLimiter.getRate().


---
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