Github user tdas commented on a diff in the pull request:
https://github.com/apache/spark/pull/4957#discussion_r26146158
--- Diff:
streaming/src/test/scala/org/apache/spark/streaming/ReceiverSuite.scala ---
@@ -161,50 +161,27 @@ class ReceiverSuite extends TestSuiteBase with
Timeouts with Serializable {
val maxRate = 100
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]
+ val generatedData = 0 until expectedMessages
// Generate blocks
val startTime = System.currentTimeMillis()
+ val blockGenerator = new BlockGenerator(blockGeneratorListener, 1,
conf)
blockGenerator.start()
- var count = 0
- while(System.currentTimeMillis - startTime < waitTime) {
- blockGenerator.addData(count)
- generatedData += count
- count += 1
- Thread.sleep(1)
- }
+ generatedData.foreach(blockGenerator.addData(_))
blockGenerator.stop()
+ val endTime = System.currentTimeMillis()
+ // should have been rate limited
+ assert(endTime - startTime >= waitTime, "Should have taken longer than
the theoretical minimum time")
+
+ // we should get the same data
val recordedBlocks = blockGeneratorListener.arrayBuffers
val recordedData = recordedBlocks.flatten
assert(blockGeneratorListener.arrayBuffers.size > 0, "No blocks
received")
assert(recordedData.toSet === generatedData.toSet, "Received data not
same")
-
--- End diff --
Interesting! It could be that because of GC or something one 200 ms
interval received only 1 record (far below rate limit), which allowed the
next 200 ms interval to received 49 (above rate in terms of 200 ms but
still below rate in terms of the 400 ms interval). It could be that the
rate limiter we had did not synchronize time and count in sync with the
block intervals. Whatever the solutions is, it should do make all the
blocks as even as possible. Uneven blocks would become a bottleneck in
processing the corresponding batch.
Thanks for looking into this :)
On Tue, Mar 10, 2015 at 4:14 AM, Kevin <[email protected]> wrote:
> In streaming/src/test/scala/org/apache/spark/streaming/ReceiverSuite.scala
> <https://github.com/apache/spark/pull/4957#discussion_r26113197>:
>
> > val recordedBlocks = blockGeneratorListener.arrayBuffers
> > val recordedData = recordedBlocks.flatten
> > assert(blockGeneratorListener.arrayBuffers.size > 0, "No blocks
received")
> > assert(recordedData.toSet === generatedData.toSet, "Received data
not same")
> > -
>
> The thing is, it doesn't actually seem to do that. The test is expecting
> to get ~10 messages per block. I ran the test a few times and saw numbers
> like 49 and 1. I also got corresponding varying numbers of messages.
>
> I'll have another look and see if I can find a more reliable way of doing
> this.
>
> â
> Reply to this email directly or view it on GitHub
> <https://github.com/apache/spark/pull/4957/files#r26113197>.
>
---
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]