You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by JoshRosen <gi...@git.apache.org> on 2014/09/15 20:13:35 UTC

[GitHub] spark pull request: [SPARK-1341] [Streaming] Throttle BlockGenerat...

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

    https://github.com/apache/spark/pull/945#discussion_r17558868
  
    --- Diff: streaming/src/test/scala/org/apache/spark/streaming/NetworkReceiverSuite.scala ---
    @@ -146,6 +146,44 @@ class NetworkReceiverSuite extends FunSuite with Timeouts {
         assert(recordedData.toSet === generatedData.toSet)
       }
     
    +  test("block generator throttling") {
    +    val blockGeneratorListener = new FakeBlockGeneratorListener
    +    val blockInterval = 50
    +    val maxRate = 200
    +    val conf = new SparkConf().set("spark.streaming.blockInterval", blockInterval.toString).
    +      set("spark.streaming.receiver.maxRate", maxRate.toString)
    +    val blockGenerator = new BlockGenerator(blockGeneratorListener, 1, conf)
    +    val expectedBlocks = 20
    +    val waitTime = expectedBlocks * blockInterval
    +    val expectedMessages = maxRate * waitTime / 1000
    +    val expectedMessagesPerBlock = maxRate * blockInterval / 1000
    +    val generatedData = new ArrayBuffer[Int]
    +
    +    // Generate blocks
    +    val startTime = System.currentTimeMillis()
    +    blockGenerator.start()
    +    var count = 0
    +    while(System.currentTimeMillis - startTime < waitTime) {
    +      blockGenerator += count
    +      generatedData += count
    +      count += 1
    +      Thread.sleep(1)
    +    }
    +    blockGenerator.stop()
    +
    +    val recordedData = blockGeneratorListener.arrayBuffers
    +    assert(blockGeneratorListener.arrayBuffers.size > 0)
    +    assert(recordedData.flatten.toSet === generatedData.toSet)
    +    // recordedData size should be close to the expected rate
    +    assert(recordedData.flatten.size >= expectedMessages * 0.9 &&
    +      recordedData.flatten.size <= expectedMessages * 1.1 )
    +    // the first and last block may be incomplete, so we slice them out
    +    recordedData.slice(1, recordedData.size - 1).foreach { block =>
    +      assert(block.size >= expectedMessagesPerBlock * 0.8 &&
    --- End diff --
    
    This test is still a frequent cause of Jenkins failures; I'm investigating fixes, but I'd appreciate help.


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

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