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

    https://github.com/apache/spark/pull/9143#discussion_r44310128
  
    --- Diff: 
streaming/src/main/scala/org/apache/spark/streaming/scheduler/ReceiverTracker.scala
 ---
    @@ -488,7 +493,24 @@ class ReceiverTracker(ssc: StreamingContext, 
skipReceiverLaunch: Boolean = false
               registerReceiver(streamId, typ, host, executorId, 
receiverEndpoint, context.senderAddress)
             context.reply(successful)
           case AddBlock(receivedBlockInfo) =>
    -        context.reply(addBlock(receivedBlockInfo))
    +        if (WriteAheadLogUtils.isBatchingEnabled(ssc.conf, isDriver = 
true)) {
    +          val f = Future {
    +            if (active) {
    +              addBlock(receivedBlockInfo)
    +            } else {
    +              throw new IllegalStateException("Receiver Tracker Endpoint 
shut down.")
    +            }
    +          }(walBatchingThreadPool)
    +          f.onComplete { result =>
    +              if (active) {
    +                context.reply(result.get)
    --- End diff --
    
    It's better to log the error. Otherwise, it will just output the std err. 
See 
https://github.com/scala/scala/blob/a6e77f721921d9e2569433761a1e6a4056ae10f8/src/library/scala/concurrent/ExecutionContext.scala#L177
    
    Actually, I suggest rewriting these codes like:
    ```Scala
              walBatchingThreadPool.execute(new Runnable {
                override def run(): Unit = Utils.tryLogNonFatalError{
                  if (active) {
                    context.reply(addBlock(receivedBlockInfo))
                  } else {
                    throw new IllegalStateException("Receiver Tracker Endpoint 
shut down.")
                  }
                }
              })
    ```
    This is much simpler
    
    



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

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

Reply via email to