@@ -320,6 +320,10 @@ class CheckpointSuite extends TestSuiteBase {
320320 val testDir = Utils .createTempDir()
321321 val outputBuffer = new ArrayBuffer [Seq [Int ]] with SynchronizedBuffer [Seq [Int ]]
322322
323+ /**
324+ * Writes a file named `i` (which contains the number `i`) to the test directory and sets its
325+ * modification time to `clock`'s current time.
326+ */
323327 def writeFile (i : Int , clock : ManualClock ): Unit = {
324328 val file = new File (testDir, i.toString)
325329 Files .write(i + " \n " , file, Charsets .UTF_8 )
@@ -329,6 +333,9 @@ class CheckpointSuite extends TestSuiteBase {
329333 assert(file.lastModified() === clock.currentTime())
330334 }
331335
336+ /**
337+ * Returns ids that identify which files which have been recorded by the file input stream.
338+ */
332339 def recordedFiles (ssc : StreamingContext ): Seq [Int ] = {
333340 val fileInputDStream =
334341 ssc.graph.getInputStreams().head.asInstanceOf [FileInputDStream [_, _, _]]
@@ -369,6 +376,8 @@ class CheckpointSuite extends TestSuiteBase {
369376 // Create files and advance manual clock to process them
370377 for (i <- Seq (1 , 2 , 3 )) {
371378 writeFile(i, clock)
379+ // Advance the clock after creating the file to avoid a race when
380+ // setting its modification time
372381 clock.addToTime(batchDuration.milliseconds)
373382 if (i != 3 ) {
374383 // Since we want to shut down while the 3rd batch is processing
@@ -399,6 +408,8 @@ class CheckpointSuite extends TestSuiteBase {
399408 // Create files while the streaming driver is down
400409 for (i <- Seq (4 , 5 , 6 )) {
401410 writeFile(i, clock)
411+ // Advance the clock after creating the file to avoid a race when
412+ // setting its modification time
402413 clock.addToTime(batchDuration.milliseconds)
403414 }
404415
@@ -428,6 +439,8 @@ class CheckpointSuite extends TestSuiteBase {
428439 }
429440 for ((i, index) <- Seq (7 , 8 , 9 ).zipWithIndex) {
430441 writeFile(i, clock)
442+ // Advance the clock after creating the file to avoid a race when
443+ // setting its modification time
431444 clock.addToTime(batchDuration.milliseconds)
432445 eventually(eventuallyTimeout) {
433446 assert(batchCounter.getNumCompletedBatches === index + numBatchesAfterRestart + 1 )
0 commit comments