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

    https://github.com/apache/spark/pull/3868#discussion_r22444552
  
    --- Diff: 
streaming/src/main/scala/org/apache/spark/streaming/scheduler/ReceiverTracker.scala
 ---
    @@ -223,22 +227,40 @@ class ReceiverTracker(ssc: StreamingContext, 
skipReceiverLaunch: Boolean = false
           thread.start()
         }
     
    -    def stop() {
    +    def stop(graceful: Boolean) {
           // Send the stop signal to all the receivers
           stopReceivers()
     
           // Wait for the Spark job that runs the receivers to be over
           // That is, for the receivers to quit gracefully.
    +      val stopTimeout = conf.getLong(
    +        "spark.streaming.gracefulStopTimeout",
    +        10 * ssc.graph.batchDuration.milliseconds)
    +
    +
           thread.join(10000)
     
           // Check if all the receivers have been deregistered or not
    -      if (!receiverInfo.isEmpty) {
    -        logWarning("All of the receivers have not deregistered, " + 
receiverInfo)
    +      def done = { receiverInfo.isEmpty && terminated }
    +
    +      if (graceful) {
    +        TimeoutUtils.waitUntilDone(stopTimeout,() => done ) match {
    +          case true =>
    +            logInfo("All of the receivers have deregistered successfully 
and job terminated")
    +          case false =>
    +            logError("Timeout waiting for receivers to deregister")
    +        }
           } else {
    -        logInfo("All of the receivers have deregistered successfully")
    +        if (!receiverInfo.isEmpty) {
    --- End diff --
    
    I think you might be able to remove a level of nesting and place this `if` 
alongside the `else` on the previous line.


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