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

    https://github.com/apache/spark/pull/7913#discussion_r36314641
  
    --- Diff: 
streaming/src/main/scala/org/apache/spark/streaming/receiver/BlockGenerator.scala
 ---
    @@ -89,59 +108,97 @@ private[streaming] class BlockGenerator(
       private val blockPushingThread = new Thread() { override def run() { 
keepPushingBlocks() } }
     
       @volatile private var currentBuffer = new ArrayBuffer[Any]
    -  @volatile private var stopped = false
    +  @volatile private var state = Initialized
     
       /** Start block generating and pushing threads. */
    -  def start() {
    -    blockIntervalTimer.start()
    -    blockPushingThread.start()
    -    logInfo("Started BlockGenerator")
    +  def start(): Unit = synchronized {
    +    if (state == Initialized) {
    +      state = Active
    +      blockIntervalTimer.start()
    +      blockPushingThread.start()
    +      logInfo("Started BlockGenerator")
    +    } else {
    +      throw new SparkException("Cannot start BlockGenerator as already 
stopped")
    --- End diff --
    
    nit: "Cannot start BlockGenerator as already stopped" -> "Cannot start 
BlockGenerator as already started or stopped"


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